mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Address review comment
Removed defer, removed error slice
This commit is contained in:
parent
41dabd7918
commit
b3ced98aa5
@ -64,9 +64,7 @@ var _ = SIGDescribe("[Serial] Volume metrics", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
defer func() {
|
|
||||||
framework.DeletePersistentVolumeClaim(c, pvc.Name, pvc.Namespace)
|
framework.DeletePersistentVolumeClaim(c, pvc.Name, pvc.Namespace)
|
||||||
}()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should create prometheus metrics for volume provisioning and attach/detach", func() {
|
It("should create prometheus metrics for volume provisioning and attach/detach", func() {
|
||||||
@ -177,18 +175,18 @@ func getControllerStorageMetrics(ms metrics.ControllerManagerMetrics) map[string
|
|||||||
// Verifies the specified metrics are in `kubeletMetrics`
|
// Verifies the specified metrics are in `kubeletMetrics`
|
||||||
func verifyVolumeStatMetric(metricKeyName string, namespace string, pvcName string, kubeletMetrics metrics.KubeletMetrics) {
|
func verifyVolumeStatMetric(metricKeyName string, namespace string, pvcName string, kubeletMetrics metrics.KubeletMetrics) {
|
||||||
found := false
|
found := false
|
||||||
invalidSamples := []string{}
|
errCount := 0
|
||||||
if samples, ok := kubeletMetrics[metricKeyName]; ok {
|
if samples, ok := kubeletMetrics[metricKeyName]; ok {
|
||||||
for _, sample := range samples {
|
for _, sample := range samples {
|
||||||
samplePVC, ok := sample.Metric["persistentvolumeclaim"]
|
samplePVC, ok := sample.Metric["persistentvolumeclaim"]
|
||||||
if !ok {
|
if !ok {
|
||||||
framework.Logf("Error getting pvc for metric %s, sample %s", metricKeyName, sample.String())
|
framework.Logf("Error getting pvc for metric %s, sample %s", metricKeyName, sample.String())
|
||||||
invalidSamples = append(invalidSamples, sample.String())
|
errCount++
|
||||||
}
|
}
|
||||||
sampleNS, ok := sample.Metric["namespace"]
|
sampleNS, ok := sample.Metric["namespace"]
|
||||||
if !ok {
|
if !ok {
|
||||||
framework.Logf("Error getting namespace for metric %s, sample %s", metricKeyName, sample.String())
|
framework.Logf("Error getting namespace for metric %s, sample %s", metricKeyName, sample.String())
|
||||||
invalidSamples = append(invalidSamples, sample.String())
|
errCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(samplePVC) == pvcName && string(sampleNS) == namespace {
|
if string(samplePVC) == pvcName && string(sampleNS) == namespace {
|
||||||
@ -197,6 +195,6 @@ func verifyVolumeStatMetric(metricKeyName string, namespace string, pvcName stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expect(invalidSamples).To(HaveLen(0), "Found %d invalid samples", len(invalidSamples))
|
Expect(errCount).To(Equal(0), "Found invalid samples")
|
||||||
Expect(found).To(BeTrue(), "PVC %s, Namespace %s not found for %s", pvcName, namespace, metricKeyName)
|
Expect(found).To(BeTrue(), "PVC %s, Namespace %s not found for %s", pvcName, namespace, metricKeyName)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user