feat(monitor): hot-reload the CDM coordinator's monitor set (no restart) - #379
Merged
Merged
Conversation
The data-plane monitor coordinator read streaming_config.monitors() ONCE at boot into MonitorCoordinator::new. But the control plane publishes the real config slightly AFTER boot via the /api/v1/streaming-config hot-reload POST (an ArcSwap in hot_reload_config) — which updated the query engine but NOT the coordinator. So a monitor that arrived post-boot never reached the coordinator and every edge registering for it was rejected as 'register for unconfigured monitor — ignored', leaving coordinated sampling dead unless the data-plane was restarted with the monitor already in its boot config. Make the coordinator reconfigurable on the live config: - cfgs moves behind a std::sync::RwLock (held only for brief, non-await sections). - New MonitorCoordinator::reconfigure(specs) diffs against the current set and applies added/changed/removed monitors, returning the counts. Added specs become matchable immediately; changed specs (new tau/eps/window) evict the stale live Monitor so the next register rebuilds it under the new spec (edges re-register every epoch, so it self-heals within one window); removed specs drop spec + live state. Unchanged monitors keep their in-flight slack state. - main.rs spawns a watcher that polls the hot_reload ArcSwap (atomic load + pointer-compare every 2s) and calls reconfigure on each swap — so a controller-pushed monitor takes effect live, no restart, no boot-config seed. MonitorConfig gains PartialEq for change detection. Two unit tests cover add/change/remove + idempotency and live-state eviction on change. 2/2 pass. This removes the need for the Fig 9 run-side workaround (seed the monitor into the boot config + restart the data-plane); pairs with ASAPCollector#503/#504. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
Live validation (Fig 9, 8-node CloudLab) ✅Built a data-plane image from this branch + the per-sid Data-plane log (no seed, no restart): The watcher applied the controller-pushed Result — identical to the boot-seed run, with the workaround gone:
The coordinator now picks up a controller-pushed monitor live with no restart and no boot-config seed — confirming this removes the ASAPCollector#503 Fig 9 workaround. |
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.
Problem
The CDM monitor coordinator read
streaming_config.monitors()once at boot (main.rs, intoMonitorCoordinator::new). But the control plane publishes the real config slightly after boot via the/api/v1/streaming-confighot-reload POST (anArcSwapinhot_reload_config) — which updated the query engine but not the coordinator. So a monitor published post-boot never reached the coordinator: every edge registering for it was rejected asregister for unconfigured monitor — ignored, and coordinated sampling stayed dead unless the data-plane was restarted with the monitor already baked into its boot config.This is exactly the gap that forced the Fig 9 run-side workaround (seed the monitor into the boot
streaming.yaml+ restart the data-plane) in ProjectASAP/ASAPCollector#503.Fix — make the coordinator reconfigurable on the live config
MonitorCoordinator.cfgsmoves behind astd::sync::RwLock(held only for brief, non-awaitcritical sections, so it's safe in async code).MonitorCoordinator::reconfigure(specs)diffs the incoming specs against the current set and applies the delta, returning(added, changed, removed):Monitor);Monitorso the next register rebuilds it under the new spec; edges re-register every epoch, so it self-heals within one window;(0,0,0)).main.rsspawns a watcher that polls thehot_reload_configArcSwap(an atomic load +Arc::ptr_eqevery 2 s) and callsreconfigureonly on an actual swap — so a controller-pushed monitor takes effect live, with no restart and no boot-config seed.MonitorConfiggainsPartialEqfor change detection.Tests
Two unit tests (
monitor::server::reconfigure_tests), 2/2 pass:reconfigure_adds_changes_and_removes_specs— add + change + remove counts,monitor_count, and idempotency.reconfigure_evicts_live_state_for_changed_monitor— a register materializes live state; a τ change evicts it; an unconfigured key is still rejected.Public signatures of
new/monitor_countare unchanged (the harness binary is unaffected).Impact
Removes the boot-seed-and-restart workaround for live coordinated sampling. Pairs with ASAPCollector#503 (Fig 9) and #504 (edge), and ASAPQuery-backend#377 (per-sid
f_iallocation).🤖 Generated with Claude Code