Skip to content

[module-sdk] feat: delete workloads by name or selector - #131

Merged
ldmonster merged 1 commit into
mainfrom
feat/storage-class-label-selector
Aug 18, 2026
Merged

[module-sdk] feat: delete workloads by name or selector#131
ldmonster merged 1 commit into
mainfrom
feat/storage-class-label-selector

Conversation

@fuldaxxx

@fuldaxxx fuldaxxx commented Aug 17, 2026

Copy link
Copy Markdown
Member

Description

common-hooks/storage-class-change can now find the workloads to delete by label
selector instead of a single hardcoded name.

Args.ObjectName Behaviour
set Exactly that object is deleted. A delete error other than NotFound is logged and the hook still succeeds — unchanged, long-standing behaviour.
empty Every object of Args.ObjectKind in Args.Namespace labelled Args.LabelSelectorKey=Args.LabelSelectorValue is deleted. A delete error other than NotFound fails the hook; an empty match is only warned about.

No new fields in Args: the selector already used for the pvcs/pods snapshots is
reused. ObjectName always wins over the selector, so every module that configures
both (all of them today) keeps the current behaviour and the new branch is
unreachable for them — the change is backward compatible by construction.

Deletion is now issued through the dynamic client for all supported kinds, so
switch over ObjectKind that built typed objects is gone. For StatefulSet and
Deployment this is the same REST request as before; as a side effect the wh
deletion path became reachable from the test framework, whose fake cluster is the
dynamic one.

Tests: four new framework tests covering deletion by selector (including that
non-matching objects survive), deletion by name, an empty match, and a failing
delete. All four fail on the previous implementation.

Why do we need it, and what problem does it solve?

The hook deleted the workload strictly by ObjectName. A module that owns several
workloads in one namespace — for example StatefulSets with generated names —
only one of them deleted. The survivors kept their old volumeClaimTemplates, and
the following Helm release failed:

StatefulSet.apps "..." is invalid: spec: Forbidden: updates to statefulset spec for
fields other than 'replicas', 'ordinals', 'template', 'updateStrategy',
'revisionHistoryLimit', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds'
are forbidden

which leaves the module release stuck in a retry loop and the storage class change
half-applied: some workloads on the new class, the rest on the old one.

Verified on a live cluster with a test module that deploys two StatefulSets i
namespace, switching the default storage class between two classes:

  • with ObjectName set — one object deleted, the second one stayed on the old
    storage class, Helm failed with the error above;
  • with ObjectName empty — both objects deleted in one hook run, both recreated
    with the new storage class, no Helm errors.

Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
@fuldaxxx
fuldaxxx requested a review from ldmonster August 17, 2026 16:01
@fuldaxxx fuldaxxx self-assigned this Aug 17, 2026
@fuldaxxx fuldaxxx added enhancement New feature or request go Pull requests that update go code labels Aug 17, 2026
@fuldaxxx
fuldaxxx requested a review from ipaqsa August 18, 2026 09:32
@fuldaxxx fuldaxxx changed the title feat: delete workloads by name or selector [module-sdk] feat: delete workloads by name or selector Aug 18, 2026
@fuldaxxx
fuldaxxx marked this pull request as ready for review August 18, 2026 09:33
@ldmonster
ldmonster merged commit 9a6f311 into main Aug 18, 2026
57 of 58 checks passed
@ldmonster
ldmonster deleted the feat/storage-class-label-selector branch August 18, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants