fix: skip source namespace in replicate-to-matching#422
Merged
elenz97 merged 1 commit intoJul 7, 2026
Conversation
Mirrors the existing self-skip in the replicate-to path so a selector that matches the source's own namespace no longer loops. Adds regression tests for both strategies.
Contributor
Author
|
@elenz97, any chance you can look at this fix? |
elenz97
approved these changes
Jul 7, 2026
elenz97
left a comment
Contributor
There was a problem hiding this comment.
Looking good, thank you for looking into this @mcastellini!
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
When a
replicate-to-matchinglabel selector also matches the source object's own namespace, the replicator copies the resource onto itself. That write updates the source object, which re-triggers the informer and produces an unbounded reconciliation loop — continuous writes that hammer the kube-apiserver. (In our case the looping objects were TLS secrets watched by an ingress controller, which rebuilt and revalidated its entire data plane on every write and pinned its CPU.)The
replicate-to(namespace pattern) strategy already guards against this ingetNamespacesToReplicate:…but the
replicate-to-matching(label selector) strategy lists namespaces straight from the API and passes them through unfiltered, so the source's own namespace can end up as a target.Fix
Apply the same self-skip in
replicateResourceToMatchingNamespacesByLabel: filter the source namespace out of the selector-matched list before replicating.Tests
Adds two regression tests in
replicate/secret:replicate-to-matching self-match— fails without this change, passes with it.replicate-to pattern self-match— exercises the pre-existing guard, which had no coverage.Both verified against a kind cluster; the full
replicate/secretsuite passes.Fixes #407