From a6fc11ce2eb20c379a6c8cdfc8c2f086cad668ad Mon Sep 17 00:00:00 2001 From: "L.Dongming" Date: Thu, 11 Jan 2024 19:16:55 +0800 Subject: [PATCH] chore: delete all resources include keeped when uninstall (#233) (cherry picked from commit 0ac09726e2d69fa8dc8ff1764e8512ec41ed246a) --- pkg/cmd/kubeblocks/kubeblocks_objects.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/pkg/cmd/kubeblocks/kubeblocks_objects.go b/pkg/cmd/kubeblocks/kubeblocks_objects.go index 4f1c28621..64885d950 100644 --- a/pkg/cmd/kubeblocks/kubeblocks_objects.go +++ b/pkg/cmd/kubeblocks/kubeblocks_objects.go @@ -209,33 +209,11 @@ func removeCustomResources(dynamic dynamic.Interface, objs kbObjects) error { } func deleteObjects(dynamic dynamic.Interface, gvr schema.GroupVersionResource, objects *unstructured.UnstructuredList) error { - const ( - helmResourcePolicyKey = "helm.sh/resource-policy" - helmResourcePolicyKeep = "keep" - ) - if objects == nil { return nil } - // if resource has annotation "helm.sh/resource-policy": "keep", skip it - // TODO: maybe a flag to control this behavior - keepResource := func(obj unstructured.Unstructured) bool { - annotations := obj.GetAnnotations() - if len(annotations) == 0 { - return false - } - if annotations[helmResourcePolicyKey] == helmResourcePolicyKeep { - return true - } - return false - } - for _, s := range objects.Items { - if keepResource(s) { - continue - } - // the object is not being deleted, delete it if s.GetDeletionTimestamp().IsZero() { klog.V(1).Infof("delete %s %s", gvr.String(), s.GetName())