Repository navigation
feat(components): isolate per-CR Helm actuation state by UID - #1239
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces per-CR incarnation isolation for Helm component management by adding a UID field to ComponentRef and transitioning state tracking keys to include this UID. It also adds a CEL validation rule to the Component CRD to limit metadata.name to 45 characters, ensuring Helm release names stay within limits. While these changes successfully isolate different CR incarnations, a critical issue was identified in uninstallComponent where a disabled component's Helm release could be leaked on a controller cold start because the uninstall is skipped when the specific incarnation key is not yet known in memory. A suggestion has been provided to check if the incarnation key is explicitly known before skipping the uninstall.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces per-CR-incarnation isolation for Helm component releases by incorporating the Kubernetes metadata UID into the state tracking keys. This prevents stale or superseded custom resource incarnations from interfering with active ones during upgrades or teardowns. Additionally, a CEL validation rule is added to the CRD to limit component names to 45 characters, ensuring Helm release names stay within the 53-character limit. Feedback on the changes suggests removing redundant calls to dropPendingUpgrade and setUpgradeErr in uninstallComponent since these are already handled internally by forgetIncarnationLocked.
7594a81 to
87674b5
Compare
87674b5 to
23e6001
Compare
2749898 to
a2a44e0
Compare
a2a44e0 to
5925ae3
Compare
5925ae3 to
bb0e46d
Compare
bb0e46d to
3b8141e
Compare
f5803f0 to
f53f44a
Compare
f53f44a to
31ce028
Compare
f88605f to
f74228b
Compare
7e12b24 to
3a837df
Compare
198ebe0 to
bf0791f
Compare
bf0791f to
dd3ce3c
Compare
990b5a2 to
2ece4b9
Compare
175338e to
a880612
Compare
Carry ComponentRef.UID across K8sHelmManager actuation state, upgrade error tracking, and async upgrade coalescing so duplicate Component CRs in different namespaces or superseded CR incarnations in the same namespace never overwrite or cancel an active owner's state. Keep ComponentReleaseNameForRef returning the canonical xmc-cmp-<name> release name for live upgrade and Orphan adoption compatibility, and enforce metadata.name <= 45 in CEL admission validation. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…elete Skip the Delete uninstall only when the CR incarnation's own UID-scoped state is recorded as inactive. The namespace-level entry hydrated from the values ConfigMap on cold start cannot prove that the incarnation's release was already uninstalled, so it no longer suppresses the uninstall. Also drop a trailing blank line flagged by gofmt. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
When a CR incarnation is actuated, drop the in-memory activation, actuation, upgrade, health and repair state of every other incarnation of the same namespace/name. Kubernetes keeps one live CR per name, so a stale incarnation whose teardown never ran could otherwise suppress the live incarnation's uninstall or run an outdated queued upgrade. Superseded and purged incarnations now delete their entries instead of leaving permanent inactive markers. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…carnations forgetIncarnationLocked already clears the incarnation's pending upgrade, upgrade error and cached health verdict. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…refix Adopting a release with a new CR incarnation now evicts every kind of in-memory state of superseded incarnations (actuation, upgrade errors, pending upgrades, health and repair) plus the namespace-level entry hydrated from the values ConfigMap. Reconciler.ForgetComponent also evicts the Helm manager state of every incarnation once the CR is gone, so incarnations whose teardown never ran no longer leak. The Component CRD rejects metadata.name values starting with xmc-cmp-, preventing doubly prefixed release names. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…rade outcomes - Mark the metadata.name CEL rules optionalOldSelf with an oldSelf.hasValue() guard, so a Component stored before the rules existed can still be updated, have its status written and its finalizer removed after a CRD upgrade. Covered by a new envtest. - Record an asynchronous upgrade outcome only while the request is still the incarnation's pending upgrade. An outcome for an incarnation evicted by a teardown or ForgetComponent mid-upgrade is logged and discarded instead of recreating its upgradeErrs entry. - Cover ComponentReleaseName canonicalization of resource-style names. Addresses: - #1239 (comment) - #1239 (comment) - #1239 (comment) Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
Summary
Helm actuation state, upgrade error tracking and async upgrade coalescing are now keyed by the Component's UID, so duplicate CRs in other namespaces or superseded incarnations never overwrite or cancel the active owner's state.
Motivation & Context
State keyed only by name let a conflicting or recreated CR clobber the live owner's actuation state, and deleting it could purge the owner's release. #1240 relies on per-CR state to clean up only the deleted CR's own workload.
Key Changes
ComponentRef.UIDcarried throughK8sHelmManageractuation state, upgrade error tracking and upgrade coalescing.ComponentReleaseNameForRefkeeps returning the canonicalxmc-cmp-<name>release name, for live upgrade andOrphanadoption compatibility.ComponentReleaseNamecanonicalizes its input withnaming.CanonicalComponentName, so release names match the CMS form (components/foo→xmc-cmp-foo). CR names are plain DNS labels, so the bridge's behavior is unchanged.metadata.name≤ 45 characters, so the release name stays within Helm limits, and rejects names starting withxmc-cmp-, so release names are never doubly prefixed. Both rules are create-only (optionalOldSelf), so a Component stored before them can still be updated, have its status written and its finalizer removed.Reconciler.ForgetComponentalso evicts the Helm manager state of every incarnation once the CR is gone, so ghost incarnations no longer leak. An asynchronous upgrade that finishes after its incarnation was evicted or superseded has its outcome discarded rather than recreating that state.Purge1PComponentalways runs the Helm uninstall, even when ConfigMap and in-memory state are empty (cold start, fenced cluster).Deleteno longer treats the ConfigMap-hydrated namespace entry as proof of a prior uninstall, so after a restart it uninstalls leaked releases.Stack Position
Assumptions
xmc-cmp-. Objects stored before the rules stay updatable because the rules are create-only.xmc-cmp-CEL rule, create-only name rules and the evicted-upgrade guard are covered by unit and envtest tests only; the live GKE evidence below predates them.main, andgit range-diffshows no behavioral change — if wrong, the checkpoint must be re-run before merge.Verification & Testing
bazel test //pkg/components/bridge:bridge_test //cmd/xmc_bridge:xmc_bridge_test;bazel test //pkg/components/... //cmd/xmc_bridge/... //api:protos_breaking_testat feat(components): enforce deletion ownership and fenced CR cleanup #1240 and the stack top.//test/e2e:components_lifecycle_testpassed with the whole stack applied.tools/analyze_diff_size.py): 247 prod / 437 test / 2 doc lines.Live Deployment & Manual Testing
enable_components: true, Spanner-backed CMS), upgraded with the dev-environment upgrade script including Spanner migrations014/015.5/5,16/16pods Ready, baseline Component CRs Ready and Synced).main.git range-diffagainst the current branches shows only rebase-induced import path updates (internal/logging) and the removal of unrelatedMODULE.bazel.lockchurn from feat(components): send RequestSource from bridge and record status.componentGeneration #1237; no behavioral change.mt-cp3-recreateand deleting the conflictingmt-cp3-del2kept actuation state per CR UID and uninstalled only the deleted CR's local Helm release (action=purge).Related Issues / Bugs
Bug: 548436300
TAG=agy
CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
Stack created with GitHub Stacks CLI • Give Feedback 💬