From bfeccba0a84958943aae709766c663f73950160d Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Mon, 20 Jul 2026 12:32:02 -0700 Subject: [PATCH] Move metric reset inside List success block Avoid clearing backupLastSuccessfulTimestamp on transient API errors. The reset and re-set now only run when the backup List call succeeds, so existing metric values remain stable across temporary failures. Signed-off-by: Shubham Pampattiwar --- pkg/controller/backup_controller.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index 7a58424eb..0e2fb1384 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -212,14 +212,14 @@ func (b *backupReconciler) updateTotalBackupMetric() { b.logger.Error(err, "Error computing backup_total metric") } else { b.metrics.SetBackupTotal(int64(len(backups.Items))) - } - // recompute backup_last_successful_timestamp metric for each - // schedule (including the empty schedule, i.e. ad-hoc backups). - // Reset first to prune stale entries for deleted schedules. - b.metrics.ResetBackupLastSuccessfulTimestamp() - for schedule, timestamp := range getLastSuccessBySchedule(backups.Items) { - b.metrics.SetBackupLastSuccessfulTimestamp(schedule, timestamp) + // recompute backup_last_successful_timestamp metric for each + // schedule (including the empty schedule, i.e. ad-hoc backups). + // Reset first to prune stale entries for deleted schedules. + b.metrics.ResetBackupLastSuccessfulTimestamp() + for schedule, timestamp := range getLastSuccessBySchedule(backups.Items) { + b.metrics.SetBackupLastSuccessfulTimestamp(schedule, timestamp) + } } }, backupResyncPeriod,