From 764da1be698e4a88f4afa74c5cdf9fcfbbc18f9b Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Wed, 1 Nov 2023 18:07:58 +0200 Subject: [PATCH] rgw: fix cloud-sync multi-tenancy scenario 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 --- src/rgw/driver/rados/rgw_sync_module_aws.cc | 2 +- src/rgw/rgw_bucket_types.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rgw/driver/rados/rgw_sync_module_aws.cc b/src/rgw/driver/rados/rgw_sync_module_aws.cc index cefcd9dd10c61..cdcd831e98923 100644 --- a/src/rgw/driver/rados/rgw_sync_module_aws.cc +++ b/src/rgw/driver/rados/rgw_sync_module_aws.cc @@ -487,7 +487,7 @@ struct AWSSyncConfig { } bool do_find_profile(const rgw_bucket bucket, std::shared_ptr *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; diff --git a/src/rgw/rgw_bucket_types.h b/src/rgw/rgw_bucket_types.h index 61acc58bbeb1a..52ac5dc34bd1f 100644 --- a/src/rgw/rgw_bucket_types.h +++ b/src/rgw/rgw_bucket_types.h @@ -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; } -- 2.39.5