@@ -7,10 +7,10 @@ import (
7
7
"net/http"
8
8
"time"
9
9
10
- "golang.org/x/net/context/ctxhttp"
11
-
12
10
"github.com/golang/glog"
13
11
"github.com/prometheus/client_golang/prometheus"
12
+ "golang.org/x/net/context/ctxhttp"
13
+ "k8s.io/apimachinery/pkg/util/sets"
14
14
)
15
15
16
16
const (
@@ -169,6 +169,7 @@ func (collector *volumeStatsCollector) Collect(ch chan<- prometheus.Metric) {
169
169
}
170
170
171
171
if statsSummary .Pods != nil {
172
+ allPVCs := sets.String {}
172
173
for _ , podStats := range statsSummary .Pods {
173
174
if podStats .VolumeStats == nil {
174
175
continue
@@ -179,12 +180,18 @@ func (collector *volumeStatsCollector) Collect(ch chan<- prometheus.Metric) {
179
180
// ignore if no PVC reference
180
181
continue
181
182
}
183
+ pvcUniqStr := pvcRef .Namespace + pvcRef .Name
184
+ if allPVCs .Has (pvcUniqStr ) {
185
+ // ignore if already collected
186
+ continue
187
+ }
182
188
addGauge (volumeStatsCapacityBytes , pvcRef , float64 (* volumeStat .CapacityBytes ))
183
189
addGauge (volumeStatsAvailableBytes , pvcRef , float64 (* volumeStat .AvailableBytes ))
184
190
addGauge (volumeStatsUsedBytes , pvcRef , float64 (* volumeStat .UsedBytes ))
185
191
addGauge (volumeStatsInodes , pvcRef , float64 (* volumeStat .Inodes ))
186
192
addGauge (volumeStatsInodesFree , pvcRef , float64 (* volumeStat .InodesFree ))
187
193
addGauge (volumeStatsInodesUsed , pvcRef , float64 (* volumeStat .InodesUsed ))
194
+ allPVCs .Insert (pvcUniqStr )
188
195
}
189
196
}
190
197
}
0 commit comments