]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
workunits/rgw: reshard cleans empty name entries 45304/head
authorDan van der Ster <daniel.vanderster@cern.ch>
Wed, 30 Mar 2022 08:55:49 +0000 (10:55 +0200)
committerDan van der Ster <daniel.vanderster@cern.ch>
Thu, 7 Apr 2022 16:12:06 +0000 (18:12 +0200)
Check that reshard prunes olh entries with empty name.

Fixes: https://tracker.ceph.com/issues/54500
Signed-off-by: Dan van der Ster <daniel.vanderster@cern.ch>
qa/workunits/rgw/olh_noname_key [new file with mode: 0644]
qa/workunits/rgw/olh_noname_val [new file with mode: 0644]
qa/workunits/rgw/test_rgw_reshard.py

diff --git a/qa/workunits/rgw/olh_noname_key b/qa/workunits/rgw/olh_noname_key
new file mode 100644 (file)
index 0000000..6138c57
--- /dev/null
@@ -0,0 +1 @@
+\801001_04/57/0457f727ec113e418d5b16d206b200ed068c0533554883ce811df7c932a3df68/2018_12_11/2889999/3386469/metadata.gz
\ No newline at end of file
diff --git a/qa/workunits/rgw/olh_noname_val b/qa/workunits/rgw/olh_noname_val
new file mode 100644 (file)
index 0000000..ff442e1
Binary files /dev/null and b/qa/workunits/rgw/olh_noname_val differ
index 61e92b990459790906b5115130e8e36530befd61..400994e476fe221f1635a109ed0a1f3130a505ad 100755 (executable)
@@ -6,6 +6,7 @@ import subprocess
 import json
 import boto3
 import botocore.exceptions
+import os
 
 """
 Rgw manual and dynamic resharding  testing against a running instance
@@ -30,6 +31,7 @@ SECRET_KEY = 'LnEsqNNqZIpkzauboDcLXLcYaWwLQ3Kop0zAnKIn'
 BUCKET_NAME1 = 'myfoo'
 BUCKET_NAME2 = 'mybar'
 VER_BUCKET_NAME = 'myver'
+INDEX_POOL = 'default.rgw.buckets.index'
 
 
 def exec_cmd(cmd):
@@ -219,6 +221,35 @@ def main():
     new_ver_bucket_acl = connection.BucketAcl(VER_BUCKET_NAME).load()
     assert new_ver_bucket_acl == ver_bucket_acl
 
+    # TESTCASE 'check reshard removes olh entries with empty name'
+    log.debug(' test: reshard removes olh entries with empty name')
+    bucket1.objects.all().delete()
+
+    # get name of shard 0 object, add a bogus olh entry with empty name
+    bucket_shard0 = '.dir.%s.0' % get_bucket_stats(BUCKET_NAME1).bucket_id
+    if 'CEPH_ROOT' in os.environ:
+      k = '%s/qa/workunits/rgw/olh_noname_key' % os.environ['CEPH_ROOT']
+      v = '%s/qa/workunits/rgw/olh_noname_val' % os.environ['CEPH_ROOT']
+    else:
+      k = 'olh_noname_key'
+      v = 'olh_noname_val'
+    exec_cmd('rados -p %s setomapval %s --omap-key-file %s < %s' % (INDEX_POOL, bucket_shard0, k, v))
+
+    # check that bi list has one entry with empty name
+    cmd = exec_cmd('radosgw-admin bi list --bucket %s' % BUCKET_NAME1)
+    json_op = json.loads(cmd.decode('utf-8', 'ignore')) # ignore utf-8 can't decode 0x80
+    assert len(json_op) == 1
+    assert json_op[0]['entry']['key']['name'] == ''
+
+    # reshard to prune the bogus olh
+    cmd = exec_cmd('radosgw-admin bucket reshard --bucket %s --num-shards %s --yes-i-really-mean-it' % (BUCKET_NAME1, 1))
+
+    # get new name of shard 0 object, check that bi list has zero entries
+    bucket_shard0 = '.dir.%s.0' % get_bucket_stats(BUCKET_NAME1).bucket_id
+    cmd = exec_cmd('radosgw-admin bi list --bucket %s' % BUCKET_NAME1)
+    json_op = json.loads(cmd)
+    assert len(json_op) == 0
+
     # Clean up
     log.debug("Deleting bucket %s", BUCKET_NAME1)
     bucket1.objects.all().delete()