Update dependency go modules for k8s v1.29.0-rc.1
This commit is contained in:
10
vendor/k8s.io/component-base/metrics/buckets.go
generated
vendored
10
vendor/k8s.io/component-base/metrics/buckets.go
generated
vendored
@@ -33,6 +33,16 @@ func ExponentialBuckets(start, factor float64, count int) []float64 {
|
||||
return prometheus.ExponentialBuckets(start, factor, count)
|
||||
}
|
||||
|
||||
// ExponentialBucketsRange creates 'count' buckets, where the lowest bucket is
|
||||
// 'min' and the highest bucket is 'max'. The final +Inf bucket is not counted
|
||||
// and not included in the returned slice. The returned slice is meant to be
|
||||
// used for the Buckets field of HistogramOpts.
|
||||
//
|
||||
// The function panics if 'count' is 0 or negative, if 'min' is 0 or negative.
|
||||
func ExponentialBucketsRange(min, max float64, count int) []float64 {
|
||||
return prometheus.ExponentialBucketsRange(min, max, count)
|
||||
}
|
||||
|
||||
// MergeBuckets merges buckets together
|
||||
func MergeBuckets(buckets ...[]float64) []float64 {
|
||||
result := make([]float64, 1)
|
||||
|
2
vendor/k8s.io/component-base/metrics/metric.go
generated
vendored
2
vendor/k8s.io/component-base/metrics/metric.go
generated
vendored
@@ -166,7 +166,7 @@ func (r *lazyMetric) Create(version *semver.Version) bool {
|
||||
if deprecatedV != nil {
|
||||
dv = deprecatedV.String()
|
||||
}
|
||||
registeredMetrics.WithLabelValues(string(sl), dv).Inc()
|
||||
registeredMetricsTotal.WithLabelValues(string(sl), dv).Inc()
|
||||
return r.IsCreated()
|
||||
}
|
||||
|
||||
|
13
vendor/k8s.io/component-base/metrics/options.go
generated
vendored
13
vendor/k8s.io/component-base/metrics/options.go
generated
vendored
@@ -31,6 +31,7 @@ type Options struct {
|
||||
ShowHiddenMetricsForVersion string
|
||||
DisabledMetrics []string
|
||||
AllowListMapping map[string]string
|
||||
AllowListMappingManifest string
|
||||
}
|
||||
|
||||
// NewOptions returns default metrics options
|
||||
@@ -40,6 +41,10 @@ func NewOptions() *Options {
|
||||
|
||||
// Validate validates metrics flags options.
|
||||
func (o *Options) Validate() []error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errs []error
|
||||
err := validateShowHiddenMetricsVersion(parseVersion(version.Get()), o.ShowHiddenMetricsForVersion)
|
||||
if err != nil {
|
||||
@@ -77,6 +82,10 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
||||
"The map from metric-label to value allow-list of this label. The key's format is <MetricName>,<LabelName>. "+
|
||||
"The value's format is <allowed_value>,<allowed_value>..."+
|
||||
"e.g. metric1,label1='v1,v2,v3', metric1,label2='v1,v2,v3' metric2,label1='v1,v2,v3'.")
|
||||
fs.StringVar(&o.AllowListMappingManifest, "allow-metric-labels-manifest", o.AllowListMappingManifest,
|
||||
"The path to the manifest file that contains the allow-list mapping. "+
|
||||
"The format of the file is the same as the flag --allow-metric-labels. "+
|
||||
"Note that the flag --allow-metric-labels will override the manifest file.")
|
||||
}
|
||||
|
||||
// Apply applies parameters into global configuration of metrics.
|
||||
@@ -93,6 +102,8 @@ func (o *Options) Apply() {
|
||||
}
|
||||
if o.AllowListMapping != nil {
|
||||
SetLabelAllowListFromCLI(o.AllowListMapping)
|
||||
} else if len(o.AllowListMappingManifest) > 0 {
|
||||
SetLabelAllowListFromManifest(o.AllowListMappingManifest)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +129,7 @@ func validateAllowMetricLabel(allowListMapping map[string]string) error {
|
||||
for k := range allowListMapping {
|
||||
reg := regexp.MustCompile(metricNameRegex + `,` + labelRegex)
|
||||
if reg.FindString(k) != k {
|
||||
return fmt.Errorf("--allow-metric-labels must has a list of kv pair with format `metricName:labelName=labelValue, labelValue,...`")
|
||||
return fmt.Errorf("--allow-metric-labels must have a list of kv pair with format `metricName:labelName=labelValue, labelValue,...`")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
24
vendor/k8s.io/component-base/metrics/opts.go
generated
vendored
24
vendor/k8s.io/component-base/metrics/opts.go
generated
vendored
@@ -18,13 +18,18 @@ package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
promext "k8s.io/component-base/metrics/prometheusextension"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -319,6 +324,7 @@ func (allowList *MetricLabelAllowList) ConstrainToAllowedList(labelNameList, lab
|
||||
if allowValues, ok := allowList.labelToAllowList[name]; ok {
|
||||
if !allowValues.Has(value) {
|
||||
labelValueList[index] = "unexpected"
|
||||
cardinalityEnforcementUnexpectedCategorizationsTotal.Inc()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,6 +335,7 @@ func (allowList *MetricLabelAllowList) ConstrainLabelMap(labels map[string]strin
|
||||
if allowValues, ok := allowList.labelToAllowList[name]; ok {
|
||||
if !allowValues.Has(value) {
|
||||
labels[name] = "unexpected"
|
||||
cardinalityEnforcementUnexpectedCategorizationsTotal.Inc()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,3 +361,20 @@ func SetLabelAllowListFromCLI(allowListMapping map[string]string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetLabelAllowListFromManifest(manifest string) {
|
||||
allowListLock.Lock()
|
||||
defer allowListLock.Unlock()
|
||||
allowListMapping := make(map[string]string)
|
||||
data, err := os.ReadFile(filepath.Clean(manifest))
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to read allow list manifest: %v", err)
|
||||
return
|
||||
}
|
||||
err = yaml.Unmarshal(data, &allowListMapping)
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to parse allow list manifest: %v", err)
|
||||
return
|
||||
}
|
||||
SetLabelAllowListFromCLI(allowListMapping)
|
||||
}
|
||||
|
13
vendor/k8s.io/component-base/metrics/registry.go
generated
vendored
13
vendor/k8s.io/component-base/metrics/registry.go
generated
vendored
@@ -37,7 +37,7 @@ var (
|
||||
registriesLock sync.RWMutex
|
||||
disabledMetrics = map[string]struct{}{}
|
||||
|
||||
registeredMetrics = NewCounterVec(
|
||||
registeredMetricsTotal = NewCounterVec(
|
||||
&CounterOpts{
|
||||
Name: "registered_metrics_total",
|
||||
Help: "The count of registered metrics broken by stability level and deprecation version.",
|
||||
@@ -61,6 +61,14 @@ var (
|
||||
StabilityLevel: BETA,
|
||||
},
|
||||
)
|
||||
|
||||
cardinalityEnforcementUnexpectedCategorizationsTotal = NewCounter(
|
||||
&CounterOpts{
|
||||
Name: "cardinality_enforcement_unexpected_categorizations_total",
|
||||
Help: "The count of unexpected categorizations during cardinality enforcement.",
|
||||
StabilityLevel: ALPHA,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
// shouldHide be used to check if a specific metric with deprecated version should be hidden
|
||||
@@ -379,7 +387,8 @@ func NewKubeRegistry() KubeRegistry {
|
||||
}
|
||||
|
||||
func (r *kubeRegistry) RegisterMetaMetrics() {
|
||||
r.MustRegister(registeredMetrics)
|
||||
r.MustRegister(registeredMetricsTotal)
|
||||
r.MustRegister(disabledMetricsTotal)
|
||||
r.MustRegister(hiddenMetricsTotal)
|
||||
r.MustRegister(cardinalityEnforcementUnexpectedCategorizationsTotal)
|
||||
}
|
||||
|
Reference in New Issue
Block a user