diff --git a/changelogs/unreleased/6318-ywk253100 b/changelogs/unreleased/6318-ywk253100 new file mode 100644 index 00000000000..064070e342d --- /dev/null +++ b/changelogs/unreleased/6318-ywk253100 @@ -0,0 +1 @@ +Update metrics when backup failed with validation error \ No newline at end of file diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index 90462a60f77..e2cc2d28d51 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -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 } @@ -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