Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump ops to 2.19 and cleanup NHC installation #86

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charms/sackd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ops==2.17.1
ops~=2.19
2 changes: 1 addition & 1 deletion charms/slurmctld/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ops==2.17.1
ops~=2.19
slurmutils<1.0.0,>=0.11.0
influxdb==5.3.2
netifaces-plus==0.12.4
11 changes: 0 additions & 11 deletions charms/slurmd/dispatch

This file was deleted.

2 changes: 1 addition & 1 deletion charms/slurmd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ops==2.17.1
ops~=2.19
slurmutils<1.0.0,>=0.12.0
nvidia-ml-py==12.560.30
git+https://github.com/canonical/ubuntu-drivers-common@554b91edfd3699625dbed90f679abb31a897b76e#egg=ubuntu-drivers-common
36 changes: 25 additions & 11 deletions charms/slurmd/src/utils/nhc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,39 @@

from constants import NHC_CONFIG

import charms.operator_libs_linux.v0.apt as apt

_logger = logging.getLogger(__name__)


class Error(Exception):
"""Exception raised when a nhc operation failed."""
class NHCOpsError(Exception):
"""Exception raised when a NHC operation failed."""

@property
def message(self) -> str:
"""Return message passed as argument to exception."""
return self.args[0]


def install() -> None:
"""Install nhc on compute node.
"""Install NHC on compute node.

Raises:
subprocess.CalledProcessError: Raised if error is encountered during nhc install.
subprocess.CalledProcessError: Raised if error is encountered during NHC install.
"""
_logger.info("installing node health check (nhc)")
_logger.info("installing required packages to install Node Health Check (NHC)")

try:
apt.add_package("make")
except (apt.PackageNotFoundError, apt.PackageError) as e:
raise NHCOpsError(f"failed to install package `make`. reason: {e}")

_logger.info("installing NHC")
with tempfile.TemporaryDirectory() as tmpdir:
try:
env = {"LC_ALL": "C", "LANG": "C.UTF-8"}

_logger.info("extracting nhc tarball")
_logger.info("extracting NHC tarball")
r = subprocess.check_output(
[
"tar",
Expand All @@ -57,7 +71,7 @@ def install() -> None:
)
_logger.debug(r)

_logger.info("building nhc with autotools")
_logger.info("building NHC with autotools")
r = subprocess.check_output(
["./autogen.sh", "--prefix=/usr", "--sysconfdir=/etc", "--libexecdir=/usr/lib"],
cwd=tmpdir,
Expand All @@ -67,22 +81,22 @@ def install() -> None:
)
_logger.debug(r)

_logger.info("testing nhc build")
_logger.info("testing NHC build")
r = subprocess.check_output(
["make", "test"], cwd=tmpdir, env=env, stderr=subprocess.STDOUT, text=True
)
_logger.debug(r)

_logger.info("installing nhc")
_logger.info("installing NHC")
r = subprocess.check_output(
["make", "install"], cwd=tmpdir, env=env, stderr=subprocess.STDOUT, text=True
)
_logger.debug(r)
except subprocess.CalledProcessError as e:
_logger.error("failed to install nhc. reason: %s", e)
_logger.error("failed to install NHC. reason: %s", e)
raise

# Write the nhc.conf following nhc installation.
# Write the nhc.conf following NHC installation.
generate_config()


Expand Down
2 changes: 1 addition & 1 deletion charms/slurmdbd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==2.17.1
ops~=2.19
slurmutils<1.0.0,>=0.11.0
2 changes: 1 addition & 1 deletion charms/slurmrestd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==2.17.1
ops~=2.19
slurmutils<1.0.0,>=0.11.0
7 changes: 7 additions & 0 deletions repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ def clean_charm(
"""
logger.debug(f"Removing {charm.build_path}")
if not dry_run:
try:
subprocess.run(["charmcraft", "clean"], cwd=charm.build_path, check=True)
except FileNotFoundError as e:
logger.info("ignoring charm %s which is not staged", charm.path.name)
except subprocess.CalledProcessError as e:
logger.warning("`charmcraft clean` failed for charm %s. cause: %s", charm.path.name, e)
logger.warning("some LXD instances may remain on the system")
shutil.rmtree(charm.build_path, ignore_errors=True)
charm.charm_path.unlink(missing_ok=True)

Expand Down
Loading