From: huanwen ren Date: Mon, 10 Sep 2018 11:29:20 +0000 (+0800) Subject: common: adapt to the new pg dump format. X-Git-Tag: v14.0.1~86^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5096b41ca8483bf1f2b818c05a72e3ea2ecce6e;p=ceph.git common: adapt to the new pg dump format. Signed-off-by: huanwen ren --- diff --git a/qa/workunits/rados/test_large_omap_detection.py b/qa/workunits/rados/test_large_omap_detection.py index 6a9e3f93857a..7b09dfd90718 100755 --- a/qa/workunits/rados/test_large_omap_detection.py +++ b/qa/workunits/rados/test_large_omap_detection.py @@ -73,7 +73,11 @@ def get_deep_scrub_timestamp(pgid): cmd = ['ceph', 'pg', 'dump', '--format=json-pretty'] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) out = proc.communicate()[0] - for stat in json.loads(out)['pg_stats']: + try: + pgstats = json.loads(out)['pg_map']['pg_stats'] + except KeyError: + pgstats = json.loads(out)['pg_stats'] + for stat in pgstats: if stat['pgid'] == pgid: return stat['last_deep_scrub_stamp'] diff --git a/src/ceph.in b/src/ceph.in index ac610d14c3c7..23070e703bd5 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -836,7 +836,11 @@ def get_scrub_timestamps(childargs): devnull = open(os.devnull, 'w') out = subprocess.check_output(['ceph', 'pg', 'dump', '--format=json-pretty'], stderr=devnull) - for stat in json.loads(out)['pg_stats']: + try: + pgstats = json.loads(out)['pg_map']['pg_stats'] + except KeyError: + pgstats = json.loads(out)['pg_stats'] + for stat in pgstats: if scruball or stat['up_primary'] == int(childargs[2]): scrub_tuple = (stat['up_primary'], stat[last_scrub_stamp]) results[stat['pgid']] = scrub_tuple