From 40a67b1b4abcbe5e388ef9bb1e0a7b3e252994ee Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Wed, 29 Sep 2021 10:18:03 +0300 Subject: [PATCH] tools/crushdiff: support old format json dump Someone may try running crushdiff against osdmap and pg dump collected for an older cluster. In general it is not guaranteed to work as not tested well, but still we can do our best to make it work if possible. One know issue is that for older versions `ceph pg dump` json output does not have a separate 'pg_map' section, where actual data is stored. This change makes crushdiff to support this old format too. Signed-off-by: Mykola Golub --- src/tools/crushdiff | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/crushdiff b/src/tools/crushdiff index ca9173379731..4b0b71bed43e 100755 --- a/src/tools/crushdiff +++ b/src/tools/crushdiff @@ -104,7 +104,8 @@ def get_erasure_code_profiles(osdmap): def get_pgmap(pg_dump_file): with open(pg_dump_file, "r") as f: - return json.load(f)['pg_map'] + dump = json.load(f) + return dump.get('pg_map', dump) def get_pg_stats(pgmap): return {pg['pgid']: pg for pg in pgmap['pg_stats']} -- 2.47.3