Skip to content

Commit

Permalink
cleanup pvcs
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin committed Dec 12, 2024
1 parent 8e8d073 commit 3bbba25
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/testworkflows/executionworker/controller/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ func cleanupJobs(labelName string) func(ctx context.Context, clientSet kubernete
}
}

func cleanupPvcs(labelName string) func(ctx context.Context, clientSet kubernetes.Interface, namespace, id string) error {
return func(ctx context.Context, clientSet kubernetes.Interface, namespace, id string) error {
return clientSet.CoreV1().PersistentVolumeClaims(namespace).DeleteCollection(ctx, metav1.DeleteOptions{
GracePeriodSeconds: common.Ptr(int64(0)),
PropagationPolicy: common.Ptr(metav1.DeletePropagationBackground),
}, metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", labelName, id),
})
}
}

func Cleanup(ctx context.Context, clientSet kubernetes.Interface, namespace, id string) error {
var errs []error
var errsMu sync.Mutex
Expand All @@ -70,6 +81,8 @@ func Cleanup(ctx context.Context, clientSet kubernetes.Interface, namespace, id
cleanupConfigMaps(constants.ResourceIdLabelName),
cleanupSecrets(constants.RootResourceIdLabelName),
cleanupSecrets(constants.ResourceIdLabelName),
cleanupPvcs(constants.RootResourceIdLabelName),
cleanupPvcs(constants.ResourceIdLabelName),
}
wg.Add(len(ops))
for _, op := range ops {
Expand All @@ -96,6 +109,7 @@ func CleanupGroup(ctx context.Context, clientSet kubernetes.Interface, namespace
cleanupPods(constants.GroupIdLabelName),
cleanupConfigMaps(constants.GroupIdLabelName),
cleanupSecrets(constants.GroupIdLabelName),
cleanupPvcs(constants.GroupIdLabelName),
}
wg.Add(len(ops))
for _, op := range ops {
Expand Down
28 changes: 28 additions & 0 deletions pkg/testworkflows/testworkflowprocessor/mock_intermediate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3bbba25

Please sign in to comment.