From 57a28e9a8f25cfea1a788ebd400c6d6d3e374676 Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Mon, 23 Apr 2018 17:13:19 -0400 Subject: [PATCH] Fix dryRun issue and avoid unnecessary log msg when node affinity strategy is disabled. --- pkg/descheduler/strategies/node_affinity.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/descheduler/strategies/node_affinity.go b/pkg/descheduler/strategies/node_affinity.go index 35881edc5..b8c35088a 100644 --- a/pkg/descheduler/strategies/node_affinity.go +++ b/pkg/descheduler/strategies/node_affinity.go @@ -27,8 +27,7 @@ import ( ) func RemovePodsViolatingNodeAffinity(ds *options.DeschedulerServer, strategy api.DeschedulerStrategy, evictionPolicyGroupVersion string, nodes []*v1.Node, nodePodCount nodePodEvictedCount) { - evictionCount := removePodsViolatingNodeAffinityCount(ds, strategy, evictionPolicyGroupVersion, nodes, nodePodCount, ds.MaxNoOfPodsToEvictPerNode) - glog.V(1).Infof("Evicted %v pods", evictionCount) + removePodsViolatingNodeAffinityCount(ds, strategy, evictionPolicyGroupVersion, nodes, nodePodCount, ds.MaxNoOfPodsToEvictPerNode) } func removePodsViolatingNodeAffinityCount(ds *options.DeschedulerServer, strategy api.DeschedulerStrategy, evictionPolicyGroupVersion string, nodes []*v1.Node, nodepodCount nodePodEvictedCount, maxPodsToEvict int) int { @@ -58,7 +57,7 @@ func removePodsViolatingNodeAffinityCount(ds *options.DeschedulerServer, strateg if !nodeutil.PodFitsCurrentNode(pod, node) && nodeutil.PodFitsAnyNode(pod, nodes) { glog.V(1).Infof("Evicting pod: %v", pod.Name) - evictions.EvictPod(ds.Client, pod, evictionPolicyGroupVersion, false) + evictions.EvictPod(ds.Client, pod, evictionPolicyGroupVersion, ds.DryRun) nodepodCount[node]++ } } @@ -70,5 +69,6 @@ func removePodsViolatingNodeAffinityCount(ds *options.DeschedulerServer, strateg return evictedPodCount } } + glog.V(1).Infof("Evicted %v pods", evictedPodCount) return evictedPodCount }