Skip to content

Fix ClusterConfiguration cache race when ClusterProfile starts matching many clusters - #2007

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:missing-clusterconfiguration-error
Sep 29, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:missing-clusterconfiguration-error

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

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.

…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
gianlucam76 force-pushed the missing-clusterconfiguration-error branch from 66fae4e to 680d00f Compare September 29, 2026 09:57
@gianlucam76
gianlucam76 merged commit 2ecf51d into projectsveltos:main Sep 29, 2026
21 of 22 checks passed
@gianlucam76
gianlucam76 deleted the missing-clusterconfiguration-error branch September 29, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant