From 3d8240d9e4fa1242084b55162b873c672dd6753c Mon Sep 17 00:00:00 2001 From: Dominic Sloan-Murphy Date: Fri, 6 Dec 2024 11:39:48 +0000 Subject: [PATCH] fix(slurmctld): fix node-configured action Splits argument passed to _slurmctld.scontrol in _resume_nodes. Fixes erroneous subprocess.run call: ['scontrol', 'update nodename= state=resume'] Now corrected to: ['scontrol', 'update', 'nodename=', 'state=resume'] Action `juju run slurmd/ node-configured` no longer reports a hook error. Adds a unit test for _resume_nodes to check arguments. --- charms/slurmctld/src/charm.py | 2 +- charms/slurmctld/tests/unit/test_charm.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/charms/slurmctld/src/charm.py b/charms/slurmctld/src/charm.py index 187154d..8171f79 100755 --- a/charms/slurmctld/src/charm.py +++ b/charms/slurmctld/src/charm.py @@ -391,7 +391,7 @@ def _resume_nodes(self, nodelist: List[str]) -> None: """Run scontrol to resume the specified node list.""" nodes = ",".join(nodelist) update_cmd = f"update nodename={nodes} state=resume" - self._slurmctld.scontrol(update_cmd) + self._slurmctld.scontrol(*shlex.split(update_cmd)) @property def _cluster_name(self) -> str: diff --git a/charms/slurmctld/tests/unit/test_charm.py b/charms/slurmctld/tests/unit/test_charm.py index 29fc2bc..70532ea 100644 --- a/charms/slurmctld/tests/unit/test_charm.py +++ b/charms/slurmctld/tests/unit/test_charm.py @@ -168,3 +168,12 @@ def test_get_user_supplied_parameters(self, *_) -> None: self.harness.charm._assemble_slurm_conf().job_acct_gather_frequency, "task=30,network=40", ) + + def test_resume_nodes_valid_input(self) -> None: + """Test that the _resume_nodes method provides a valid scontrol command.""" + self.harness.charm._slurmctld.scontrol = Mock() + self.harness.charm._resume_nodes(["juju-123456-1", "tester-node", "node-three"]) + args, _ = self.harness.charm._slurmctld.scontrol.call_args + self.assertEqual( + args, ("update", "nodename=juju-123456-1,tester-node,node-three", "state=resume") + )