Skip to content

Commit

Permalink
add missing CompletionTimestamp and metrics when restore moved into t…
Browse files Browse the repository at this point in the history
…erminal phase (#6397)

Signed-off-by: Nutrymaco <[email protected]>
  • Loading branch information
Nutrymaco authored Jul 21, 2023
1 parent 178b073 commit 8396163
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/6397-Nutrymaco
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing CompletionTimestamp and metrics when restore moved into terminal phase in restoreOperationsReconciler
7 changes: 6 additions & 1 deletion pkg/controller/restore_operations_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 8396163

Please sign in to comment.