From 1ff8fac13832b23837a9778efb034cdf41f7797e Mon Sep 17 00:00:00 2001 From: PingWang Date: Tue, 15 Jan 2019 11:07:14 +0800 Subject: [PATCH] Correct the count of evictionsNumber Signed-off-by: PingWang check nodeutil.SwapNodeControllerTaint's return Signed-off-by: PingWang --- .../node_lifecycle_controller.go | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/controller/nodelifecycle/node_lifecycle_controller.go b/pkg/controller/nodelifecycle/node_lifecycle_controller.go index 598b37c1cb..7fe4aa8b8d 100644 --- a/pkg/controller/nodelifecycle/node_lifecycle_controller.go +++ b/pkg/controller/nodelifecycle/node_lifecycle_controller.go @@ -573,9 +573,6 @@ func (nc *Controller) doNoExecuteTaintingPass() { klog.Warningf("Failed to get Node %v from the nodeLister: %v", value.Value, err) // retry in 50 millisecond return false, 50 * time.Millisecond - } else { - zone := utilnode.GetZoneKey(node) - evictionsNumber.WithLabelValues(zone).Inc() } _, condition := v1node.GetNodeCondition(&node.Status, v1.NodeReady) // Because we want to mimic NodeStatus.Condition["Ready"] we make "unreachable" and "not ready" taints mutually exclusive. @@ -593,7 +590,14 @@ func (nc *Controller) doNoExecuteTaintingPass() { return true, 0 } - return nodeutil.SwapNodeControllerTaint(nc.kubeClient, []*v1.Taint{&taintToAdd}, []*v1.Taint{&oppositeTaint}, node), 0 + result := nodeutil.SwapNodeControllerTaint(nc.kubeClient, []*v1.Taint{&taintToAdd}, []*v1.Taint{&oppositeTaint}, node) + if result { + //count the evictionsNumber + zone := utilnode.GetZoneKey(node) + evictionsNumber.WithLabelValues(zone).Inc() + } + + return result, 0 }) } } @@ -609,9 +613,6 @@ func (nc *Controller) doEvictionPass() { klog.Warningf("Node %v no longer present in nodeLister!", value.Value) } else if err != nil { klog.Warningf("Failed to get Node %v from the nodeLister: %v", value.Value, err) - } else { - zone := utilnode.GetZoneKey(node) - evictionsNumber.WithLabelValues(zone).Inc() } nodeUID, _ := value.UID.(string) remaining, err := nodeutil.DeletePods(nc.kubeClient, nc.recorder, value.Value, nodeUID, nc.daemonSetStore) @@ -622,6 +623,13 @@ func (nc *Controller) doEvictionPass() { if remaining { klog.Infof("Pods awaiting deletion due to Controller eviction") } + + //count the evictionsNumber + if node != nil { + zone := utilnode.GetZoneKey(node) + evictionsNumber.WithLabelValues(zone).Inc() + } + return true, 0 }) }