From 16511fd15f949359dabda3de8289975c351b0215 Mon Sep 17 00:00:00 2001 From: Dan van der Ster Date: Wed, 30 Mar 2022 10:55:49 +0200 Subject: [PATCH] workunits/rgw: reshard cleans empty name entries Check that reshard prunes olh entries with empty name. Fixes: https://tracker.ceph.com/issues/54500 Signed-off-by: Dan van der Ster --- qa/workunits/rgw/olh_noname_key | 1 + qa/workunits/rgw/olh_noname_val | Bin 0 -> 71 bytes qa/workunits/rgw/test_rgw_reshard.py | 31 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 qa/workunits/rgw/olh_noname_key create mode 100644 qa/workunits/rgw/olh_noname_val diff --git a/qa/workunits/rgw/olh_noname_key b/qa/workunits/rgw/olh_noname_key new file mode 100644 index 00000000000..6138c57cd0f --- /dev/null +++ b/qa/workunits/rgw/olh_noname_key @@ -0,0 +1 @@ +€1001_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 index 0000000000000000000000000000000000000000..ff442e1374c6e24735d85a9e6c9e4020c8fad591 GIT binary patch literal 71 zcmZQ%bYx&)U}WR~l5oHdXE87+0NEvJ6_o}BRRzUmnc0bXsi}D;mZqjvl}Q$fN%_S& I*_8~800e;y=l}o! literal 0 HcmV?d00001 diff --git a/qa/workunits/rgw/test_rgw_reshard.py b/qa/workunits/rgw/test_rgw_reshard.py index 61e92b99045..400994e476f 100755 --- a/qa/workunits/rgw/test_rgw_reshard.py +++ b/qa/workunits/rgw/test_rgw_reshard.py @@ -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() -- 2.39.5