mirror of https://github.com/ceph/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 <aschoen@redhat.com>pull/3206/head
parent
a68c680225
commit
a63ca220e6
|
@ -285,7 +285,18 @@ def batch(module):
|
|||
report_cmd.extend(report_flags)
|
||||
|
||||
rc, out, err = module.run_command(report_cmd, encoding=None)
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue