Skip to content

fix(control_plane): X-Agent-ID header + memory_limit knob + drop gorillas3 bucket (B1 downstream bundle) - #279

Merged
zzylol merged 1 commit into
mainfrom
b1-downstream-bundle-id-mem-bucket
May 18, 2026
Merged

zzylol merged 1 commit into
mainfrom
b1-downstream-bundle-id-mem-bucket

Conversation

@zzylol

@zzylol zzylol commented May 18, 2026

Copy link
Copy Markdown
Contributor

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.

  • Fix 1 (Issue feat: DataCollector controller client — dynamic query config #2): thread X-Agent-ID into the opamp emit so the agent re-identifies after a controller-pushed Docker restart. Without this, /api/v1/agents returns {} 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 inside replan_metric, bootstrap GET when pinned_agent_id is set) thread the real agent id; broadcast call sites emit the literal $AGENT_ID placeholder.
  • Fix 2 (Issue feat: complete OTLP sketch ingest → SimpleMapStore #3): ASAP_AGENT_MEMORY_LIMIT_MIB env knob (default 1280) replaces the hardcoded memory_limiter soft limit, mirroring the build_gorillas3_yaml env-substitute pattern. spike_limit_mib scales as max(256, limit/5).
  • Fix 3 (gorillas3 Bucket Phase 2): drop the now-unread bucket: line from build_gorillas3_yaml. ASAPCollector#387 retired the runtime use of the field; only tsdb_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 contains X-Agent-ID: with the threaded id
  • b1_emit_preserves_dollar_agent_id_placeholder_for_broadcast — broadcast callers keep $AGENT_ID verbatim for agent-container env expansion
  • b1_memory_limiter_defaults_to_1280_mib_when_env_unset — default unchanged
  • b1_memory_limiter_honours_asap_agent_memory_limit_mib_env — operator-bumped value flows through, spike scales as max(256, limit/5)
  • b1_gorillas3_emit_drops_bucket_field_keeps_tsdb_bucket — no top-level bucket: line, tsdb_bucket: present

Closes B1-downstream Issues #2 + #3 + gorillas3-Bucket Phase 2.

🤖 Generated with Claude Code

…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>
@zzylol
zzylol merged commit e0374d2 into main May 18, 2026
@zzylol
zzylol deleted the b1-downstream-bundle-id-mem-bucket branch July 17, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant