Merge pull request #128166 from yongruilin/test-allow-label

test: add integration test for allow-metric-label

Kubernetes-commit: 154b756e2ed850d2e64baea269dbb749ac02a77d
This commit is contained in:
Kubernetes Publisher 2024-11-07 05:19:29 +00:00
commit a16a110639
3 changed files with 30 additions and 3 deletions

2
go.mod
View File

@ -50,7 +50,7 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.12.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/square/go-jose.v2 v2.6.0
k8s.io/api v0.0.0-20241106230208-459b3bf01982
k8s.io/api v0.0.0-20241108114310-4772861d607e
k8s.io/apimachinery v0.0.0-20241106231735-d941d9fb4c83
k8s.io/client-go v0.0.0-20241107030607-c57dbd8decb0
k8s.io/component-base v0.0.0-20241107031631-88ede593c6c4

4
go.sum
View File

@ -365,8 +365,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20241106230208-459b3bf01982 h1:dawXS/j3CvWhfIXAJA29WpGivkWXdaOE6HmDY24ujcU=
k8s.io/api v0.0.0-20241106230208-459b3bf01982/go.mod h1:a1KpjW7qk2zdbW2qzX85ex/fBhKNkow9dOvgGEKU+u8=
k8s.io/api v0.0.0-20241108114310-4772861d607e h1:SJxpg9FSTdq3qp/R+LRlZv+xjY+miO+30ZpC7QkSkoM=
k8s.io/api v0.0.0-20241108114310-4772861d607e/go.mod h1:h7yaPC7+0KxMELdLjLoo6n6m3EWq6AeHEY25PjH4cPI=
k8s.io/apimachinery v0.0.0-20241106231735-d941d9fb4c83 h1:4KfMPmiiRIpvYJQ8cBYFEFht59EKysW1anuJWzHLHNg=
k8s.io/apimachinery v0.0.0-20241106231735-d941d9fb4c83/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY=
k8s.io/client-go v0.0.0-20241107030607-c57dbd8decb0 h1:oDzLA4eLxznpJJ7JNIpfFwtH1ItBtE6BS+YBhPJYoJE=

View File

@ -416,6 +416,33 @@ func Reset() {
}
}
// ResetLabelAllowLists resets the label allow lists for all metrics.
// NOTE: This is only used for testing.
func ResetLabelAllowLists() {
for _, metric := range metrics {
if counterVec, ok := metric.(*compbasemetrics.CounterVec); ok {
counterVec.ResetLabelAllowLists()
continue
}
if gaugeVec, ok := metric.(*compbasemetrics.GaugeVec); ok {
gaugeVec.ResetLabelAllowLists()
continue
}
if histogramVec, ok := metric.(*compbasemetrics.HistogramVec); ok {
histogramVec.ResetLabelAllowLists()
continue
}
if summaryVec, ok := metric.(*compbasemetrics.SummaryVec); ok {
summaryVec.ResetLabelAllowLists()
continue
}
if timingHistogramVec, ok := metric.(*compbasemetrics.TimingHistogramVec); ok {
timingHistogramVec.ResetLabelAllowLists()
continue
}
}
}
// UpdateInflightRequestMetrics reports concurrency metrics classified by
// mutating vs Readonly.
func UpdateInflightRequestMetrics(phase string, nonmutating, mutating int) {