Skip to content

Commit

Permalink
fix(metrics): don't parse backup.status.size with an empty string
Browse files Browse the repository at this point in the history
Longhorn 10358

Signed-off-by: Derek Su <derek.su@suse.com>
(cherry picked from commit be22faf)
  • Loading branch information
derekbit authored and mergify[bot] committed Feb 11, 2025
1 parent 155bd59 commit 19e0076
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metrics_collector/backup_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ func (bc *BackupCollector) Collect(ch chan<- prometheus.Metric) {
for _, backup := range backupLists {
if backup.Status.OwnerID == bc.currentNodeID {
var size float64
if size, err = strconv.ParseFloat(backup.Status.Size, 64); err != nil {
bc.logger.WithError(err).Warn("Error get size")
if backup.Status.Size != "" {
if size, err = strconv.ParseFloat(backup.Status.Size, 64); err != nil {
bc.logger.WithError(err).Warn("Error get size")
}
}
backupVolumeName, ok := backup.Labels[types.LonghornLabelBackupVolume]
if !ok {
Expand Down

0 comments on commit 19e0076

Please sign in to comment.