From 54fdf4b3397aab1887668fa6bcbbe3d6e0681b18 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 8 Nov 2023 17:58:20 +0800 Subject: [PATCH] fix(backup): skip StopBackup task when deleting backuppolicy --- pkg/resource/obtenantbackuppolicy_manager.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/resource/obtenantbackuppolicy_manager.go b/pkg/resource/obtenantbackuppolicy_manager.go index 4594b85cf..3fb96655f 100644 --- a/pkg/resource/obtenantbackuppolicy_manager.go +++ b/pkg/resource/obtenantbackuppolicy_manager.go @@ -78,17 +78,19 @@ func (m *ObTenantBackupPolicyManager) CheckAndUpdateFinalizers() error { } if !finalizerFinished { - tenant, err := m.getOBTenantCR() - if err != nil { - // the tenant is deleted, no need to wait finalizer - if kubeerrors.IsNotFound(err) { + if m.BackupPolicy.Spec.TenantCRName != "" { + tenant, err := m.getOBTenantCR() + if err != nil { + // the tenant is deleted, no need to wait finalizer + if kubeerrors.IsNotFound(err) { + finalizerFinished = true + } else { + return errors.Wrap(err, "Get obtenant failed") + } + } else if !tenant.GetDeletionTimestamp().IsZero() { + // the tenant is being deleted finalizerFinished = true - } else { - return errors.Wrap(err, "Get obtenant failed") } - } else if !tenant.GetDeletionTimestamp().IsZero() { - // the tenant is being deleted - finalizerFinished = true } else { err := m.StopBackup() // the policy is being deleted, connection still exists, stop backup