Skip to content

Commit

Permalink
fix(slurmctld): correctly parse nested config
Browse files Browse the repository at this point in the history
These changes modify the user supplied config parser so that
it correctly handles nested user supplied configuration values.

Accompanying test to show nested configuration is parsed correctly
in test_charm.py

Fixes #14
  • Loading branch information
jamesbeedy authored and NucciTheBoss committed Aug 20, 2024
1 parent 86e1b47 commit 4ddc566
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -326,7 +326,7 @@ def _get_user_supplied_parameters(self) -> Dict[Any, Any]:
user_supplied_parameters = {}
if custom_config := self.config.get("slurm-conf-parameters"):
user_supplied_parameters = {
line.split("=")[0]: line.split("=")[1]
line.split("=")[0]: line.split("=", 1)[1]
for line in str(custom_config).split("\n")
if not line.startswith("#") and line.strip() != ""
}
Expand Down
11 changes: 11 additions & 0 deletions charms/slurmctld/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,14 @@ def test_on_slurmdbd_unavailable(self) -> None:
"""Test that the on_slurmdbd_unavailable method works."""
self.harness.charm._slurmdbd.on.slurmdbd_unavailable.emit()
self.assertEqual(self.harness.charm._stored.slurmdbd_host, "")

def test_get_user_supplied_parameters(self) -> None:
"""Test that user supplied parameters are parsed correctly."""
self.harness.add_relation("slurmd", "slurmd")
self.harness.update_config(
{"slurm-conf-parameters": "JobAcctGatherFrequency=task=30,network=40"}
)
self.assertEqual(
self.harness.charm._assemble_slurm_conf()["JobAcctGatherFrequency"],
"task=30,network=40",
)

0 comments on commit 4ddc566

Please sign in to comment.