From b08bf778038a37032b3381a890b1439db033e175 Mon Sep 17 00:00:00 2001 From: razo7 Date: Thu, 22 Jun 2023 18:54:15 +0300 Subject: [PATCH] Add toleration to the remediation taint for the boot pod The pod is failing to have a ready status since the remediation taint with NoExecute effect evict it every time --- test/e2e/utils/command.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/e2e/utils/command.go b/test/e2e/utils/command.go index dc88b759..7fe038c0 100644 --- a/test/e2e/utils/command.go +++ b/test/e2e/utils/command.go @@ -20,6 +20,8 @@ import ( "k8s.io/client-go/tools/remotecommand" "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client/config" + + "github.com/medik8s/fence-agents-remediation/api/v1alpha1" ) // GetBootTime gets the boot time of the given node by running a pod on it executing uptime command @@ -49,6 +51,7 @@ func RunCommandInCluster(c *kubernetes.Clientset, nodeName string, ns string, co err = waitForCondition(c, pod, corev1.PodReady, corev1.ConditionTrue, time.Minute) if err != nil { + log.Error(err, "helper pod isn't ready") return "", err } @@ -127,9 +130,8 @@ func execCommandOnPod(c *kubernetes.Clientset, pod *corev1.Pod, command []string // waitForCondition waits until the pod will have specified condition type with the expected status func waitForCondition(c *kubernetes.Clientset, pod *corev1.Pod, conditionType corev1.PodConditionType, conditionStatus corev1.ConditionStatus, timeout time.Duration) error { return wait.PollImmediate(time.Second, timeout, func() (bool, error) { - updatedPod := &corev1.Pod{} - var err error - if updatedPod, err = c.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}); err != nil { + updatedPod, err := c.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}) + if err != nil { return false, err } for _, c := range updatedPod.Status.Conditions { @@ -168,6 +170,13 @@ func getPod(nodeName string) *corev1.Pod { Command: []string{"sleep", "2m"}, }, }, + Tolerations: []corev1.Toleration{ + { + Key: v1alpha1.FARNoExecuteTaintKey, + Operator: corev1.TolerationOpEqual, + Effect: corev1.TaintEffectNoExecute, + }, + }, }, } }