fix(control_plane): X-Agent-ID header + memory_limit knob + drop gorillas3 bucket (B1 downstream bundle) - #279
Merged
Conversation
…llas3 bucket (B1 downstream bundle) Three follow-ups to ASAPCollector#383 (agent OpAMP-apply) and companion PRs, bundled because they all touch control_plane/src/emit/stage_config.rs. Fix 1 (Issue #2): thread X-Agent-ID into opamp emit The controller's emitted opamp extension block didn't include `headers: X-Agent-ID: <id>` -- so when the agent applies a controller-pushed config and Docker restarts it, the reconnected agent has no agent-id and the controller's OpAMP server can't identify it. Empty `/api/v1/agents` after restart. Thread agent_id from replan / main into the three emit functions; add to each opamp block. Per-agent call sites (`push_config_to_agent`, the per-agent re-emit loop inside `replan_metric`, and the bootstrap GET path when `pinned_agent_id` is set) thread the real agent id. Broadcast call sites that don't have a single agent in scope (handle_plan's typed-stage-split push, handle_rollback, replan fallback) emit the literal `$AGENT_ID` placeholder and rely on the agent container's env to expand it at boot. Fix 2 (Issue #3): ASAP_AGENT_MEMORY_LIMIT_MIB env knob memory_limiter was hardcoded to 1280 MiB. Smoke agent at 1.5 GiB trips the soft limit under the 5-sketch + gorillas3 workload. Read ASAP_AGENT_MEMORY_LIMIT_MIB from the controller's env (default 1280, mirroring the build_gorillas3_yaml env-substitute pattern). `spike_limit_mib` scales as `max(256, limit/5)` so the ratio stays sensible as operators tune the limit. Operators raise both the env var AND the agent container's cgroup limit together. Fix 3 (gorillas3 Bucket Phase 2): drop `bucket:` from emit ASAPCollector#387 made the gorillas3 `Bucket` field a no-op: validation + log + TSDBBucket fallback retired. Controller doesn't need to emit it anymore. Remove the bucket: line from build_gorillas3_yaml. ASAPCollector#387's gorillas3 Config struct still has the `Bucket` field (mapstructure compat) but it's now unread. Test plan: * `cargo test -p control_plane --lib`: 706 (699 baseline + 7 new) * X-Agent-ID assertion: emitted yaml under emit_edge_yaml (both legacy + 5-sketch routing) and emit_gateway_yaml contains `X-Agent-ID:` with the threaded agent_id; broadcast callers preserve the `$AGENT_ID` placeholder verbatim. * memory_limit assertion: emitted yaml's memory_limiter.limit_mib matches ASAP_AGENT_MEMORY_LIMIT_MIB env (or 1280 default), with spike_limit_mib scaling as max(256, limit/5). * bucket: absence: build_gorillas3_yaml output does NOT contain a top-level `bucket:` line (but DOES contain `tsdb_bucket:`). Closes B1-downstream Issues #2 + #3 + gorillas3-Bucket Phase 2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three follow-ups to ASAPCollector#383 (agent OpAMP-apply) and companion PRs, bundled because all three changes touch
control_plane/src/emit/stage_config.rs.X-Agent-IDinto the opamp emit so the agent re-identifies after a controller-pushed Docker restart. Without this,/api/v1/agentsreturns{}after the restart and the controller can't push config to the orphaned agent. Per-agent call sites (push_config_to_agent, the per-agent re-emit loop insidereplan_metric, bootstrap GET whenpinned_agent_idis set) thread the real agent id; broadcast call sites emit the literal$AGENT_IDplaceholder.ASAP_AGENT_MEMORY_LIMIT_MIBenv knob (default 1280) replaces the hardcodedmemory_limitersoft limit, mirroring thebuild_gorillas3_yamlenv-substitute pattern.spike_limit_mibscales asmax(256, limit/5).bucket:line frombuild_gorillas3_yaml. ASAPCollector#387 retired the runtime use of the field; onlytsdb_bucket:(the real TSDB block write destination) is kept.Test plan
cargo test -p control_plane --lib— 706 (699 baseline + 7 new)b1_legacy_emit_threads_x_agent_id_header,b1_5sketch_emit_threads_x_agent_id_header,b1_gateway_emit_threads_x_agent_id_header— emitted yaml containsX-Agent-ID:with the threaded idb1_emit_preserves_dollar_agent_id_placeholder_for_broadcast— broadcast callers keep$AGENT_IDverbatim for agent-container env expansionb1_memory_limiter_defaults_to_1280_mib_when_env_unset— default unchangedb1_memory_limiter_honours_asap_agent_memory_limit_mib_env— operator-bumped value flows through, spike scales asmax(256, limit/5)b1_gorillas3_emit_drops_bucket_field_keeps_tsdb_bucket— no top-levelbucket:line,tsdb_bucket:presentCloses B1-downstream Issues #2 + #3 + gorillas3-Bucket Phase 2.
🤖 Generated with Claude Code