From d78e4b0ca1a10d12409fbef9c0b2e39ee260ac3d Mon Sep 17 00:00:00 2001 From: Suleyman Akbas Date: Thu, 23 Nov 2023 12:57:38 +0100 Subject: [PATCH] fix: take tolerations into consideration for readiness check Signed-off-by: Suleyman Akbas --- controllers/lvmcluster_controller.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/controllers/lvmcluster_controller.go b/controllers/lvmcluster_controller.go index 81e693178..e32b1a026 100644 --- a/controllers/lvmcluster_controller.go +++ b/controllers/lvmcluster_controller.go @@ -309,17 +309,17 @@ func (r *LVMClusterReconciler) getExpectedVGCount(ctx context.Context, instance } for _, deviceClass := range instance.Spec.Storage.DeviceClasses { - for i := range nodeList.Items { - ignoreDueToNoSchedule := false - for _, taint := range nodeList.Items[i].Spec.Taints { - if taint.Effect == corev1.TaintEffectNoSchedule { - r.Log.V(1).Info("even though node selector matches, NoSchedule forces ignore of the Node", - "node", nodeList.Items[i].GetName()) - ignoreDueToNoSchedule = true + for _, node := range nodeList.Items { + ignoreDueToTaint := false + for _, taint := range node.Spec.Taints { + if !corev1helper.TolerationsTolerateTaint(instance.Spec.Tolerations, &taint) { + r.Log.V(1).Info("node is ignored because of the taint", + "node", node.GetName(), "taint", taint) + ignoreDueToTaint = true break } } - if ignoreDueToNoSchedule { + if ignoreDueToTaint { continue } @@ -328,7 +328,7 @@ func (r *LVMClusterReconciler) getExpectedVGCount(ctx context.Context, instance continue } - matches, err := corev1helper.MatchNodeSelectorTerms(&nodeList.Items[i], deviceClass.NodeSelector) + matches, err := corev1helper.MatchNodeSelectorTerms(&node, deviceClass.NodeSelector) if err != nil { r.Log.Error(err, "failed to match node selector") return 0, err