mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-10 15:07:29 +00:00
recompute backup_last_successful_timestamp metric during resync
Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
@@ -148,12 +148,36 @@ func NewBackupController(
|
||||
}
|
||||
|
||||
func (c *backupController) resync() {
|
||||
// recompute backup_total metric
|
||||
backups, err := c.lister.List(labels.Everything())
|
||||
if err != nil {
|
||||
c.logger.Error(err, "Error computing backup_total metric")
|
||||
} else {
|
||||
c.metrics.SetBackupTotal(int64(len(backups)))
|
||||
}
|
||||
|
||||
// recompute backup_last_successful_timestamp metric for each
|
||||
// schedule (including the empty schedule, i.e. ad-hoc backups)
|
||||
lastSuccessBySchedule := map[string]time.Time{}
|
||||
for _, backup := range backups {
|
||||
if backup.Status.Phase != velerov1api.BackupPhaseCompleted {
|
||||
continue
|
||||
}
|
||||
if backup.Status.CompletionTimestamp == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
schedule := backup.Labels[velerov1api.ScheduleNameLabel]
|
||||
timestamp := backup.Status.CompletionTimestamp.Time
|
||||
|
||||
if timestamp.After(lastSuccessBySchedule[schedule]) {
|
||||
lastSuccessBySchedule[schedule] = timestamp
|
||||
}
|
||||
}
|
||||
|
||||
for schedule, timestamp := range lastSuccessBySchedule {
|
||||
c.metrics.SetBackupLastSuccessfulTimestamp(schedule, timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *backupController) processBackup(key string) error {
|
||||
|
||||
Reference in New Issue
Block a user