Skip to content

Commit

Permalink
chore: delete all resources include keeped when uninstall (#233)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0ac0972)
  • Loading branch information
ldming committed Jan 11, 2024
1 parent 178e40a commit a6fc11c
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions pkg/cmd/kubeblocks/kubeblocks_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit a6fc11c

Please sign in to comment.