Skip to content

Commit 556f51a

Browse files
committed
Fail early on missing Ready Worker node
Move the check of missing Ready worker node outside of the previous two functions. It simplifies the code
1 parent 156442e commit 556f51a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/e2e/far_e2e_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ var _ = Describe("FAR E2e", func() {
108108
if availableWorkerNodes == nil {
109109
availableWorkerNodes = getReadyWorkerNodes()
110110
}
111+
if len(availableWorkerNodes.Items) < 1 {
112+
Fail("There isn't an available (and Ready) worker node in the cluster")
113+
}
114+
111115
selectedNode = pickRemediatedNode(availableWorkerNodes)
112116
nodeName = selectedNode.Name
113117
printNodeDetails(selectedNode, nodeIdentifierPrefix, testNodeParam)
@@ -269,18 +273,12 @@ func getReadyWorkerNodes() *corev1.NodeList {
269273
}
270274
}
271275
}
272-
if len(readyWorkerNodes.Items) < 1 {
273-
Fail("There isn't an available (and ready) worker node in the cluster")
274-
}
275276
return readyWorkerNodes
276277
}
277278

278279
// pickRemediatedNode randomly returns a next remediated node from the current available nodes,
279280
// and then the node is removed from the list of available nodes
280281
func pickRemediatedNode(availableNodes *corev1.NodeList) *corev1.Node {
281-
if len(availableNodes.Items) < 1 {
282-
Fail("There isn't an available (and ready) worker node in the cluster")
283-
}
284282
// Generate a random seed based on the current time
285283
r := rand.New(rand.NewSource(time.Now().UnixNano()))
286284
// Randomly select a worker node

0 commit comments

Comments
 (0)