Skip to content

Commit

Permalink
Merge pull request #6544 from allenxu404/enhance-uninstall
Browse files Browse the repository at this point in the history
Check if restore crd exist before operating restore
  • Loading branch information
blackpiglet authored Jul 26, 2023
2 parents 9c8275e + 6dbdc54 commit 81c916f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/6544-allenxu404
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
check if restore crd exist before operating restores
13 changes: 12 additions & 1 deletion pkg/cmd/cli/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,18 @@ func deleteNamespace(ctx context.Context, kbClient kbclient.Client, namespace st
}

func deleteResourcesWithFinalizer(ctx context.Context, kbClient kbclient.Client, namespace string) error {
// delete restores
//check if restore crd exists
v1crd := &apiextv1.CustomResourceDefinition{}
key := kbclient.ObjectKey{Name: "restores.velero.io"}
if err := kbClient.Get(ctx, key, v1crd); err != nil {
if apierrors.IsNotFound(err) {
return nil
} else {
return err
}
}

// delete all the restores
restoreList := &velerov1api.RestoreList{}
if err := kbClient.List(ctx, restoreList, &kbclient.ListOptions{Namespace: namespace}); err != nil {
return err
Expand Down

0 comments on commit 81c916f

Please sign in to comment.