From e014fda58e6a15994bd969f587c7c4ab6c66b805 Mon Sep 17 00:00:00 2001 From: lixiang Date: Sat, 20 Feb 2021 11:52:02 +0800 Subject: [PATCH] Log and README optimization for LowNodeUtilization --- README.md | 4 +++- .../strategies/lownodeutilization.go | 18 +++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b1d74700e..f670b8019 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,9 @@ the node is considered over utilized. Any node between the thresholds, `threshol considered appropriately utilized and is not considered for eviction. The threshold, `targetThresholds`, can be configured for cpu, memory, and number of pods too in terms of percentage. -These thresholds, `thresholds` and `targetThresholds`, could be tuned as per your cluster requirements. +These thresholds, `thresholds` and `targetThresholds`, could be tuned as per your cluster requirements. Note that this +strategy evicts pods from `overutilized nodes` (those with usage above `targetThresholds`) to `underutilized nodes` +(those with usage below `thresholds`), it will abort if any number of `underutilized nodes` or `overutilized nodes` is zero. **Parameters:** diff --git a/pkg/descheduler/strategies/lownodeutilization.go b/pkg/descheduler/strategies/lownodeutilization.go index a5ba19d4d..85aa3f696 100644 --- a/pkg/descheduler/strategies/lownodeutilization.go +++ b/pkg/descheduler/strategies/lownodeutilization.go @@ -115,32 +115,24 @@ func LowNodeUtilization(ctx context.Context, client clientset.Interface, strateg klog.V(1).InfoS("Criteria for a node under utilization", "CPU", thresholds[v1.ResourceCPU], "Mem", thresholds[v1.ResourceMemory], "Pods", thresholds[v1.ResourcePods]) + klog.V(1).InfoS("Number of underutilized nodes", "totalNumber", len(lowNodes)) + klog.V(1).InfoS("Criteria for a node above target utilization", + "CPU", targetThresholds[v1.ResourceCPU], "Mem", targetThresholds[v1.ResourceMemory], "Pods", targetThresholds[v1.ResourcePods]) + klog.V(1).InfoS("Number of overutilized nodes", "totalNumber", len(targetNodes)) if len(lowNodes) == 0 { klog.V(1).InfoS("No node is underutilized, nothing to do here, you might tune your thresholds further") return } - klog.V(1).InfoS("Total number of underutilized nodes", "totalNumber", len(lowNodes)) - if len(lowNodes) < strategy.Params.NodeResourceUtilizationThresholds.NumberOfNodes { klog.V(1).InfoS("Number of nodes underutilized is less than NumberOfNodes, nothing to do here", "underutilizedNodes", len(lowNodes), "numberOfNodes", strategy.Params.NodeResourceUtilizationThresholds.NumberOfNodes) return } - - if len(lowNodes) == len(nodes) { - klog.V(1).InfoS("All nodes are underutilized, nothing to do here") - return - } - if len(targetNodes) == 0 { - klog.V(1).InfoS("All nodes are under target utilization, nothing to do here") + klog.V(1).InfoS("No node is overutilized, nothing to do here, you might tune your thresholds further") return } - klog.V(1).InfoS("Criteria for a node above target utilization", - "CPU", targetThresholds[v1.ResourceCPU], "Mem", targetThresholds[v1.ResourceMemory], "Pods", targetThresholds[v1.ResourcePods]) - - klog.V(1).InfoS("Number of nodes above target utilization", "totalNumber", len(targetNodes)) evictable := podEvictor.Evictable(evictions.WithPriorityThreshold(thresholdPriority)) evictPodsFromTargetNodes(