From: Shilpa Jagannath Date: Tue, 18 Apr 2023 20:40:09 +0000 (-0400) Subject: rgw/multisite: parse shard_id value correctly to handle num_shards 0 case X-Git-Tag: v18.1.0~11^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b4bc964eacc871495e67ccddb2a1841da8a08c7f;p=ceph.git rgw/multisite: parse shard_id value correctly to handle num_shards 0 case For buckets that have num_shards set to 0, bucket instance will not have a shard_id delimiter. When this bucket instance is parsed, we end up assigning a value of -1 to shard_id, which is invalid in data sync. This change ensures that we represent the shard_id correctly by giving it a valid number Signed-off-by: Shilpa Jagannath (cherry picked from commit f11b3dce832221a344440787333c41f61a9f9c67) --- diff --git a/src/rgw/driver/rados/rgw_data_sync.cc b/src/rgw/driver/rados/rgw_data_sync.cc index d53999cd5ee57..e9027c68775e1 100644 --- a/src/rgw/driver/rados/rgw_data_sync.cc +++ b/src/rgw/driver/rados/rgw_data_sync.cc @@ -1721,8 +1721,17 @@ protected: rgw_bucket_shard source_bs; int parse_bucket_key(const std::string& key, rgw_bucket_shard& bs) const { - return rgw_bucket_parse_bucket_key(sc->env->cct, key, + int ret = rgw_bucket_parse_bucket_key(sc->env->cct, key, &bs.bucket, &bs.shard_id); + //for the case of num_shards 0, shard_id gets a value of -1 + //because of the way bucket instance gets parsed in the absence of shard_id delimiter. + //interpret it as a non-negative value. + if (ret == 0) { + if (bs.shard_id < 0) { + bs.shard_id = 0; + } + } + return ret; } RGWDataBaseSyncShardCR(