From 91385e4ff6c030f36f97ca58e8dff8dd68d15453 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Wed, 24 Oct 2018 16:55:52 +0200 Subject: [PATCH] ceph_volume: better error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When loading the json, if invalid, we should fail with a meaningful error. Signed-off-by: Sébastien Han --- library/ceph_volume.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -- 2.47.3