update dependencies (#6267)
Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
23
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/leaderelection.go
generated
vendored
23
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/leaderelection.go
generated
vendored
@@ -14,6 +14,11 @@ var (
|
||||
Name: "leader_election_master_status",
|
||||
Help: "Gauge of if the reporting system is master of the relevant lease, 0 indicates backup, 1 indicates master. 'name' is the string used to identify the lease. Please make sure to group by name.",
|
||||
}, []string{"name"})
|
||||
|
||||
leaderSlowpathCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "leader_election_slowpath_total",
|
||||
Help: "Total number of slow path exercised in renewing leader leases. 'name' is the string used to identify the lease. Please make sure to group by name.",
|
||||
}, []string{"name"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -23,18 +28,20 @@ func init() {
|
||||
|
||||
type leaderelectionMetricsProvider struct{}
|
||||
|
||||
func (leaderelectionMetricsProvider) NewLeaderMetric() leaderelection.SwitchMetric {
|
||||
return &switchAdapter{gauge: leaderGauge}
|
||||
func (leaderelectionMetricsProvider) NewLeaderMetric() leaderelection.LeaderMetric {
|
||||
return leaderElectionPrometheusAdapter{}
|
||||
}
|
||||
|
||||
type switchAdapter struct {
|
||||
gauge *prometheus.GaugeVec
|
||||
type leaderElectionPrometheusAdapter struct{}
|
||||
|
||||
func (s leaderElectionPrometheusAdapter) On(name string) {
|
||||
leaderGauge.WithLabelValues(name).Set(1.0)
|
||||
}
|
||||
|
||||
func (s *switchAdapter) On(name string) {
|
||||
s.gauge.WithLabelValues(name).Set(1.0)
|
||||
func (s leaderElectionPrometheusAdapter) Off(name string) {
|
||||
leaderGauge.WithLabelValues(name).Set(0.0)
|
||||
}
|
||||
|
||||
func (s *switchAdapter) Off(name string) {
|
||||
s.gauge.WithLabelValues(name).Set(0.0)
|
||||
func (leaderElectionPrometheusAdapter) SlowpathExercised(name string) {
|
||||
leaderSlowpathCounter.WithLabelValues(name).Inc()
|
||||
}
|
||||
|
||||
32
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/server/server.go
generated
vendored
32
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/server/server.go
generated
vendored
@@ -46,6 +46,9 @@ var DefaultBindAddress = ":8080"
|
||||
|
||||
// Server is a server that serves metrics.
|
||||
type Server interface {
|
||||
// AddExtraHandler adds extra handler served on path to the http server that serves metrics.
|
||||
AddExtraHandler(path string, handler http.Handler) error
|
||||
|
||||
// NeedLeaderElection implements the LeaderElectionRunnable interface, which indicates
|
||||
// the metrics server doesn't need leader election.
|
||||
NeedLeaderElection() bool
|
||||
@@ -101,6 +104,9 @@ type Options struct {
|
||||
// TLSOpts is used to allow configuring the TLS config used for the server.
|
||||
// This also allows providing a certificate via GetCertificate.
|
||||
TLSOpts []func(*tls.Config)
|
||||
|
||||
// ListenConfig contains options for listening to an address on the metric server.
|
||||
ListenConfig net.ListenConfig
|
||||
}
|
||||
|
||||
// Filter is a func that is added around metrics and extra handlers on the metrics server.
|
||||
@@ -179,6 +185,23 @@ func (*defaultServer) NeedLeaderElection() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// AddExtraHandler adds extra handler served on path to the http server that serves metrics.
|
||||
func (s *defaultServer) AddExtraHandler(path string, handler http.Handler) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.options.ExtraHandlers == nil {
|
||||
s.options.ExtraHandlers = make(map[string]http.Handler)
|
||||
}
|
||||
if path == defaultMetricsEndpoint {
|
||||
return fmt.Errorf("overriding builtin %s endpoint is not allowed", defaultMetricsEndpoint)
|
||||
}
|
||||
if _, found := s.options.ExtraHandlers[path]; found {
|
||||
return fmt.Errorf("can't register extra handler by duplicate path %q on metrics http server", path)
|
||||
}
|
||||
s.options.ExtraHandlers[path] = handler
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start runs the server.
|
||||
// It will install the metrics related resources depend on the server configuration.
|
||||
func (s *defaultServer) Start(ctx context.Context) error {
|
||||
@@ -249,7 +272,7 @@ func (s *defaultServer) Start(ctx context.Context) error {
|
||||
|
||||
func (s *defaultServer) createListener(ctx context.Context, log logr.Logger) (net.Listener, error) {
|
||||
if !s.options.SecureServing {
|
||||
return net.Listen("tcp", s.options.BindAddress)
|
||||
return s.options.ListenConfig.Listen(ctx, "tcp", s.options.BindAddress)
|
||||
}
|
||||
|
||||
cfg := &tls.Config{ //nolint:gosec
|
||||
@@ -302,7 +325,12 @@ func (s *defaultServer) createListener(ctx context.Context, log logr.Logger) (ne
|
||||
cfg.Certificates = []tls.Certificate{keyPair}
|
||||
}
|
||||
|
||||
return tls.Listen("tcp", s.options.BindAddress, cfg)
|
||||
l, err := s.options.ListenConfig.Listen(ctx, "tcp", s.options.BindAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return tls.NewListener(l, cfg), nil
|
||||
}
|
||||
|
||||
func (s *defaultServer) GetBindAddr() string {
|
||||
|
||||
28
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/workqueue.go
generated
vendored
28
vendor/sigs.k8s.io/controller-runtime/pkg/metrics/workqueue.go
generated
vendored
@@ -42,27 +42,27 @@ var (
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: DepthKey,
|
||||
Help: "Current depth of workqueue",
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
adds = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: AddsKey,
|
||||
Help: "Total number of adds handled by workqueue",
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
latency = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: QueueLatencyKey,
|
||||
Help: "How long in seconds an item stays in workqueue before being requested",
|
||||
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 12),
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
workDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: WorkDurationKey,
|
||||
Help: "How long in seconds processing an item from workqueue takes.",
|
||||
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 12),
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
unfinished = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
@@ -71,20 +71,20 @@ var (
|
||||
"is in progress and hasn't been observed by work_duration. Large " +
|
||||
"values indicate stuck threads. One can deduce the number of stuck " +
|
||||
"threads by observing the rate at which this increases.",
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
longestRunningProcessor = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: LongestRunningProcessorKey,
|
||||
Help: "How many seconds has the longest running " +
|
||||
"processor for workqueue been running.",
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
|
||||
retries = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Subsystem: WorkQueueSubsystem,
|
||||
Name: RetriesKey,
|
||||
Help: "Total number of retries handled by workqueue",
|
||||
}, []string{"name"})
|
||||
}, []string{"name", "controller"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -102,29 +102,29 @@ func init() {
|
||||
type workqueueMetricsProvider struct{}
|
||||
|
||||
func (workqueueMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric {
|
||||
return depth.WithLabelValues(name)
|
||||
return depth.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric {
|
||||
return adds.WithLabelValues(name)
|
||||
return adds.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewLatencyMetric(name string) workqueue.HistogramMetric {
|
||||
return latency.WithLabelValues(name)
|
||||
return latency.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewWorkDurationMetric(name string) workqueue.HistogramMetric {
|
||||
return workDuration.WithLabelValues(name)
|
||||
return workDuration.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewUnfinishedWorkSecondsMetric(name string) workqueue.SettableGaugeMetric {
|
||||
return unfinished.WithLabelValues(name)
|
||||
return unfinished.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewLongestRunningProcessorSecondsMetric(name string) workqueue.SettableGaugeMetric {
|
||||
return longestRunningProcessor.WithLabelValues(name)
|
||||
return longestRunningProcessor.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
func (workqueueMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
|
||||
return retries.WithLabelValues(name)
|
||||
return retries.WithLabelValues(name, name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user