Skip to content

Commit

Permalink
fix(slurm_ops): manadate that config server is provided in service file
Browse files Browse the repository at this point in the history
Require the `--conf-server` to be provided for start-up. Variable
substitution cannot be used in environment files. Declared environment
variables are treated as independent key-value pairs.

Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Dec 6, 2024
1 parent a340fdd commit 18db3f6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions lib/charms/hpc_libs/v0/slurm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,19 +657,26 @@ def _apply_overrides(self) -> None:
"""Override defaults supplied provided by Slurm Debian packages."""
match self._service_name:
case "sackd":
# TODO: https://github.com/charmed-hpc/hpc-libs/issues/54 -
# Make `sackd` create its service environment file so that we
# aren't required to manually create it here.
_logger.debug("creating sackd environment file")
self._env_file.touch(mode=0o644, exist_ok=True)
self._env_file.write_text(
_logger.debug("overriding default sackd service configuration")
config_override = Path(
"/etc/systemd/system/sackd.service.d/10-sackd-config-server.conf"
)
config_override.parent.mkdir(parents=True, exist_ok=True)
config_override.write_text(
textwrap.dedent(
"""
SACKD_CONFIG_SERVER=''
SACKD_OPTIONS="${SACKD_CONFIG_SERVER:+--conf-server $SACKD_CONFIG_SERVER}"
[Service]
ExecStart=
ExecStart=/usr/sbin/sackd --systemd --conf-server $SACKD_CONFIG_SERVER
"""
)
)

# TODO: https://github.com/charmed-hpc/hpc-libs/issues/54 -
# Make `sackd` create its service environment file so that we
# aren't required to manually create it here.
_logger.debug("creating sackd environment file")
self._env_file.touch(mode=0o644, exist_ok=True)
case "slurmctld":
_logger.debug("overriding default slurmctld service configuration")
self._set_ulimit()
Expand Down Expand Up @@ -914,8 +921,7 @@ def __init__(self, *args, **kwargs) -> None:
@property
def config_server(self) -> str | None:
"""Get the configuration server address of this `sackd` node."""
result = self._env_manager.get("SACKD_CONFIG_SERVER")
return None if result == "" else result
return self._env_manager.get("SACKD_CONFIG_SERVER")

@config_server.setter
def config_server(self, addr: str) -> None:
Expand All @@ -927,15 +933,8 @@ def config_server(self, addr: str) -> None:

@config_server.deleter
def config_server(self) -> None:
"""Unset the configuration server address of this `sackd` node.
Warnings:
The `SACKD_CONFIG_SERVER` is set to an emtpy string rather than
deleted from the environment file to preserve the line order necessary
to successfully use variable substitution within the `SACKD_OPTIONS`
environment variable.
"""
self._env_manager.set({"SACKD_CONFIG_SERVER": ""})
"""Unset the configuration server address of this `sackd` node."""
self._env_manager.unset("SACKD_CONFIG_SERVER")


class SlurmctldManager(_SlurmManagerBase):
Expand Down

0 comments on commit 18db3f6

Please sign in to comment.