Skip to content

Commit e4fc52d

Browse files
committed
fix(cluster): read node readiness under check mode so the wait can judge it
The two kubectl reads that feed the wait were skipped under --check, leaving an empty node list that the wait reported as no registered node. They change nothing, so they now run in check mode.
1 parent 9601122 commit e4fc52d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎roles/github_runner_cluster/tasks/node_readiness.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
environment:
88
KUBECONFIG: "{{ github_runner_cluster_kubeconfig_path }}"
99
changed_when: false
10+
check_mode: false
1011
register: github_runner_cluster_node_readiness
1112

1213
- name: Read which nodes memory-pressure regrading has stepped down
@@ -16,4 +17,5 @@
1617
environment:
1718
KUBECONFIG: "{{ github_runner_cluster_kubeconfig_path }}"
1819
changed_when: false
20+
check_mode: false
1921
register: github_runner_cluster_nodes_stepped_down

‎tests/unit/test_cluster_wait_nodes.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def setUp(self) -> None:
7777
modules.mkdir(parents=True)
7878
(modules / "k8s.py").write_text(K8S_MODULE)
7979

80-
def wait(self) -> subprocess.CompletedProcess[str]:
80+
def wait(self, check: bool = False) -> subprocess.CompletedProcess[str]:
8181
hosts, group_vars = self.hosts(("node1", "node2", "node3"), ("agent1",))
82-
return self.run_tasks("wait_for_nodes", hosts, group_vars, limit="node1")
82+
return self.run_tasks("wait_for_nodes", hosts, group_vars, check=check, limit="node1")
8383

8484
def kubectl_calls(self) -> list[str]:
8585
return self.read_log("kubectl.log")
@@ -173,6 +173,15 @@ def test_a_cluster_holding_no_node_of_the_inventory_fails_rather_than_passing_an
173173
self.assertEqual(self.waits(), [])
174174

175175

176+
class CheckModeTest(WaitTestCase):
177+
def test_a_check_run_reads_the_nodes_and_leaves_the_wait_itself_unrun(self) -> None:
178+
self.nodes(node1="True", node2="True", node3="True", agent1="True")
179+
result = self.wait(check=True)
180+
self.assertEqual(result.returncode, 0, result.stdout)
181+
self.assertEqual(self.waits(), [])
182+
self.assertEqual(len([call for call in self.kubectl_calls() if call.startswith("get nodes")]), 2)
183+
184+
176185
class WiringTest(unittest.TestCase):
177186
def tasks(self, name: str) -> list[dict[str, Any]]:
178187
loaded: list[dict[str, Any]] = yaml.safe_load((ROLE / "tasks" / name).read_text())

0 commit comments

Comments
 (0)