From b88b51c6e5191fa3a70d052438720672aa17462d Mon Sep 17 00:00:00 2001 From: cyclinder Date: Fri, 10 Dec 2021 19:16:34 +0800 Subject: [PATCH] adding evictions_total metric and marking evictions_number deprecated Signed-off-by: Davanum Srinivas --- pkg/controller/nodelifecycle/metrics.go | 16 ++++++++++++++-- .../nodelifecycle/node_lifecycle_controller.go | 3 +++ .../testdata/stable-metrics-list.yaml | 8 ++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pkg/controller/nodelifecycle/metrics.go b/pkg/controller/nodelifecycle/metrics.go index 9314af04291..ace0ca32226 100644 --- a/pkg/controller/nodelifecycle/metrics.go +++ b/pkg/controller/nodelifecycle/metrics.go @@ -29,6 +29,7 @@ const ( zoneSizeKey = "zone_size" zoneNoUnhealthyNodesKey = "unhealthy_nodes_in_zone" evictionsNumberKey = "evictions_number" + evictionsTotalKey = "evictions_total" ) var ( @@ -60,11 +61,21 @@ var ( []string{"zone"}, ) evictionsNumber = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: nodeControllerSubsystem, + Name: evictionsNumberKey, + Help: "Number of Node evictions that happened since current instance of NodeController started, This metric is replaced by node_collector_evictions_total.", + DeprecatedVersion: "1.24.0", + StabilityLevel: metrics.ALPHA, + }, + []string{"zone"}, + ) + evictionsTotal = metrics.NewCounterVec( &metrics.CounterOpts{ Subsystem: nodeControllerSubsystem, - Name: evictionsNumberKey, + Name: evictionsTotalKey, Help: "Number of Node evictions that happened since current instance of NodeController started.", - StabilityLevel: metrics.ALPHA, + StabilityLevel: metrics.STABLE, }, []string{"zone"}, ) @@ -79,5 +90,6 @@ func Register() { legacyregistry.MustRegister(zoneSize) legacyregistry.MustRegister(unhealthyNodes) legacyregistry.MustRegister(evictionsNumber) + legacyregistry.MustRegister(evictionsTotal) }) } diff --git a/pkg/controller/nodelifecycle/node_lifecycle_controller.go b/pkg/controller/nodelifecycle/node_lifecycle_controller.go index b9a37311e04..8ada7320e29 100644 --- a/pkg/controller/nodelifecycle/node_lifecycle_controller.go +++ b/pkg/controller/nodelifecycle/node_lifecycle_controller.go @@ -699,6 +699,7 @@ func (nc *Controller) doNoExecuteTaintingPass(ctx context.Context) { //count the evictionsNumber zone := nodetopology.GetZoneKey(node) evictionsNumber.WithLabelValues(zone).Inc() + evictionsTotal.WithLabelValues(zone).Inc() } return result, 0 @@ -742,6 +743,7 @@ func (nc *Controller) doEvictionPass(ctx context.Context) { if node != nil { zone := nodetopology.GetZoneKey(node) evictionsNumber.WithLabelValues(zone).Inc() + evictionsTotal.WithLabelValues(zone).Inc() } return true, 0 @@ -1396,6 +1398,7 @@ func (nc *Controller) addPodEvictorForNewZone(node *v1.Node) { // Init the metric for the new zone. klog.Infof("Initializing eviction metric for zone: %v", zone) evictionsNumber.WithLabelValues(zone).Add(0) + evictionsTotal.WithLabelValues(zone).Add(0) } } diff --git a/test/instrumentation/testdata/stable-metrics-list.yaml b/test/instrumentation/testdata/stable-metrics-list.yaml index fdeda713bab..be3a2483e8b 100644 --- a/test/instrumentation/testdata/stable-metrics-list.yaml +++ b/test/instrumentation/testdata/stable-metrics-list.yaml @@ -1,3 +1,11 @@ +- name: evictions_total + subsystem: node_collector + help: Number of Node evictions that happened since current instance of NodeController + started. + type: Counter + stabilityLevel: STABLE + labels: + - zone - name: framework_extension_point_duration_seconds subsystem: scheduler help: Latency for running all plugins of a specific extension point.