Skip to content

chore: Scope stale resource cleanup with projectsveltos.io/cluster an… - #2035

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:deps
Oct 13, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:deps

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

…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.

…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.
@gianlucam76
gianlucam76 merged commit 984091a into projectsveltos:main Oct 13, 2026
21 of 22 checks passed
@gianlucam76
gianlucam76 deleted the deps branch October 13, 2026 10:55
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