Merge pull request #6544 from allenxu404/enhance-uninstall

Check if restore crd exist before operating restore
pull/6637/head
Xun Jiang/Bruce Jiang 2023-07-26 11:24:26 +08:00 committed by GitHub
commit 81c916fb12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1 @@
check if restore crd exist before operating restores

View File

@ -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