[module-sdk] feat: delete workloads by name or selector - #131
Merged
Conversation
Signed-off-by: Ruslan Gorbunov <ruslan.gorbunov@flant.com>
fuldaxxx
marked this pull request as ready for review
August 18, 2026 09:33
ipaqsa
approved these changes
Aug 18, 2026
ldmonster
approved these changes
Aug 18, 2026
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.
Description
common-hooks/storage-class-changecan now find the workloads to delete by labelselector instead of a single hardcoded name.
Args.ObjectNameNotFoundis logged and the hook still succeeds — unchanged, long-standing behaviour.Args.ObjectKindinArgs.NamespacelabelledArgs.LabelSelectorKey=Args.LabelSelectorValueis deleted. A delete error other thanNotFoundfails the hook; an empty match is only warned about.No new fields in
Args: the selector already used for thepvcs/podssnapshots isreused.
ObjectNamealways wins over the selector, so every module that configuresboth (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
switchoverObjectKindthat built typed objects is gone. ForStatefulSetandDeploymentthis is the same REST request as before; as a side effect the whdeletion 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 severalworkloads in one namespace — for example StatefulSets with generated names —
only one of them deleted. The survivors kept their old
volumeClaimTemplates, andthe following Helm release failed:
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:
ObjectNameset — one object deleted, the second one stayed on the oldstorage class, Helm failed with the error above;
ObjectNameempty — both objects deleted in one hook run, both recreatedwith the new storage class, no Helm errors.