]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/multisite: parse shard_id value correctly to handle num_shards 0 case 51735/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 18 Apr 2023 20:40:09 +0000 (16:40 -0400)
committerShilpa Jagannath <smanjara@redhat.com>
Wed, 24 May 2023 19:33:08 +0000 (15:33 -0400)
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 <smanjara@redhat.com>
(cherry picked from commit f11b3dce832221a344440787333c41f61a9f9c67)

src/rgw/driver/rados/rgw_data_sync.cc

index d53999cd5ee57dec09550ce9a073fb0c709a9b29..e9027c68775e146cc620a555109fae7c4ca00b81 100644 (file)
@@ -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(