Skip to content

Commit a6b5c76

Browse files
committed
fix(cleanup): restore the name-based sweep for pre-ADR-020 agent leftovers
An earlier commit on this branch replaced four name-based deletes (job, sa, role, rolebinding named "aicr" in gpu-operator) with a label selector on app.kubernetes.io/name=aicr,app.kubernetes.io/component=snapshot-agent. Pre-branch objects never carried those labels: origin/main's ensureServiceAccount, ensureRole and ensureRoleBinding set no Labels at all, and its Job carried only app.kubernetes.io/name. So the block, still commented "Legacy on-cluster agent leftovers from the older deployment pattern", swept only current-run objects and no legacy one. Both sweeps are now present. They cannot collide: a run-scoped name is always "aicr-<run-id>", never the bare "aicr". The comment describes what the code actually does. The aicr-node-reader ClusterRole/ClusterRoleBinding lines are deliberately untouched — whether to add a name-based delete for the legacy pair is a separate decision. Refs: ADR-020 Signed-off-by: Alex Yuskauskas <ayuskauskas@nvidia.com>
1 parent 9d8665a commit a6b5c76

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

tools/cleanup

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,28 @@ if ! $DRY_RUN; then
347347
| xargs -r kubectl delete --ignore-not-found || true
348348
fi
349349
kc delete ns aicr-validation --ignore-not-found --wait=false
350-
# Legacy on-cluster agent leftovers from the older deployment pattern.
351-
# Run-scoped agent resources (Job/SA/Role/RoleBinding) are named
352-
# "aicr-<run-id>", so a fixed-name delete never matches current runs; select
353-
# by the label every one of them carries instead.
350+
# On-cluster snapshot-agent leftovers, current and legacy. Both sweeps are
351+
# needed and neither subsumes the other:
352+
#
353+
# - Current (ADR-020) runs name their Job/SA/Role/RoleBinding
354+
# "aicr-<run-id>", so no fixed-name delete matches them; they are found by
355+
# the label set every one of them carries.
356+
# - Pre-ADR-020 runs used the fixed name "aicr" and carried none of those
357+
# labels — the Job had only app.kubernetes.io/name, and the SA, Role and
358+
# RoleBinding had no labels at all — so the label selector above misses
359+
# them entirely. The name-based deletes below are the only thing that
360+
# collects them.
361+
#
362+
# The two cannot collide: a run-scoped name is always "aicr-<run-id>", never
363+
# the bare "aicr".
354364
kc -n gpu-operator delete job -l app.kubernetes.io/name=aicr,app.kubernetes.io/component=snapshot-agent --ignore-not-found
355365
kc -n gpu-operator delete sa -l app.kubernetes.io/name=aicr,app.kubernetes.io/component=snapshot-agent --ignore-not-found
356366
kc -n gpu-operator delete role -l app.kubernetes.io/name=aicr,app.kubernetes.io/component=snapshot-agent --ignore-not-found
357367
kc -n gpu-operator delete rolebinding -l app.kubernetes.io/name=aicr,app.kubernetes.io/component=snapshot-agent --ignore-not-found
368+
kc -n gpu-operator delete job aicr --ignore-not-found
369+
kc -n gpu-operator delete sa aicr --ignore-not-found
370+
kc -n gpu-operator delete role aicr --ignore-not-found
371+
kc -n gpu-operator delete rolebinding aicr --ignore-not-found
358372

359373
# Phase 3: Component CRDs.
360374
# Helm does NOT remove CRDs on uninstall — they must be deleted manually or a

0 commit comments

Comments
 (0)