Repository navigation
chore: Scope stale resource cleanup with projectsveltos.io/cluster an… - #2035
Merged
Merged
Conversation
…notation Resources deployed by a ClusterSummary were annotated with `projectsveltos.io/clustersummary: <prefix>-<namespace>-<name>`. Despite the name, the value is built from the **managed cluster** (type prefix, namespace and name), not from the ClusterSummary. Two different clusters can also produce the same value (namespace `a-b` with cluster `c`, and namespace `a` with cluster `b-c`, both give `capi-a-b-c`). This PR adds a new annotation, `projectsveltos.io/cluster`, with the value `<prefix>/<namespace>/<name>` (for example `capi/default/clusterapi-workload`). The separators make the value unambiguous, and the name says what it holds. - **New deployments** only set `projectsveltos.io/cluster`. The legacy `projectsveltos.io/clustersummary` is no longer written. Because resources are applied with server-side apply, a resource that is redeployed loses the old annotation. - **Stale resource cleanup** picks the annotation to compare per resource (`getClusterScopingAnnotation`). A resource with `projectsveltos.io/cluster` is compared with the new value. A resource that only has `projectsveltos.io/clustersummary` (deployed by an older version) is still compared with the legacy value, so resources deployed before the upgrade are still found and removed. - **Upgrade:** nothing to do. Resources keep the old annotation until their ClusterSummary redeploys them, and stale cleanup works for both forms. - **Downgrade, `deploymentType: Remote`:** works. Remote cleanup does not depend on this annotation (it relies on the owner annotations). - **Downgrade, `deploymentType: Local`:** an older addon-controller does not know the new annotation, so Local resources deployed after the upgrade are not found as stale and are left in the management cluster. They are never deleted wrongly. They have to be removed manually.
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.
…notation
Resources deployed by a ClusterSummary were annotated with
projectsveltos.io/clustersummary: <prefix>-<namespace>-<name>. Despite the name, the value is built from the managed cluster (type prefix, namespace and name), not from the ClusterSummary. Two different clusters can also produce the same value (namespacea-bwith clusterc, and namespaceawith clusterb-c, both givecapi-a-b-c).This PR adds a new annotation,
projectsveltos.io/cluster, with the value<prefix>/<namespace>/<name>(for examplecapi/default/clusterapi-workload). The separators make the value unambiguous, and the name says what it holds.New deployments only set
projectsveltos.io/cluster. The legacyprojectsveltos.io/clustersummaryis no longer written. Because resources are applied with server-side apply, a resource that is redeployed loses the old annotation.Stale resource cleanup picks the annotation to compare per resource (
getClusterScopingAnnotation). A resource withprojectsveltos.io/clusteris compared with the new value. A resource that only hasprojectsveltos.io/clustersummary(deployed by an older version) is still compared with the legacy value, so resources deployed before the upgrade are still found and removed.Upgrade: nothing to do. Resources keep the old annotation until their ClusterSummary redeploys them, and stale cleanup works for both forms.
Downgrade,
deploymentType: Remote: works. Remote cleanup does not depend on this annotation (it relies on the owner annotations).Downgrade,
deploymentType: Local: an older addon-controller does not know the new annotation, so Local resources deployed after the upgrade are not found as stale and are left in the management cluster. They are never deleted wrongly. They have to be removed manually.