Repository navigation
feat(components): declare the bridge cluster identity and epoch to CMS - #1273
Merged
VLukiantsev merged 4 commits intoOct 16, 2026
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces cluster identity and fencing mechanisms to the xmc-bridge controller by adding configuration options for cluster name and ownership epoch, reading the kube-system namespace UID, and implementing a ClusterFence runnable to periodically declare the cluster's epoch to CMS. It also updates Helm templates, RBAC permissions, and tests. The feedback recommends adding a defensive nil check on the retrieved namespace object in ReadClusterUID to prevent potential nil pointer dereferences.
This was referenced Oct 14, 2026
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 14, 2026 13:54
eeba6f8 to
a526ddd
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
3 times, most recently
from
October 15, 2026 08:07
1d76621 to
9ed5476
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
2 times, most recently
from
October 15, 2026 09:29
401b6fe to
3053d60
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 15, 2026 09:49
3053d60 to
a4b902a
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 15, 2026 10:02
a4b902a to
700df49
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
2 times, most recently
from
October 15, 2026 11:16
0888cf6 to
4da4e70
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
2 times, most recently
from
October 15, 2026 12:43
2059d84 to
6104642
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 15, 2026 12:50
6104642 to
65ea951
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 15, 2026 13:11
65ea951 to
0627aa1
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 16, 2026 08:53
1037d72 to
a5ebe27
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
3 times, most recently
from
October 16, 2026 11:27
3468e16 to
63db6c3
Compare
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
2 times, most recently
from
October 16, 2026 12:18
957b5de to
60db89b
Compare
VLukiantsev
commented
Oct 16, 2026
VLukiantsev
commented
Oct 16, 2026
VLukiantsev
commented
Oct 16, 2026
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
2 times, most recently
from
October 16, 2026 13:26
e5a9830 to
94b7016
Compare
VLukiantsev
marked this pull request as ready for review
October 16, 2026 13:59
janzak-dev
previously approved these changes
Oct 16, 2026
The CMS ownership fence (DeclareClusterEpoch) has no caller yet. This layer makes xmc-bridge declare its cluster so that CMS knows which cluster is active and a DR takeover can reassign owners: - RunBridge reads the kube-system Namespace UID (ReadClusterUID) as a stable cluster UID and builds a ClusterIdentity from it, the new --cluster-name / CLUSTER_NAME flag (a DNS-1123 label, defaulting to --release-name) and --ownership-epoch / COMPONENT_OWNERSHIP_EPOCH (>= 1, default 1). - A leader-elected ClusterFence runnable calls DeclareClusterEpoch immediately and every heartbeat interval, each call bounded by a 10s timeout, and retries after 5s when CMS is unreachable or rejects the declaration. Only the Lease holder declares. - Helm: componentsDeployment.clusterName / ownershipEpoch values feed the ConfigMap, and a namespace-suffixed ClusterRole/Binding grants get on the kube-system Namespace only. - The xmc-bridge README documents both flags. The bridge does not act on the fence yet: its intents are still unsourced, so a fenced bridge only logs a warning and keeps retrying. Holding a fenced bridge in cold standby is the next layer. Tests: ReadClusterUID, NewClusterFence validation, a Start heartbeat against an in-process CMS that fences out a second cluster at the same epoch, Declare request/err wrapping, the bounded hung declaration, the new flags and env vars, and the RBAC template. Bug: 548436300 TAG=agy CONV=b2ebecbe-c04a-4fb7-a16c-d23de82ed3e5
Address review comment on #1273 by checking that the returned Namespace object is non-nil before accessing its UID. Comment link: #1273 (comment) Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
…idation table-driven Fold the three ReadClusterUID error blocks and the success block into one named table, and turn the unnamed invalid-identity loop plus the nil CMS check into named rows, each run as a subtest. Inputs and assertions are unchanged. Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
… an integer - ClusterFence retries a FailedPrecondition declaration (fenced or regressed epoch) at the heartbeat interval and logs it as an error; transient failures keep the fast retry. - The chart renders COMPONENT_OWNERSHIP_EPOCH with int64, so large epochs are not rendered in float notation, and passes an explicit 0 through for xmc-bridge to reject instead of defaulting it to 1. - Replace the map-based duration check with an explicit, ordered validateTimings helper that keeps ParseConfig within the gocyclo limit. Comment links: #1273 (comment) #1273 (comment) #1273 (comment) Bug: 548436300 TAG=agy CONV=d833b0e6-4821-48f6-8576-776d53f55a5c
VLukiantsev
force-pushed
the
feat/components-bridge-cluster-declaration-b548436300
branch
from
October 16, 2026 15:16
b21d7cf to
1c17668
Compare
There was a problem hiding this comment.
🤖 Incremental PR Approval
Clean rebase detected with zero semantic patch lines changed.
Preserving prior approval by @janzak-dev on commit b21d7cf.
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
xmc-bridge reads the
kube-systemNamespace UID as its cluster identity and, from a leader-elected runnable, declares(clusterUID, --cluster-name, --ownership-epoch)to CMS viaDeclareClusterEpochat startup and on every heartbeat. The bridge does not act on the answer yet; cold standby is the next layer (#1236).Motivation & Context
With the CMS fence in place (#1234/#1235), CMS needs to know which cluster is the active writer before the bridge sends sourced requests, and a DR takeover needs a declared, higher epoch. Split out of #1236 to keep that layer within the size limits: this slice is the declaration end to end (flags, Helm, RBAC, runnable), observable in CMS as the fence row.
Key Changes
ReadClusterUID: GET of thekube-systemNamespace at startup; startup fails without it and there is no override. NewClusterRole/xmc-bridge-cluster-identity-<release-namespace>(namespace-suffixed so multiple installs in one cluster do not collide) grants onlygetonnamespaceswithresourceNames: [kube-system].--cluster-name/CLUSTER_NAME(DNS-1123 label, defaults to--release-name) and--ownership-epoch/COMPONENT_OWNERSHIP_EPOCH(>= 1, default 1); Helm valuescomponentsDeployment.clusterNameandcomponentsDeployment.ownershipEpoch(rendered withint64, so large epochs are not rendered in float notation; an explicit0is passed through for the binary to reject); README rows for both flags (moved here from feat(components): add CMS ownership metrics and DR takeover documentation #1243 so the docs ship with the flags). The existing duration checks move intovalidateTimings, which keepsParseConfigwithin thegocyclolimit of 15 now that it also validates the cluster identity.ClusterFence: leader-elected runnable (mgr.Add(fence)) that declares immediately and everydefaultCMSHeartbeatInterval(5 min) and bounds each declaration with a 10sDeclareTimeout. A fenced or regressed declaration (FailedPrecondition) is logged as an error and retried at the heartbeat interval; other failures are retried after 5s. In this layerDeclareis stateless.CMSClientgainsDeclareClusterEpoch.TestReadClusterUID,TestNewClusterFence_Validation,TestClusterFence_StartDeclaresToCMS(a started fence declares to an in-process CMS so a second cluster at the same epoch is fenced out),TestClusterFence_DeclareSendsIdentity,TestClusterFence_StartBoundsHungDeclare,TestClusterFence_RetryDelay, flag/env cases inmain_test.go, the RBAC template test, andtest/helm/bridge_cluster_identity_test.py.Stack Position
Assumptions
kube-systemNamespace UID is the only cluster authority — Velero, Git and Helm never copy it, so a restore or rebuild always gets a new identity — impact if wrong: two clusters could share an identity.--cluster-nameREADME default reads "value of--release-name", matching the code; the earlier text in feat(components): add CMS ownership metrics and DR takeover documentation #1243 said"xmc", which only holds for that release name.Verification & Testing
bazel test //cmd/xmc_bridge/... //pkg/components/bridge/...plus the pre-commit affected-test set (cms, store with the Spanner emulator, actuator, kind harness unit test),golangci-lint run(v1.64.6),gofmt -l.//test/e2e:components_lifecycle_test.tools/analyze_diff_size.py): 293 prod / 382 test / 675 total / 2 doc lines.Live Deployment & Manual Testing
enable_components: true, Spanner-backed CMS), upgraded with the dev-environment upgrade script including Spanner migrations014/015.kube-systemUID discovery and leader-electedDeclareClusterEpochkube-systemNamespace UID viaClusterRole/xmc-bridge-cluster-identity, declared epoch 1 into the fence row (FenceId=1), and refreshedLastSeenTimeevery 5 minutes.Related Issues / Bugs
Bug: 548436300
TAG=agy
CONV=d833b0e6-4821-48f6-8576-776d53f55a5c