From: Andrew Schoen Date: Thu, 18 Jan 2018 20:25:46 +0000 (-0600) Subject: ceph-volume: allow passing a fail_msg param to process.run X-Git-Tag: v12.2.3~79^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5f98bc964b2ef05110363c70507048c85e33fa8c;p=ceph.git ceph-volume: allow passing a fail_msg param to process.run This will allow the user to provide a more detailed error message on why the command failed. Signed-off-by: Andrew Schoen (cherry picked from commit 7204851042fa42799e1003ef57d57a512d4a7f28) Conflicts: src/ceph-volume/ceph_volume/process.py --- diff --git a/src/ceph-volume/ceph_volume/process.py b/src/ceph-volume/ceph_volume/process.py index 4b6a9c28474..d34aff2bb29 100644 --- a/src/ceph-volume/ceph_volume/process.py +++ b/src/ceph-volume/ceph_volume/process.py @@ -96,10 +96,12 @@ def run(command, **kw): :param command: The command to pass in to the remote subprocess.Popen as a list :param stop_on_error: If a nonzero exit status is return, it raises a ``RuntimeError`` + :param fail_msg: If a nonzero exit status is returned this message will be included in the log """ stop_on_error = kw.pop('stop_on_error', True) command_msg = obfuscate(command, kw.pop('obfuscate', None)) stdin = kw.pop('stdin', None) + fail_msg = kw.pop('fail_msg', None) logger.info(command_msg) terminal.write(command_msg) terminal_logging = kw.pop('terminal_logging', True) @@ -131,6 +133,10 @@ def run(command, **kw): returncode = process.wait() if returncode != 0: msg = "command returned non-zero exit status: %s" % returncode + if fail_msg: + logger.warning(fail_msg) + if terminal_logging: + terminal.warning(fail_msg) if stop_on_error: raise RuntimeError(msg) else: