@@ -104,11 +104,16 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
104
104
framework .Skipf ("Environment does not support getting controller-manager metrics - skipping" )
105
105
}
106
106
107
+ ginkgo .By ("Getting plugin name" )
108
+ defaultClass , err := c .StorageV1 ().StorageClasses ().Get (defaultScName , metav1.GetOptions {})
109
+ framework .ExpectNoError (err , "Error getting default storageclass: %v" , err )
110
+ pluginName := defaultClass .Provisioner
111
+
107
112
controllerMetrics , err := metricsGrabber .GrabFromControllerManager ()
108
113
109
114
framework .ExpectNoError (err , "Error getting c-m metrics : %v" , err )
110
115
111
- storageOpMetrics := getControllerStorageMetrics (controllerMetrics )
116
+ storageOpMetrics := getControllerStorageMetrics (controllerMetrics , pluginName )
112
117
113
118
pvc , err = c .CoreV1 ().PersistentVolumeClaims (pvc .Namespace ).Create (pvc )
114
119
framework .ExpectNoError (err )
@@ -126,7 +131,7 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
126
131
framework .Logf ("Deleting pod %q/%q" , pod .Namespace , pod .Name )
127
132
framework .ExpectNoError (e2epod .DeletePodWithWait (c , pod ))
128
133
129
- updatedStorageMetrics := waitForDetachAndGrabMetrics (storageOpMetrics , metricsGrabber )
134
+ updatedStorageMetrics := waitForDetachAndGrabMetrics (storageOpMetrics , metricsGrabber , pluginName )
130
135
131
136
framework .ExpectNotEqual (len (updatedStorageMetrics .latencyMetrics ), 0 , "Error fetching c-m updated storage metrics" )
132
137
framework .ExpectNotEqual (len (updatedStorageMetrics .statusMetrics ), 0 , "Error fetching c-m updated storage metrics" )
@@ -145,15 +150,16 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
145
150
framework .Skipf ("Environment does not support getting controller-manager metrics - skipping" )
146
151
}
147
152
153
+ ginkgo .By ("Geting default storageclass" )
154
+ defaultClass , err := c .StorageV1 ().StorageClasses ().Get (defaultScName , metav1.GetOptions {})
155
+ framework .ExpectNoError (err , "Error getting default storageclass: %v" , err )
156
+ pluginName := defaultClass .Provisioner
157
+
148
158
controllerMetrics , err := metricsGrabber .GrabFromControllerManager ()
149
159
150
160
framework .ExpectNoError (err , "Error getting c-m metrics : %v" , err )
151
161
152
- storageOpMetrics := getControllerStorageMetrics (controllerMetrics )
153
-
154
- ginkgo .By ("Creating an invalid storageclass" )
155
- defaultClass , err := c .StorageV1 ().StorageClasses ().Get (defaultScName , metav1.GetOptions {})
156
- framework .ExpectNoError (err , "Error getting default storageclass: %v" , err )
162
+ storageOpMetrics := getControllerStorageMetrics (controllerMetrics , pluginName )
157
163
158
164
invalidSc = & storagev1.StorageClass {
159
165
ObjectMeta : metav1.ObjectMeta {
@@ -188,7 +194,7 @@ var _ = utils.SIGDescribe("[Serial] Volume metrics", func() {
188
194
ginkgo .By ("Checking failure metrics" )
189
195
updatedControllerMetrics , err := metricsGrabber .GrabFromControllerManager ()
190
196
framework .ExpectNoError (err , "failed to get controller manager metrics" )
191
- updatedStorageMetrics := getControllerStorageMetrics (updatedControllerMetrics )
197
+ updatedStorageMetrics := getControllerStorageMetrics (updatedControllerMetrics , pluginName )
192
198
193
199
framework .ExpectNotEqual (len (updatedStorageMetrics .statusMetrics ), 0 , "Error fetching c-m updated storage metrics" )
194
200
verifyMetricCount (storageOpMetrics , updatedStorageMetrics , "volume_provision" , true )
@@ -521,7 +527,7 @@ func newStorageControllerMetrics() *storageControllerMetrics {
521
527
}
522
528
}
523
529
524
- func waitForDetachAndGrabMetrics (oldMetrics * storageControllerMetrics , metricsGrabber * metrics.Grabber ) * storageControllerMetrics {
530
+ func waitForDetachAndGrabMetrics (oldMetrics * storageControllerMetrics , metricsGrabber * metrics.Grabber , pluginName string ) * storageControllerMetrics {
525
531
backoff := wait.Backoff {
526
532
Duration : 10 * time .Second ,
527
533
Factor : 1.2 ,
@@ -542,7 +548,7 @@ func waitForDetachAndGrabMetrics(oldMetrics *storageControllerMetrics, metricsGr
542
548
return false , err
543
549
}
544
550
545
- updatedStorageMetrics = getControllerStorageMetrics (updatedMetrics )
551
+ updatedStorageMetrics = getControllerStorageMetrics (updatedMetrics , pluginName )
546
552
newDetachCount , ok := updatedStorageMetrics .latencyMetrics ["volume_detach" ]
547
553
548
554
// if detach metrics are not yet there, we need to retry
@@ -555,6 +561,7 @@ func waitForDetachAndGrabMetrics(oldMetrics *storageControllerMetrics, metricsGr
555
561
if oldDetachCount >= newDetachCount {
556
562
return false , nil
557
563
}
564
+
558
565
return true , nil
559
566
}
560
567
@@ -602,7 +609,7 @@ func verifyMetricCount(oldMetrics, newMetrics *storageControllerMetrics, metricN
602
609
gomega .Expect (newStatusCount ).To (gomega .BeNumerically (">" , oldStatusCount ), "New status count %d should be more than old count %d for action %s" , newStatusCount , oldStatusCount , metricName )
603
610
}
604
611
605
- func getControllerStorageMetrics (ms metrics.ControllerManagerMetrics ) * storageControllerMetrics {
612
+ func getControllerStorageMetrics (ms metrics.ControllerManagerMetrics , pluginName string ) * storageControllerMetrics {
606
613
result := newStorageControllerMetrics ()
607
614
608
615
for method , samples := range ms {
@@ -612,6 +619,10 @@ func getControllerStorageMetrics(ms metrics.ControllerManagerMetrics) *storageCo
612
619
for _ , sample := range samples {
613
620
count := int64 (sample .Value )
614
621
operation := string (sample .Metric ["operation_name" ])
622
+ metricPluginName := string (sample .Metric ["volume_plugin" ])
623
+ if len (pluginName ) > 0 && pluginName != metricPluginName {
624
+ continue
625
+ }
615
626
result .latencyMetrics [operation ] = count
616
627
}
617
628
case "storage_operation_status_count" :
@@ -620,6 +631,10 @@ func getControllerStorageMetrics(ms metrics.ControllerManagerMetrics) *storageCo
620
631
operation := string (sample .Metric ["operation_name" ])
621
632
status := string (sample .Metric ["status" ])
622
633
statusCounts := result .statusMetrics [operation ]
634
+ metricPluginName := string (sample .Metric ["volume_plugin" ])
635
+ if len (pluginName ) > 0 && pluginName != metricPluginName {
636
+ continue
637
+ }
623
638
switch status {
624
639
case "success" :
625
640
statusCounts .successCount = count
0 commit comments