From f7e82e9f8a9e522ff5e8a05bff72069c004054d8 Mon Sep 17 00:00:00 2001 From: Lumir Sliva Date: Tue, 31 Mar 2026 17:04:16 +0200 Subject: [PATCH] rgw: avoid doubled ARN in GetBucketReplication for pre-existing data 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 --- src/rgw/rgw_rest_s3.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index a90346b6886a..0b943d36b61a 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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(); -- 2.47.3