From 8396163e77c5d4285c0e93fab2063d6a48e8b9e5 Mon Sep 17 00:00:00 2001 From: Efim Smykov <33357780+Nutrymaco@users.noreply.github.com> Date: Sat, 22 Jul 2023 00:22:01 +0300 Subject: [PATCH] add missing CompletionTimestamp and metrics when restore moved into terminal phase (#6397) Signed-off-by: Nutrymaco --- changelogs/unreleased/6397-Nutrymaco | 1 + pkg/controller/restore_operations_controller.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/6397-Nutrymaco diff --git a/changelogs/unreleased/6397-Nutrymaco b/changelogs/unreleased/6397-Nutrymaco new file mode 100644 index 0000000000..318884c736 --- /dev/null +++ b/changelogs/unreleased/6397-Nutrymaco @@ -0,0 +1 @@ +Add missing CompletionTimestamp and metrics when restore moved into terminal phase in restoreOperationsReconciler \ No newline at end of file diff --git a/pkg/controller/restore_operations_controller.go b/pkg/controller/restore_operations_controller.go index 869c5acb1b..de7b96a760 100644 --- a/pkg/controller/restore_operations_controller.go +++ b/pkg/controller/restore_operations_controller.go @@ -130,6 +130,8 @@ func (r *restoreOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Re if err != nil { log.Warnf("Cannot check progress on Restore operations because backup info is unavailable %s; marking restore PartiallyFailed", err.Error()) restore.Status.Phase = velerov1api.RestorePhasePartiallyFailed + restore.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()} + r.metrics.RegisterRestorePartialFailure(restore.Spec.ScheduleName) err2 := r.updateRestoreAndOperationsJSON(ctx, original, restore, nil, &itemoperationmap.OperationsForRestore{ErrsSinceUpdate: []string{err.Error()}}, false, false) if err2 != nil { log.WithError(err2).Error("error updating Restore") @@ -140,7 +142,8 @@ func (r *restoreOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Re if info.location.Spec.AccessMode == velerov1api.BackupStorageLocationAccessModeReadOnly { log.Infof("Cannot check progress on Restore operations because backup storage location %s is currently in read-only mode; marking restore PartiallyFailed", info.location.Name) restore.Status.Phase = velerov1api.RestorePhasePartiallyFailed - + restore.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()} + r.metrics.RegisterRestorePartialFailure(restore.Spec.ScheduleName) err := r.updateRestoreAndOperationsJSON(ctx, original, restore, nil, &itemoperationmap.OperationsForRestore{ErrsSinceUpdate: []string{"BSL is read-only"}}, false, false) if err != nil { log.WithError(err).Error("error updating Restore") @@ -189,10 +192,12 @@ func (r *restoreOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Re if restore.Status.Phase == velerov1api.RestorePhaseWaitingForPluginOperations { log.Infof("Marking restore %s completed", restore.Name) restore.Status.Phase = velerov1api.RestorePhaseCompleted + restore.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()} r.metrics.RegisterRestoreSuccess(restore.Spec.ScheduleName) } else { log.Infof("Marking restore %s FinalizingPartiallyFailed", restore.Name) restore.Status.Phase = velerov1api.RestorePhasePartiallyFailed + restore.Status.CompletionTimestamp = &metav1.Time{Time: r.clock.Now()} r.metrics.RegisterRestorePartialFailure(restore.Spec.ScheduleName) } }