From f0102f2d3f4ca252860cdee8a397183fab56d2d5 Mon Sep 17 00:00:00 2001 From: "Jason C. Nucciarone" Date: Fri, 12 Jul 2024 21:44:21 -0400 Subject: [PATCH] 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]