diff --git a/charms/slurmctld/charmcraft.yaml b/charms/slurmctld/charmcraft.yaml index 81679c5..13808de 100644 --- a/charms/slurmctld/charmcraft.yaml +++ b/charms/slurmctld/charmcraft.yaml @@ -30,6 +30,10 @@ requires: slurmrestd: interface: slurmrestd +peers: + slurmctld-peer: + interface: slurmctld-peer + assumes: - juju diff --git a/charms/slurmctld/src/charm.py b/charms/slurmctld/src/charm.py index 8e75863..f552cf1 100755 --- a/charms/slurmctld/src/charm.py +++ b/charms/slurmctld/src/charm.py @@ -9,7 +9,8 @@ import subprocess from typing import Any, Dict, List, Optional, Union -from constants import CHARM_MAINTAINED_SLURM_CONF_PARAMETERS, SLURM_CONF_PATH +from constants import CHARM_MAINTAINED_SLURM_CONF_PARAMETERS, PEER_RELATION, SLURM_CONF_PATH +from custom_exceptions import IngressAddressUnavailableError from interface_slurmd import ( PartitionAvailableEvent, PartitionUnavailableEvent, @@ -307,7 +308,7 @@ def _assemble_slurmctld_parameters() -> str: slurm_conf = { "ClusterName": self.cluster_name, - "SlurmctldAddr": self._slurmd_ingress_address, + "SlurmctldAddr": self._ingress_address, "SlurmctldHost": self.hostname, "SlurmctldParameters": _assemble_slurmctld_parameters(), "ProctrackType": "proctrack/linuxproc" if is_container() else "proctrack/cgroup", @@ -403,12 +404,15 @@ def hostname(self) -> str: return self._slurmctld_manager.hostname @property - def _slurmd_ingress_address(self) -> str: - """Return the ingress_address from the slurmd relation if it exists.""" - ingress_address = "" - if binding := self.model.get_binding("slurmd"): - ingress_address = f"{binding.network.ingress_address}" - return ingress_address + def _ingress_address(self) -> str: + """Return the ingress_address from the peer relation if it exists.""" + if (peer_binding := self.model.get_binding(PEER_RELATION)) is not None: + logger.debug( + "Getting ingress_address: %s", + peer_binding.network.ingress_address, + ) + return str(peer_binding.network.ingress_address) + raise IngressAddressUnavailableError @property def slurm_installed(self) -> bool: diff --git a/charms/slurmctld/src/constants.py b/charms/slurmctld/src/constants.py index 1890c15..6390e3e 100644 --- a/charms/slurmctld/src/constants.py +++ b/charms/slurmctld/src/constants.py @@ -3,6 +3,8 @@ """This module provides constants for the slurmctld-operator charm.""" from pathlib import Path +PEER_RELATION = "slurmctld-peer" + SLURM_CONF_PATH = Path("/etc/slurm/slurm.conf") SLURM_USER = "slurm" SLURM_GROUP = "slurm"