From dc9c2901cbf71682d9e63f627c38015faecdb752 Mon Sep 17 00:00:00 2001 From: "Jason C. Nucciarone" Date: Fri, 12 Jul 2024 21:39:38 -0400 Subject: [PATCH 1/2] fix: ensure that nhc tarball is properly primed within charm Needed to add the part `charm: {}` to make the charm pack correctly. jedel1043 and I found that this part declaration must be included in `charmcraft.yaml`, or it will fail to pack the charm correctly. nhc will be there, but the charm won't :'( Signed-off-by: Jason C. Nucciarone --- charmcraft.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/charmcraft.yaml b/charmcraft.yaml index dac7bdb..1af8322 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -34,12 +34,16 @@ bases: architectures: [amd64] parts: - charm: + charm: {} + nhc: + plugin: nil build-packages: - wget + override-pull: | + wget https://github.com/mej/nhc/releases/download/1.4.3/lbnl-nhc-1.4.3.tar.gz override-build: | - wget https://github.com/mej/nhc/releases/download/1.4.3/lbnl-nhc-1.4.3.tar.gz - craftctl default + install -m644 -D -t $CRAFT_PART_INSTALL lbnl-nhc-1.4.3.tar.gz + craftctl default provides: slurmctld: From b6236c70e8b5e859af1574e4f48d45961e6adbdc Mon Sep 17 00:00:00 2001 From: "Jason C. Nucciarone" Date: Fri, 12 Jul 2024 21:44:21 -0400 Subject: [PATCH 2/2] fix: handle if tar fails to extract contents nhc tarball Previously, if tar failed to extract the contents of the nhc tarball to `/tmp/nhc`, _install_nhc_from_tarball would throw an unhandled excepting that would cause the charm to bork. Now we catch if tar fails to extract the contents of the tarball, log the error output for the asministrator to read, and return False so that the slurmd operator can properly handle and install failure. Signed-off-by: Jason C. Nucciarone --- src/slurmd_ops.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slurmd_ops.py b/src/slurmd_ops.py index dcab81b..7b3a1b8 100644 --- a/src/slurmd_ops.py +++ b/src/slurmd_ops.py @@ -173,7 +173,12 @@ def _install_nhc_from_tarball(self) -> bool: base_path.mkdir() cmd = f"tar --extract --directory {base_path} --file lbnl-nhc-1.4.3.tar.gz".split() - subprocess.run(cmd) + try: + result = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True) + logger.debug(result) + except subprocess.CalledProcessError as e: + logger.error("failed to extract NHC using tar. reason:\n%s", e.stdout) + return False full_path = base_path / os.listdir(base_path)[0]