]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: do not omit shard when ghobject NO_GEN is set
authorLoic Dachary <ldachary@redhat.com>
Fri, 14 Nov 2014 00:16:10 +0000 (01:16 +0100)
committerLoic Dachary <ldachary@redhat.com>
Sat, 15 Nov 2014 22:27:15 +0000 (23:27 +0100)
Do not silence the display of shard_id when generation is NO_GEN.
Erasure coded objects JSON representation used by ceph_objectstore_tool
need the shard_id to find the file containing the chunk.

Minimal testing is added to ceph_objectstore_tool.py

http://tracker.ceph.com/issues/10063 Fixes: #10063

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/common/hobject.cc
src/test/ceph_objectstore_tool.py

index 0abe59a0174f0497bb07c170b88093dc62f29e06..00b00195601dde4b34f59f108b65844183a34374 100644 (file)
@@ -252,10 +252,10 @@ void ghobject_t::decode(json_spirit::Value& v)
 void ghobject_t::dump(Formatter *f) const
 {
   hobj.dump(f);
-  if (generation != NO_GEN) {
+  if (generation != NO_GEN)
     f->dump_int("generation", generation);
+  if (shard_id != shard_id_t::NO_SHARD)
     f->dump_int("shard_id", shard_id);
-  }
 }
 
 void ghobject_t::generate_test_instances(list<ghobject_t*>& o)
index 407222e135c8f4331ecc02fb0a83b178c0b43ea6..3185a5ac1f34a87843a0368dce5addb714fef421 100755 (executable)
@@ -2,6 +2,7 @@
 
 from subprocess import call
 from subprocess import check_output
+import subprocess
 import os
 import time
 import sys
@@ -562,6 +563,31 @@ def main(argv):
         for basename in db[nspace].keys():
             file = os.path.join(DATADIR, nspace + "-" + basename)
             JSON = db[nspace][basename]['json']
+            jsondict = json.loads(JSON)
+
+            if 'shard_id' in jsondict:
+                logging.debug("ECobject " + JSON)
+                found = 0
+                for pg in OBJECPGS:
+                    OSDS = get_osds(pg, OSDDIR)
+                    # Fix shard_id since we only have one json instance for each object
+                    jsondict['shard_id'] = int(string.split(pg, 's')[1])
+                    JSON = json.dumps(jsondict)
+                    for osd in OSDS:
+                        cmd = (CFSD_PREFIX + "--pgid {pg} '{json}' get-attr hinfo_key").format(osd=osd, pg=pg, json=JSON)
+                        logging.debug("TRY: " + cmd)
+                        try:
+                            out = check_output(cmd, shell=True, stderr=subprocess.STDOUT)
+                            logging.debug("FOUND: {json} in {osd} has value '{val}'".format(osd=osd, json=JSON, val=out))
+                            found += 1
+                        except subprocess.CalledProcessError, e:
+                            if "No such file or directory" not in e.output and "No data available" not in e.output:
+                                raise
+                # Assuming k=2 m=1 for the default ec pool
+                if found != 3:
+                    logging.error("{json} hinfo_key found {found} times instead of 3".format(json=JSON, found=found))
+                    ERRORS += 1
+
             for pg in OBJREPPGS:
                 OSDS = get_osds(pg, OSDDIR)
                 for osd in OSDS: