mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #128426 from yongruilin/reset-label-allow-list
feat(metrics): Add util func to reset label allow lists
This commit is contained in:
commit
151ca569f9
@ -37,6 +37,14 @@ var (
|
|||||||
allowListLock sync.RWMutex
|
allowListLock sync.RWMutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ResetLabelValueAllowLists resets the allow lists for label values.
|
||||||
|
// NOTE: This should only be used in test.
|
||||||
|
func ResetLabelValueAllowLists() {
|
||||||
|
allowListLock.Lock()
|
||||||
|
defer allowListLock.Unlock()
|
||||||
|
labelValueAllowLists = map[string]*MetricLabelAllowList{}
|
||||||
|
}
|
||||||
|
|
||||||
// KubeOpts is superset struct for prometheus.Opts. The prometheus Opts structure
|
// KubeOpts is superset struct for prometheus.Opts. The prometheus Opts structure
|
||||||
// is purposefully not embedded here because that would change struct initialization
|
// is purposefully not embedded here because that would change struct initialization
|
||||||
// in the manner which people are currently accustomed.
|
// in the manner which people are currently accustomed.
|
||||||
|
@ -208,3 +208,21 @@ metric2,label2: v3`,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResetLabelValueAllowLists(t *testing.T) {
|
||||||
|
labelValueAllowLists = map[string]*MetricLabelAllowList{
|
||||||
|
"metric1": {
|
||||||
|
labelToAllowList: map[string]sets.Set[string]{
|
||||||
|
"label1": sets.New[string]("v1", "v2"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"metric2": {
|
||||||
|
labelToAllowList: map[string]sets.Set[string]{
|
||||||
|
"label2": sets.New[string]("v3"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetLabelValueAllowLists()
|
||||||
|
assert.Empty(t, labelValueAllowLists)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user