]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph_volume: better error handling
authorSébastien Han <seb@redhat.com>
Wed, 24 Oct 2018 14:55:52 +0000 (16:55 +0200)
committerSébastien Han <seb@redhat.com>
Fri, 26 Oct 2018 09:19:24 +0000 (11:19 +0200)
When loading the json, if invalid, we should fail with a meaningful
error.

Signed-off-by: Sébastien Han <seb@redhat.com>
library/ceph_volume.py

index 92413c017e248f83d22dc77f9316ed8ad99c17b0..b07c1d43b4c5662032ef40a657947b23ae9e413f 100644 (file)
@@ -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