Skip to content

Commit

Permalink
Update metrics when backup failed with validation error
Browse files Browse the repository at this point in the history
Update metrics when backup failed with validation error

Fixes #6265

Signed-off-by: Wenkai Yin(尹文开) <[email protected]>
  • Loading branch information
ywk253100 committed May 29, 2023
1 parent f9057bd commit 65dfd9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,13 @@ func (b *backupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
// store ref to just-updated item for creating patch
original = request.Backup.DeepCopy()

backupScheduleName := request.GetLabels()[velerov1api.ScheduleNameLabel]

if request.Status.Phase == velerov1api.BackupPhaseFailedValidation {
log.Debug("failed to validate backup status")
b.metrics.RegisterBackupValidationFailure(backupScheduleName)
b.metrics.RegisterBackupLastStatus(backupScheduleName, metrics.BackupLastStatusFailure)

return ctrl.Result{}, nil
}

Expand All @@ -274,7 +279,6 @@ func (b *backupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr

log.Debug("Running backup")

backupScheduleName := request.GetLabels()[velerov1api.ScheduleNameLabel]
b.metrics.RegisterBackupAttempt(backupScheduleName)

// execution & upload of backup
Expand Down

0 comments on commit 65dfd9c

Please sign in to comment.