Repository navigation
refactor(components): run xmc-bridge as a controller-runtime controller - #1224
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the xmc_bridge controller to use controller-runtime instead of a custom reconciliation loop, introducing a new ComponentController and a jittered exponential backoff rate limiter. The feedback suggests two improvements to component_controller.go: conditionally joining errors in Reconcile to avoid unnecessary wrapping when only one error is present, and adding a defensive nil check in dependencyUnreadyReason to prevent a potential nil pointer dereference panic.
This was referenced Oct 13, 2026
test(components): add lifecycle kind E2E suite with blocked deactivation and finalizer cleanup
#1151
Merged
VLukiantsev
force-pushed
the
refactor/components-bridge-controller-runtime-b548436300
branch
2 times, most recently
from
October 14, 2026 09:37
00d25cc to
66b91e8
Compare
VLukiantsev
force-pushed
the
refactor/components-bridge-controller-runtime-b548436300
branch
2 times, most recently
from
October 14, 2026 11:58
a8fa007 to
01e5b45
Compare
VLukiantsev
force-pushed
the
refactor/components-bridge-controller-runtime-b548436300
branch
from
October 14, 2026 14:22
01e5b45 to
486d12a
Compare
Replace the xmc-bridge namespace sweep, which listed and reconciled every Component each probe interval, with a controller-runtime manager and a per-Component ComponentController. - The manager cache watches the Components of --namespace only, and the manager's client serves unstructured Gets and Lists from it (CacheOptions.Unstructured), so Reconcile and the dependents watch never read Components from the API server. - A Component is reconciled when its generation, labels or annotations change or its deletion starts, and --probe-interval after each pass that does not release its finalizer, to observe workload health. - A dependents watch enqueues the Components that list a dependency in spec.dependencies when it is created, deleted, changes generation, or changes readiness as a dependency. Status writes that keep its readiness do not re-enqueue its dependents, so condition timestamp refreshes cannot loop. - A failed pass still persists its status, then returns its error so the work queue retries the Component with exponential backoff from 5s to 300s with +/-10% jitter (NewComponentRateLimiter). - The KinD harness runs one manager per test namespace instead of hand- driven passes; the finalizer cleanup scenario waits for the Component to be gone and then checks that CMS no longer has it. Tests: unit tests for Reconcile, dependency gating, mapDependents, the predicates and the rate limiter; an envtest that activates a dependent created before its dependency through the dependents watch alone and checks that a dependent's pass does not re-enqueue its dependency, that a deletion event alone releases the finalizer, and that no Component GET or LIST reaches the API server after the cache syncs; the KinD components_lifecycle_test. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
Join the Reconciler pass error and the result persistence error only when both are set, and treat a typed-nil object as not a Component in the dependency readiness predicate. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…ayer CMS now fails closed without an authorizer (#1219), so in-process servers built by the tests in this layer pass WithAuthorizer(NewDisabledAuthorizer()), as main's own tests do. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…envtest file Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
VLukiantsev
force-pushed
the
refactor/components-bridge-controller-runtime-b548436300
branch
from
October 14, 2026 14:48
486d12a to
4008060
Compare
VLukiantsev
marked this pull request as ready for review
October 14, 2026 14:49
andrzejfudro
approved these changes
Oct 14, 2026
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
Replaces the xmc-bridge namespace sweep, which listed and reconciled every Component on each probe interval, with a controller-runtime manager and a per-Component
ComponentController. Status writes and theReconcilerare unchanged; only scheduling changes.Motivation & Context
The ticker sweep did N passes for a dependency chain of N, had no per-item backoff, and re-read every Component each interval. The ownership layers later in this stack need controller primitives (uncached reads,
RequeueAfter, channel sources, leader-elected runnables), so the controller foundation lands first.Key Changes
--namespace; unstructured Gets and Lists are served from it (CacheOptions.Unstructured), so no Component read reaches the API server after cache sync.--probe-intervalrequeues to observe workload health. The existingPROBE_TIMEOUTkeeps bounding a pass in this layer; the separateRECONCILE_TIMEOUTis fix(components): make bridge reconcile timeout and concurrency configurable #1272.mapDependents) enqueues Components that list a dependency when it is created, deleted, changes generation, or changes readiness. Status writes that keep readiness do not re-enqueue, so timestamp refreshes cannot loop.NewComponentRateLimiter: per-item exponential backoff 5s→300s with ±10% jitter; a failed pass persists status and returns its error (a single failure unwrapped).mapDependents, predicates and the rate limiter; an envtest for dependents-watch activation, deletion-event finalizer release, and no API-server Component reads after sync.Stack Position
RECONCILE_TIMEOUTcommit moved to fix(components): make bridge reconcile timeout and concurrency configurable #1272, together with the--max-concurrent-reconcilesflag from fix(components): run xmc-bridge as a single leader-elected writer #1225.Assumptions
Watchescan move to its own layer.main, andgit range-diffshows no behavioral change — if wrong, the checkpoint must be re-run before merge.Verification & Testing
bazel test //pkg/components/... //cmd/xmc_bridge/... //cmd/experiment_state_server/... //cmd/actuator/... //test/e2e:kind_3p_harness_unit_testand the//test/helmpy tests at this layer's tip;golangci-lint run(v1.64.6);gofmt -l.//test/e2e:components_lifecycle_testpassed with the whole stack applied.tools/analyze_diff_size.py): 321 prod / 740 test / 1061 total / 26 doc lines (see Assumptions).Live Deployment & Manual Testing
enable_components: true, Spanner-backed CMS), upgraded with the dev-environment upgrade script.5/5,16/16pods Ready) before and after the checkpoint.mainand before the split; no behavioral change in this layer.spec.version,spec.deletionProtection,metadata.finalizers) and deleting Component CRs reconciles immediately via the watch, without namespace-wide polling.mapDependents)mt-cp1-dep, created before its dependencymt-cp1-prereq, reportedReady=False/DependenciesNotReady. Creatingmt-cp1-prereqenqueued it immediately and it becameReady=True/ComponentHealthywithDependenciesReady=True/AllDependenciesReady.NewComponentRateLimiterand converged toSynced=True/CMSSynced.Related Issues / Bugs
Bug: 548436300
TAG=agy
CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
Stack created with GitHub Stacks CLI • Give Feedback 💬