Repository navigation
Fix ClusterConfiguration cache race when ClusterProfile starts matching many clusters - #2007
Merged
gianlucam76 merged 1 commit intoSep 29, 2026
Conversation
…ng many clusters When a ClusterProfile/Profile starts matching a large number of clusters (e.g. going from 0 to ~60), updateClusterConfigurations creates a ClusterConfiguration for each newly matching cluster and then immediately re-fetches it by Get to add the owner reference and status entry. That Get goes through the manager's cached client, and the informer cache doesn't always reflect the object Create just returned, so it can come back NotFound right after creation. Because the per-cluster loop returns on the first error, one stale-cache miss aborts the whole reconcile. With a fixed 10s requeue and no backoff, working through dozens of clusters this way can take minutes, even though nothing is actually wrong. This changes createClusterConfiguration to return the object it just created (or fetched, if it already existed) instead of just an error, and threads that object through updateClusterConfigurationWithProfile, updateClusterConfigurationOwnerReferences, and updateClusterConfigurationProfileResources. Each of those only falls back to a fresh Get on a real retry after a Conflict, not on the first attempt so the known-good object from Create is used directly instead of racing the cache.
gianlucam76
force-pushed
the
missing-clusterconfiguration-error
branch
from
September 29, 2026 09:57
66fae4e to
680d00f
Compare
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.
When a ClusterProfile/Profile starts matching a large number of clusters (e.g. going from 0 to ~60), updateClusterConfigurations creates a ClusterConfiguration for each newly matching cluster and then immediately re-fetches it by Get to add the owner reference and status entry. That Get goes through the manager's cached client, and the informer cache doesn't always reflect the object Create just returned, so it can come back NotFound right after creation.
Because the per-cluster loop returns on the first error, one stale-cache miss aborts the whole reconcile. With a fixed 10s requeue and no backoff, working through dozens of clusters this way can take minutes, even though nothing is actually wrong.
This changes createClusterConfiguration to return the object it just created (or fetched, if it already existed) instead of just an error, and threads that object through updateClusterConfigurationWithProfile, updateClusterConfigurationOwnerReferences, and updateClusterConfigurationProfileResources. Each of those only falls back to a fresh Get on a real retry after a Conflict, not on the first attempt so the known-good object from Create is used directly instead of racing the cache.