From 448dc4784ce720207b20f25b0e368b3edc0951d7 Mon Sep 17 00:00:00 2001 From: prune Date: Thu, 10 Mar 2022 08:05:42 -0500 Subject: [PATCH] add conflicting taint to the logs log when count mismatch simplified logic to log blocking taints --- pkg/utils/pod.go | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/pkg/utils/pod.go b/pkg/utils/pod.go index c252888ea..245d7bee2 100644 --- a/pkg/utils/pod.go +++ b/pkg/utils/pod.go @@ -207,12 +207,31 @@ func maxResourceList(list, new v1.ResourceList) { // PodToleratesTaints returns true if a pod tolerates one node's taints func PodToleratesTaints(pod *v1.Pod, taintsOfNodes map[string][]v1.Taint) bool { - for nodeName, taintsForNode := range taintsOfNodes { - if len(pod.Spec.Tolerations) >= len(taintsForNode) && TolerationsTolerateTaintsWithFilter(pod.Spec.Tolerations, taintsForNode, nil) { - return true - } - klog.V(5).InfoS("Pod doesn't tolerate nodes taint", "pod", klog.KObj(pod), "nodeName", nodeName) - } + for nodeName, taintsForNode := range taintsOfNodes { + if len(pod.Spec.Tolerations) >= len(taintsForNode) { + + if TolerationsTolerateTaintsWithFilter(pod.Spec.Tolerations, taintsForNode, nil) { + return true + } + + if klog.V(5).Enabled() { + for i := range taintsForNode { + if !TolerationsTolerateTaint(pod.Spec.Tolerations, &taintsForNode[i]) { + klog.V(5).InfoS("Pod doesn't tolerate node taint", + "pod", klog.KObj(pod), + "nodeName", nodeName, + "taint", fmt.Sprintf("%s:%s=%s", taintsForNode[i].Key, taintsForNode[i].Value, taintsForNode[i].Effect), + ) + } + } + } + } else { + klog.V(5).InfoS("Pod doesn't tolerate nodes taint, count mismatch", + "pod", klog.KObj(pod), + "nodeName", nodeName, + ) + } + } return false }