Skip to content

Commit 977512f

Browse files
authored
Merge pull request #7 from s16rv/fix/image-collector
Fix bugs index out of range
2 parents 157f18e + e09e112 commit 977512f

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

collector/image.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ func (c *ImageCollector) Collect(ch chan<- prometheus.Metric) {
6161
}
6262

6363
for _, img := range images {
64+
if len(img.Regions) == 0 {
65+
return
66+
}
67+
6468
ch <- prometheus.MustNewConstMetric(
6569
c.MinDiskSize,
6670
prometheus.GaugeValue,

collector/snapshot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (c *SnapshotCollector) Collect(ch chan<- prometheus.Metric) {
6666
}
6767

6868
for _, snapshot := range snapshots {
69+
if len(snapshot.Regions) == 0 {
70+
return
71+
}
72+
6973
labels := []string{
7074
snapshot.ID,
7175
snapshot.Name,

0 commit comments

Comments
 (0)