(feat) Guarantee helm chart handoff when cluster switches between profiles#1780
Merged
Conversation
2f2db99 to
e6d0949
Compare
…sterProfiles When a cluster atomically switches from ClusterProfile A to ClusterProfile B (both wanting the same Helm chart, e.g. Kyverno), a race condition could cause a delete+reinstall instead of an in-place upgrade: 1. ClusterProfile A detects the cluster is no longer a match and starts undeploying 2. ClusterProfile B has not yet run its reconciler and registered its charts with the chart manager 3. canUninstallHelmChart sees no other registrant → proceeds with uninstall 4. B eventually installs → unnecessary downtime Before allowing a Helm chart uninstall, verify that every other ClusterProfile/Profile currently matching the cluster has had its ClusterSummary fully processed by the chart manager. "Fully processed" means GetRegisteredChartsCount == len(spec.HelmCharts), which proves B's reconciler has run and registered all its charts. If not all profiles are processed yet, a new WaitForProfileProcessingError sentinel is returned, which causes the controller to requeue with a short delay (10s) rather than logging an error. Once B has registered, the existing len(otherRegistered) > 1 check becomes authoritative and the handoff proceeds as an upgrade.
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 cluster atomically switches from ClusterProfile A to ClusterProfile B (both wanting the same Helm chart, e.g. Kyverno), a race condition could cause a delete+reinstall instead of an in-place upgrade:
Before allowing a Helm chart uninstall, verify that every other ClusterProfile/Profile currently matching the cluster has had its ClusterSummary fully processed by the chart manager. "Fully processed" means GetRegisteredChartsCount == len(spec.HelmCharts), which proves B's reconciler has run and registered all its charts.
If not all profiles are processed yet, a new WaitForProfileProcessingError sentinel is returned, which causes the controller to requeue with a short delay (10s) rather than logging an error. Once B has registered, the existing len(otherRegistered) > 1 check becomes authoritative and the handoff proceeds as an upgrade.
Fixes #1779