Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
fix: handle if tar fails to extract contents nhc tarball
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
NucciTheBoss committed Jul 13, 2024
1 parent dc9c290 commit b6236c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/slurmd_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit b6236c7

Please sign in to comment.