]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid doubled ARN in GetBucketReplication for pre-existing data 68137/head
authorLumir Sliva <lumir.sliva@firma.seznam.cz>
Tue, 31 Mar 2026 15:04:16 +0000 (17:04 +0200)
committerLumir Sliva <lumir.sliva@firma.seznam.cz>
Tue, 31 Mar 2026 15:04:16 +0000 (17:04 +0200)
Before commit b8f89327e1a ("rgw: handle destination bucket as an ARN
in ReplicationConfiguration"), the PutBucketReplication handler stored
the full ARN string (e.g. "arn:aws:s3:::bucket") as the bucket name
in the sync policy.  After that commit, the GetBucketReplication
handler wraps the stored bucket name in a new ARN via
ARN(rgw_bucket).to_string(), which produces a doubled prefix like
"arn:aws:s3:::arn:aws:s3:::bucket" for buckets whose replication was
configured before the fix.

Detect whether the stored bucket name is already a valid S3 ARN and
use it directly instead of wrapping it again.  New data written after
b8f89327e1a stores only the bare bucket name, so the else branch
handles that case unchanged.

Fixes: https://tracker.ceph.com/issues/75770
Signed-off-by: Lumir Sliva <lumir.sliva@firma.seznam.cz>
src/rgw/rgw_rest_s3.cc

index a90346b6886ad56e602f4bfd3a0308ce781e4333..0b943d36b61a291f9f081e155c246b557a514a26 100644 (file)
@@ -1449,7 +1449,17 @@ struct ReplicationConfiguration {
       }
 
       if (pipe.dest.bucket) {
-        destination.bucket = ARN(*pipe.dest.bucket).to_string();
+        // The bucket name may already contain the full ARN from data
+        // written before commit b8f89327e1a ("rgw: handle destination
+        // bucket as an ARN in ReplicationConfiguration").  Detect this
+        // to avoid producing a doubled ARN like
+        // "arn:aws:s3:::arn:aws:s3:::bucket".
+        auto existing = ARN::parse(pipe.dest.bucket->name);
+        if (existing && existing->service == rgw::Service::s3) {
+          destination.bucket = existing->to_string();
+        } else {
+          destination.bucket = ARN(*pipe.dest.bucket).to_string();
+        }
       }
 
       filter.emplace();