From 2d389a5b94ddaddbd45499a2f7050723bba71cfb Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Thu, 13 Feb 2025 14:44:33 +0100 Subject: [PATCH] rgw: check for duplicate rule priorities in replication configuration When multiple replication rules target the same bucket, the rule with the highest priority should be applied. While this logic is already in place, the configuration does not enforce priority settings, which could lead to confusion. This behavior aligns with AWS's implementation for multiple destination buckets as outlined https://aws.amazon.com/blogs/aws/new-amazon-s3-replication-adds-support-for-multiple-destination-buckets/ Fixes: https://tracker.ceph.com/issues/69946 Signed-off-by: Seena Fallah --- src/rgw/rgw_rest_s3.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index d2ce7ca6afe..e7ef09b5aa1 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1419,7 +1419,13 @@ struct ReplicationConfiguration { disabled_group.id = disabled_group_id; disabled_group.status = rgw_sync_policy_group::Status::ALLOWED; /* not enabled, not forbidden */ + std::unordered_set priorities; // used to check for duplicates for (auto& rule : rules) { + if (!priorities.insert(rule.priority).second) { + s->err.message = fmt::format("Found duplicate priority {}.", rule.priority); + return -EINVAL; + } + rgw_sync_bucket_pipes pipe; bool enabled; int r = rule.to_sync_policy_pipe(s, driver, &pipe, &enabled); -- 2.47.3