]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: fix cloud-sync multi-tenancy scenario
authorIonut Balutoiu <ibalutoiu@cloudbasesolutions.com>
Wed, 1 Nov 2023 16:07:58 +0000 (18:07 +0200)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 3 Nov 2023 12:41:05 +0000 (12:41 +0000)
At the moment, we cannot set buckets prefixed with tenant ID in the
`source_bucket` field from cloud-sync profiles (non-trivial config):
https://docs.ceph.com/en/latest/radosgw/cloud-sync-module/#non-trivial-configuration

This is because the `do_find_profile` function only searches in the
profiles configured using `bucket.name`, and it ignores `bucket.tenant`.

This is problematic in the RGW multi-tenancy scenario:
https://docs.ceph.com/en/latest/radosgw/multitenancy/#rgw-multi-tenancy

At the moment, we can only configure bucket name in the profile
`source_bucket` field. In the multi-tenancy scenario, this would sync
all the buckets (from all the tenants).

Without this fix, we cannot configure a cloud-sync profile that syncs
all the buckets from a tenant to a particular S3 target.

For example, we cannot do this:

* `tenantA/test-bucket` -> S3 target A
* `tenantB/test-bucket` -> S3 target B
* `tenantC/test-bucket` -> S3 target C

We can only do this at the moment:

* `test-bucket` -> S3 target A

If `test-bucket` is present in both `tenantA` and `tenantB`, both
buckets will be synced to S3 target A.

The idea would be to be able to do this:

* `tenantA/*` -> S3 target A
* `tenantB/*` -> S3 target B
* `tenantC/*` -> S3 target C

If `test-bucket` is present in all tenants, each tenant bucket is
synced to its own S3 target.

Fixes: https://tracker.ceph.com/issues/63395
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
(cherry picked from commit 764da1be698e4a88f4afa74c5cdf9fcfbbc18f9b)

src/rgw/driver/rados/rgw_sync_module_aws.cc
src/rgw/rgw_bucket_types.h

index cefcd9dd10c6155ceae57087cbd1f4119363a0f2..cdcd831e98923144aee2e7ba133c20e9ca0d731a 100644 (file)
@@ -487,7 +487,7 @@ struct AWSSyncConfig {
   }
 
   bool do_find_profile(const rgw_bucket bucket, std::shared_ptr<AWSSyncConfig_Profile> *result) {
-    const string& name = bucket.name;
+    const string& name = bucket.get_namespaced_name();
     auto iter = explicit_profiles.upper_bound(name);
     if (iter == explicit_profiles.begin()) {
       return false;
index 61acc58bbeb1a77553e0f40c01c0dd8d2595dd78..52ac5dc34bd1fb3fbc21fc830893de3b048ceee6 100644 (file)
@@ -136,6 +136,13 @@ struct rgw_bucket {
     DECODE_FINISH(bl);
   }
 
+  std::string get_namespaced_name() const {
+    if (tenant.empty()) {
+      return name;
+    }
+    return tenant + std::string("/") + name;
+  }
+
   void update_bucket_id(const std::string& new_bucket_id) {
     bucket_id = new_bucket_id;
   }