mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update kubernetes to v1.21.2
Updated kubernetes packages to latest release. resizefs package has been included into k8s.io/mount-utils package. updated code to use the same. Updates: #1968 Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
57
vendor/k8s.io/component-base/metrics/counter.go
generated
vendored
57
vendor/k8s.io/component-base/metrics/counter.go
generated
vendored
@ -17,8 +17,10 @@ limitations under the License.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/blang/semver"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
// Counter is our internal representation for our wrapping struct around prometheus
|
||||
@ -30,6 +32,9 @@ type Counter struct {
|
||||
selfCollector
|
||||
}
|
||||
|
||||
// The implementation of the Metric interface is expected by testutil.GetCounterMetricValue.
|
||||
var _ Metric = &Counter{}
|
||||
|
||||
// NewCounter returns an object which satisfies the kubeCollector and CounterMetric interfaces.
|
||||
// However, the object returned will not measure anything unless the collector is first
|
||||
// registered, since the metric is lazily instantiated.
|
||||
@ -45,6 +50,14 @@ func NewCounter(opts *CounterOpts) *Counter {
|
||||
return kc
|
||||
}
|
||||
|
||||
func (c *Counter) Desc() *prometheus.Desc {
|
||||
return c.metric.Desc()
|
||||
}
|
||||
|
||||
func (c *Counter) Write(to *dto.Metric) error {
|
||||
return c.metric.Write(to)
|
||||
}
|
||||
|
||||
// Reset resets the underlying prometheus Counter to start counting from 0 again
|
||||
func (c *Counter) Reset() {
|
||||
if !c.IsCreated() {
|
||||
@ -79,6 +92,11 @@ func (c *Counter) initializeDeprecatedMetric() {
|
||||
c.initializeMetric()
|
||||
}
|
||||
|
||||
// WithContext allows the normal Counter metric to pass in context. The context is no-op now.
|
||||
func (c *Counter) WithContext(ctx context.Context) CounterMetric {
|
||||
return c.CounterMetric
|
||||
}
|
||||
|
||||
// CounterVec is the internal representation of our wrapping struct around prometheus
|
||||
// counterVecs. CounterVec implements both kubeCollector and CounterVecMetric.
|
||||
type CounterVec struct {
|
||||
@ -94,13 +112,20 @@ type CounterVec struct {
|
||||
func NewCounterVec(opts *CounterOpts, labels []string) *CounterVec {
|
||||
opts.StabilityLevel.setDefaults()
|
||||
|
||||
fqName := BuildFQName(opts.Namespace, opts.Subsystem, opts.Name)
|
||||
allowListLock.RLock()
|
||||
if allowList, ok := labelValueAllowLists[fqName]; ok {
|
||||
opts.LabelValueAllowLists = allowList
|
||||
}
|
||||
allowListLock.RUnlock()
|
||||
|
||||
cv := &CounterVec{
|
||||
CounterVec: noopCounterVec,
|
||||
CounterOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
}
|
||||
cv.lazyInit(cv, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
cv.lazyInit(cv, fqName)
|
||||
return cv
|
||||
}
|
||||
|
||||
@ -140,6 +165,9 @@ func (v *CounterVec) WithLabelValues(lvs ...string) CounterMetric {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op counter
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainToAllowedList(v.originalLabels, lvs)
|
||||
}
|
||||
return v.CounterVec.WithLabelValues(lvs...)
|
||||
}
|
||||
|
||||
@ -151,6 +179,9 @@ func (v *CounterVec) With(labels map[string]string) CounterMetric {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op counter
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainLabelMap(labels)
|
||||
}
|
||||
return v.CounterVec.With(labels)
|
||||
}
|
||||
|
||||
@ -176,3 +207,27 @@ func (v *CounterVec) Reset() {
|
||||
|
||||
v.CounterVec.Reset()
|
||||
}
|
||||
|
||||
// WithContext returns wrapped CounterVec with context
|
||||
func (v *CounterVec) WithContext(ctx context.Context) *CounterVecWithContext {
|
||||
return &CounterVecWithContext{
|
||||
ctx: ctx,
|
||||
CounterVec: *v,
|
||||
}
|
||||
}
|
||||
|
||||
// CounterVecWithContext is the wrapper of CounterVec with context.
|
||||
type CounterVecWithContext struct {
|
||||
CounterVec
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// WithLabelValues is the wrapper of CounterVec.WithLabelValues.
|
||||
func (vc *CounterVecWithContext) WithLabelValues(lvs ...string) CounterMetric {
|
||||
return vc.CounterVec.WithLabelValues(lvs...)
|
||||
}
|
||||
|
||||
// With is the wrapper of CounterVec.With.
|
||||
func (vc *CounterVecWithContext) With(labels map[string]string) CounterMetric {
|
||||
return vc.CounterVec.With(labels)
|
||||
}
|
||||
|
Reference in New Issue
Block a user