From b5bd55fc56788960dbebd5df4e0cc39d86014a3c Mon Sep 17 00:00:00 2001 From: lyndon <98304688+Lyndon-Li@users.noreply.github.com> Date: Sat, 15 Jul 2023 02:05:51 +0800 Subject: [PATCH] fix issue 6490 (#6491) Signed-off-by: Lyndon-Li --- changelogs/unreleased/6491-Lyndon-Li | 1 + pkg/controller/backup_operations_controller.go | 7 ++++--- pkg/controller/restore_operations_controller.go | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/6491-Lyndon-Li diff --git a/changelogs/unreleased/6491-Lyndon-Li b/changelogs/unreleased/6491-Lyndon-Li new file mode 100644 index 000000000..afadb6bf0 --- /dev/null +++ b/changelogs/unreleased/6491-Lyndon-Li @@ -0,0 +1 @@ +Fix issue 6490, If a backup/restore has multiple async operations and one operation fails while others are still in-progress, when all the operations finish, the backup/restore will be set as Completed falsely \ No newline at end of file diff --git a/pkg/controller/backup_operations_controller.go b/pkg/controller/backup_operations_controller.go index d6d491c5f..f00e9c205 100644 --- a/pkg/controller/backup_operations_controller.go +++ b/pkg/controller/backup_operations_controller.go @@ -185,14 +185,15 @@ func (c *backupOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Req operations.ChangesSinceUpdate = true } + if len(operations.ErrsSinceUpdate) > 0 { + backup.Status.Phase = velerov1api.BackupPhaseWaitingForPluginOperationsPartiallyFailed + } + // if stillInProgress is false, backup moves to finalize phase and needs update // if operations.ErrsSinceUpdate is not empty, then backup phase needs to change to // BackupPhaseWaitingForPluginOperationsPartiallyFailed and needs update // If the only changes are incremental progress, then no write is necessary, progress can remain in memory if !stillInProgress { - if len(operations.ErrsSinceUpdate) > 0 { - backup.Status.Phase = velerov1api.BackupPhaseWaitingForPluginOperationsPartiallyFailed - } if backup.Status.Phase == velerov1api.BackupPhaseWaitingForPluginOperations { log.Infof("Marking backup %s Finalizing", backup.Name) backup.Status.Phase = velerov1api.BackupPhaseFinalizing diff --git a/pkg/controller/restore_operations_controller.go b/pkg/controller/restore_operations_controller.go index 100fef214..869c5acb1 100644 --- a/pkg/controller/restore_operations_controller.go +++ b/pkg/controller/restore_operations_controller.go @@ -177,14 +177,15 @@ func (r *restoreOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Re operations.ChangesSinceUpdate = true } + if len(operations.ErrsSinceUpdate) > 0 { + restore.Status.Phase = velerov1api.RestorePhaseWaitingForPluginOperationsPartiallyFailed + } + // if stillInProgress is false, restore moves to terminal phase and needs update // if operations.ErrsSinceUpdate is not empty, then restore phase needs to change to // RestorePhaseWaitingForPluginOperationsPartiallyFailed and needs update // If the only changes are incremental progress, then no write is necessary, progress can remain in memory if !stillInProgress { - if len(operations.ErrsSinceUpdate) > 0 { - restore.Status.Phase = velerov1api.RestorePhaseWaitingForPluginOperationsPartiallyFailed - } if restore.Status.Phase == velerov1api.RestorePhaseWaitingForPluginOperations { log.Infof("Marking restore %s completed", restore.Name) restore.Status.Phase = velerov1api.RestorePhaseCompleted