Skip to content

Commit

Permalink
fix(slurmctld): fix node-configured action
Browse files Browse the repository at this point in the history
Splits argument passed to _slurmctld.scontrol in _resume_nodes.
Fixes erroneous subprocess.run call:

  ['scontrol', 'update nodename=<nodes> state=resume']

Now corrected to:

  ['scontrol', 'update', 'nodename=<nodes>', 'state=resume']

Action `juju run slurmd/<id> node-configured` no longer reports a
hook error.

Adds a unit test for _resume_nodes to check arguments.
  • Loading branch information
dsloanm committed Dec 6, 2024
1 parent 274fc85 commit d45dd8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charms/slurmctld/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions charms/slurmctld/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit d45dd8a

Please sign in to comment.