From: Andrew Schoen Date: Tue, 2 Oct 2018 18:50:01 +0000 (-0500) Subject: ceph-volume: if --report fails to load json, fail with better info X-Git-Tag: v3.2.0beta4~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a63ca220e6b034de01b162b3a527764512ab573c;p=ceph-ansible.git ceph-volume: if --report fails to load json, fail with better info This handles the case gracefully where --report does not return any JSON because a validator might have failed. Signed-off-by: Andrew Schoen --- diff --git a/library/ceph_volume.py b/library/ceph_volume.py index f05bab57c..2d281b1b8 100644 --- a/library/ceph_volume.py +++ b/library/ceph_volume.py @@ -285,7 +285,18 @@ def batch(module): report_cmd.extend(report_flags) rc, out, err = module.run_command(report_cmd, encoding=None) - report_result = json.loads(out) + try: + report_result = json.loads(out) + except ValueError: + result = dict( + cmd=report_cmd, + stdout=out.rstrip(b"\r\n"), + stderr=err.rstrip(b"\r\n"), + rc=rc, + changed=True, + ) + module.fail_json(msg='non-zero return code', **result) + if not report: rc, out, err = module.run_command(cmd, encoding=None) else: