stor-529: Calling cleanupResources as part of finalizer handlers in applicationbackup controller code
@@ -220,6 +220,12 @@ func (a *ApplicationBackupController) handle(ctx context.Context, backup *stork_
if !canDelete {
return nil
}
+ // Calling cleanupResources which will cleanup the resources created by applicationbackup controller.
+ // In the case of kdmp driver, it will cleanup the dataexport CRs.
+ err = a.cleanupResources(backup)
+ if err != nil {
+ return err
+ }
}
if backup.GetFinalizers() != nil {
@@ -1239,11 +1245,6 @@ func (a *ApplicationBackupController) backupResources(
log.ApplicationBackupLog(backup).Errorf(message)
return err
}
- // Before moving it to success case, cleanup generic backup CR, if any
- err = a.cleanupResources(backup)
- if err != nil {
- return err
- }
backup.Status.BackupPath = GetObjectPath(backup)
backup.Status.Stage = stork_api.ApplicationBackupStageFinal
backup.Status.FinishTimestamp = metav1.Now()
