Skip to content

Commit 508f0af

Browse files
committed
e2e/loadbalancer: skip unschedulable nodes during discovery
Skip unsupported or unscheduled worker nodes when discovering candidates for load balancer scenarios. Some tests, such as hairpin traffic, discover worker nodes using the node-role.kubernetes.io label. If a discovered node has NoSchedule or NoExecute taints, the test fails because the workload is implemented generically and does not define specific tolerations. Filtering these nodes during discovery ensures the test selects a candidate capable of hosting the workload without requiring changes to the test's pod specification.
1 parent 1243690 commit 508f0af

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/e2e/loadbalancer.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,22 @@ func (e2e *e2eTestConfig) buildDeployment(affinity bool) func(deployment *appsv1
557557
}
558558
}
559559

560+
// isNodeSchedulable checks if a node is schedulable by checking if it has any taints that prevent scheduling pods.
561+
func (e2e *e2eTestConfig) isNodeSchedulable(node *v1.Node) bool {
562+
if node == nil {
563+
return false
564+
}
565+
if len(node.Spec.Taints) == 0 {
566+
return true
567+
}
568+
for _, taint := range node.Spec.Taints {
569+
if taint.Effect == v1.TaintEffectNoSchedule || taint.Effect == v1.TaintEffectNoExecute {
570+
return false
571+
}
572+
}
573+
return true
574+
}
575+
560576
// discoverClusterWorkerNode identifies and selects worker nodes in the cluster based on predefined node label selectors.
561577
// It returns a ClusterNodeDiscovery struct with the discovered information.
562578
func (e2e *e2eTestConfig) discoverClusterWorkerNode() {
@@ -569,6 +585,10 @@ func (e2e *e2eTestConfig) discoverClusterWorkerNode() {
569585
framework.ExpectNoError(err, "failed to list worker nodes")
570586
if len(nodeList.Items) > 0 {
571587
for _, node := range nodeList.Items {
588+
if !isNodeSchedulable {
589+
framework.Logf("skipping node %s because it has taints: %v", node.Name, node.Spec.Taints)
590+
continue
591+
}
572592
workerNodeList = append(workerNodeList, node.Name)
573593
}
574594
// Save the first worker node in the list to be used in cases.

0 commit comments

Comments
 (0)