Skip to content

Commit

Permalink
add common packages to slurmd and slurmctld
Browse files Browse the repository at this point in the history
These changes install nfs-common, openmpi-bin, and libpmix-dev to
slurmd and nfs-common to slurmctld.

Fixes: #23
  • Loading branch information
jamesbeedy committed Sep 3, 2024
1 parent 4ddc566 commit 7674307
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
25 changes: 24 additions & 1 deletion charms/slurmctld/src/slurmctld_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,38 @@ def version(self) -> str:
return slurm_package_vers


class CommonPackagesLifecycleManager:
"""Facilitate common package lifecycles."""

def install(self) -> bool:
"""Install package using lib apt."""
package_installed = False

try:
apt.update()
apt.add_package(["nfs-common"])
package_installed = True
except apt.PackageNotFoundError:
logger.error("Package not found in package cache or on system.")
except apt.PackageError as e:
logger.error(f"Could not install package. Reason: {e.message}")

return package_installed


class SlurmctldManager:
"""SlurmctldManager."""

def __init__(self):
self._munge_package = CharmedHPCPackageLifecycleManager("munge")
self._slurmctld_package = CharmedHPCPackageLifecycleManager("slurmctld")
self._common_packages = CommonPackagesLifecycleManager()

def install(self) -> bool:
"""Install slurmctld and munge to the system."""
"""Install slurmctld, munge, and common packages to the system."""
if self._common_packages.install() is not True:
return False

if self._slurmctld_package.install() is not True:
return False
systemd.service_stop("slurmctld")
Expand Down
27 changes: 26 additions & 1 deletion charms/slurmd/src/slurmd_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,41 @@ def version(self) -> str:
return slurm_package_vers


class CommonPackagesLifecycleManager:
"""Facilitate common package lifecycles."""

def install(self) -> bool:
"""Install package using lib apt."""
package_installed = False

try:
apt.update()
apt.add_package(["nfs-common", "libpmix-dev", "openmpi-bin"])
package_installed = True
except apt.PackageNotFoundError:
logger.error("Package not found in package cache or on system.")
except apt.PackageError as e:
logger.error(f"Could not install package. Reason: {e.message}")

return package_installed


class SlurmdManager:
"""SlurmdManager."""

def __init__(self):
self._munge_package = CharmedHPCPackageLifecycleManager("munge")
self._slurmd_package = CharmedHPCPackageLifecycleManager("slurmd")
self._slurm_client_package = CharmedHPCPackageLifecycleManager("slurm-client")
self._common_packages = CommonPackagesLifecycleManager()

def install(self) -> bool:
"""Install slurmd, slurm-client and munge packages to the system."""
"""Install slurmd, slurm-client, munge, and common packages to the system."""

if self._common_packages.install() is not True:
logger.debug("Cannot install common packages.")
return False

if self._slurmd_package.install() is not True:
logger.debug("Cannot install 'slurmd' package.")
return False
Expand Down

0 comments on commit 7674307

Please sign in to comment.