]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/crushdiff: support old format json dump 43343/head
authorMykola Golub <mykola.golub@clyso.com>
Wed, 29 Sep 2021 07:18:03 +0000 (10:18 +0300)
committerMykola Golub <mykola.golub@clyso.com>
Wed, 29 Sep 2021 07:18:03 +0000 (10:18 +0300)
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 <mykola.golub@clyso.com>
src/tools/crushdiff

index ca9173379731d787e9aca0b595a26afd150eedc4..4b0b71bed43e1fcecdacb6074f06ef2163c870b9 100755 (executable)
@@ -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']}