From: Sébastien Han Date: Wed, 24 Oct 2018 14:55:52 +0000 (+0200) Subject: ceph_volume: better error handling X-Git-Tag: v3.2.0rc1~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91385e4ff6c030f36f97ca58e8dff8dd68d15453;p=ceph-ansible.git ceph_volume: better error handling When loading the json, if invalid, we should fail with a meaningful error. Signed-off-by: Sébastien Han --- diff --git a/library/ceph_volume.py b/library/ceph_volume.py index 92413c017..b07c1d43b 100644 --- a/library/ceph_volume.py +++ b/library/ceph_volume.py @@ -518,8 +518,12 @@ def run_module(): # see: http://tracker.ceph.com/issues/36329 # FIXME: it's probably less confusing to check for rc - # convert out to json, ansible return a string... - out_dict = json.loads(out) + # convert out to json, ansible returns a string... + try: + out_dict = json.loads(out) + except ValueError: + fatal("Could not decode json output: {} from the command {}".format(out, cmd), module) # noqa E501 + if out_dict: data = module.params['data'] result['stdout'] = 'skipped, since {0} is already used for an osd'.format( # noqa E501