From 82b9299512537b8d921caa044107472adacbdabe Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 8 May 2013 14:54:33 -0700 Subject: [PATCH] ceph-create-keys: gracefully handle no data from admin socket Old ceph-mon (prior to 393c9372f82ef37fc6497dd46fc453507a463d42) would return an empty string and success if the command was not registered yet. Gracefully handle that case by retrying. If we still fail to parse, exit entirely with EINVAL. Fixes: #4952 Signed-off-by: Sage Weil Reviewed-by: Dan Mick (cherry picked from commit e2528ae42c455c522154c9f68b5032a3362fca8e) --- src/ceph-create-keys | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ceph-create-keys b/src/ceph-create-keys index bb3967c087943..23632dd2075a4 100755 --- a/src/ceph-create-keys +++ b/src/ceph-create-keys @@ -34,7 +34,17 @@ def wait_for_quorum(cluster, mon_id): time.sleep(1) continue - data = json.loads(out) + if out == '': + LOG.info('ceph-mon admin socket returned no data') + time.sleep(1) + continue + + try: + data = json.loads(out) + except: + LOG.info('failed to parse json %s', out) + sys.exit(errno.EINVAL) + state = data['state'] if state not in QUORUM_STATES: LOG.info('ceph-mon is not in quorum: %r', state) -- 2.39.5