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 <spampatt@redhat.com>
This commit is contained in:
Shubham Pampattiwar
2026-07-22 09:17:59 -07:00
parent 6ea95548d6
commit bfeccba0a8
+7 -7
View File
@@ -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,