From 4205560e41db060c9a3c5d771e24a2ef1915ae30 Mon Sep 17 00:00:00 2001 From: jamesbeedy Date: Tue, 20 Aug 2024 19:30:11 +0000 Subject: [PATCH] fix(slurmctld): correctly parse nested config 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 --- charms/slurmctld/src/charm.py | 2 +- charms/slurmctld/tests/unit/test_charm.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/charms/slurmctld/src/charm.py b/charms/slurmctld/src/charm.py index 8e75863..4e0aa92 100755 --- a/charms/slurmctld/src/charm.py +++ b/charms/slurmctld/src/charm.py @@ -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() != "" } diff --git a/charms/slurmctld/tests/unit/test_charm.py b/charms/slurmctld/tests/unit/test_charm.py index a8fe7e3..d592e97 100644 --- a/charms/slurmctld/tests/unit/test_charm.py +++ b/charms/slurmctld/tests/unit/test_charm.py @@ -171,3 +171,13 @@ 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.update_config( + {"slurm-conf-parameters": "JobAcctGatherFrequency=task=30,network=40"} + ) + self.assertEqual( + self.harness.charm._assemble_slurm_conf()["JobAcctGatherFrequency"], + "task=30,network=40", + )