Skip to content

Clean up orphaned sveltos-agent version ConfigMaps - #502

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
nscaledev:mkjpryor/cleanup-sveltosagent-configmap
Aug 30, 2026
Merged

Clean up orphaned sveltos-agent version ConfigMaps#502
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
nscaledev:mkjpryor/cleanup-sveltosagent-configmap

Conversation

@mkjpryor

Copy link
Copy Markdown
Contributor

Fixes the sveltos-agent side of gianlucam76's approach from libsveltos#670 (owner-reference PR closed in favour of this) - companion PRs: projectsveltos/libsveltos#671 and a matching one against addon-controller for the drift-detection side.

removeSveltosAgentFromManagementCluster deletes every resource in the sveltos-agent manifest for a cluster once it's gone, but the sa-* version ConfigMap isn't part of that manifest - it's written by the agent itself at runtime - so it was never cleaned up. These accumulate without bound: one NKS cell had ~2000 of them from nothing but a canary probe's create/delete cycle (ORC-294).

This adds the ConfigMap delete after every manifest resource (deployment included), using the new DeleteSveltosAgentVersion from libsveltos, and propagates its error instead of swallowing it like the rest of the function does - cleanClusterStaleResources already turns a failure here into a requeue, so this gets picked up again by both the reconciler and the periodic sweep rather than being dropped.

Needs a libsveltos version pinned that includes DeleteSveltosAgentVersion; will update the pin once that's tagged rather than the commit pseudo-version this currently uses.

removeSveltosAgentFromManagementCluster tears down every resource in
the sveltos-agent manifest for a cluster that's gone, but never touched
the sa-* version ConfigMap since that gets written by the running agent
itself, not deployed as part of the manifest. Left unowned and never
cleaned up, these accumulate without bound - one NKS cell had ~2000 of
them from nothing but a canary probe's create/delete cycle.

Delete it last, after every manifest resource (including the deployment)
already has a delete issued, and propagate the error instead of
swallowing it like the rest of that function does: cleanClusterStaleResources
turns a failure here into a requeue, so this gets retried through both
the reconciler and the periodic sweep instead of just giving up.

@gianlucam76 gianlucam76 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gianlucam76
gianlucam76 merged commit 94739b2 into projectsveltos:main Aug 30, 2026
9 checks passed
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.

2 participants