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 0dd48f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/6318-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update metrics when backup failed with validation error
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 0dd48f6

Please sign in to comment.