Repository navigation
EV-6919: Fix multi owner write issues - #5124
Merged
alexh-tigera merged 2 commits intoJul 29, 2026
Merged
Conversation
The component handler stamps app.kubernetes.io/instance and /component from the CR it is writing for. An object carrying MultipleOwnersLabel is written by more than one controller, each passing its own CR — the waypoint controller's Istio CR and the gatewayapi controller's per-Gateway passes stamp different values onto the same RoleBinding, pull-secret copy, and trust-bundle ConfigMap, so every reconcile rewrites the object with whichever identity wrote last. Measured on a live cluster: a namespace holding a waypoint and two of our Gateways rewrote all three shared objects on every periodic tick, cycling instance between the two Gateway names and the Istio CR's name. Stop stamping the two per-owner labels on multi-owner objects. The writer-independent labels (name, k8s-app, part-of, managed-by) are still applied, and a value an earlier writer already stamped is left in place: the label merge keeps labels it did not set, so existing values freeze instead of flipping. Owner-reference ordering still makes these writes non-convergent; that is addressed separately. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit 6ff005a4bbf17c0949b08fccb9a62a9626fc0158)
MergeOwnerReferences put desired first, so each controller writing a shared object (MultipleOwnersLabel) put its own owner reference first: waypoint wrote [Istio, Gateway], gatewayapi wrote [Gateway, Istio], and two EgressGateways in one namespace flipped between [A, B] and [B, A]. Every alternating reconcile was a genuine content change, so the writers rewrote the object in turn for as long as both kept reconciling. Measured on a live cluster: a shared RoleBinding and pull-secret copy rewritten within a second of every reconcile trigger, indefinitely. Sort the merged references by UID so every writer converges on identical bytes and the second write becomes a no-op. A UID identifies an owner, so desired's version of a reference wins over current's and a re-rendered reference with corrected fields still lands. Order carries no meaning to Kubernetes: owner references are a set, and the controller reference is identified by its Controller field rather than its position. Also fixed while here: - dedup key changed from the whole OwnerReference struct to UID. The struct contains *bool Controller/BlockOwnerDeletion, so the old map key compared pointers and kept two references for one owner if one writer set Controller and another did not. - slices.Concat instead of append(desired, ...), which could mutate the caller's slice. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes reconcile-loop churn for operator-managed objects that are intentionally shared by multiple owners (marked with operator.tigera.io/multipleOwners). It ensures both owner reference merging and label stamping converge to stable object bytes, avoiding alternating rewrites by different controllers.
Changes:
- Make
common.MergeOwnerReferencesdeduplicate by owner UID and return owner references in a stable (UID-sorted) order to prevent reorder-based write loops. - Prevent stamping per-owner identity labels (
app.kubernetes.io/instanceandapp.kubernetes.io/component) onto multi-owner objects so different controllers don’t flip these values back and forth. - Add focused unit tests covering convergence, dedup semantics, non-mutation, and the multi-owner label behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/controller/utils/component.go | Passes multi-owner context into standard labeling so per-owner identity labels are skipped for shared objects. |
| pkg/controller/utils/component_test.go | Adds a test asserting multi-owner shared objects don’t get per-owner identity labels and don’t persist the directive label. |
| pkg/common/components.go | Updates owner-reference merging to dedupe by UID, avoid slice mutation, and sort deterministically. |
| pkg/common/components_test.go | Adds unit tests verifying deterministic/convergent merge behavior and UID-based deduplication. |
tmjd
approved these changes
Jul 29, 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.
Description
Objects shared by multiple owners (
operator.tigera.io/multipleOwnerslabel —pull-secret copies, the
tigera-operator-secretsRoleBinding, and the gateway trust-bundleConfigMap) were rewritten on every alternating reconcile by their owning controllers,
indefinitely. Two independent per-writer fields caused this:
common.MergeOwnerReferencesput the writer's own owner reference first, so each controllerreordered the references written by the previous one. Fixed by sorting the merged references
by UID so every writer converges on identical bytes; the dedup key also moves from the whole
struct (which compared
*boolpointers by identity) to the UID, andslices.Concatreplacesan
appendthat could mutate the caller's slice.app.kubernetes.io/instanceand/componentfrom the writingCR, so shared objects flipped identity labels between owners. Fixed by skipping those two
per-owner labels on multi-owner objects; writer-independent labels still apply, and values an
earlier writer stamped are left in place.
Release Note
For PR author
make gen-files(not applicable)make gen-versions(not applicable)For PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bugif this is a bugfix.kind/enhancementif this is a a new feature.enterpriseif this PR applies to Calico Enterprise only.