Skip to content

Commit

Permalink
Add toleration to the remediation taint for the boot pod
Browse files Browse the repository at this point in the history
The pod is failing to have a ready status since the remediation taint with NoExecute effect evict it every time
  • Loading branch information
razo7 committed Jun 22, 2023
1 parent 173a161 commit b08bf77
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/e2e/utils/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
},
},
},
}
}

0 comments on commit b08bf77

Please sign in to comment.