From 0ecf8bc3a7ddc7570c5ffcefc9cbaf25839ffa3c Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Tue, 30 Aug 2022 11:00:48 +0300 Subject: [PATCH] rgw/notifications: add region to bucket ARN Fixes: https://tracker.ceph.com/issues/53186 Signed-off-by: Yuval Lifshitz --- doc/radosgw/notifications.rst | 4 ++-- src/rgw/rgw_notify.cc | 7 +++++-- src/test/rgw/bucket_notification/test_bn.py | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/radosgw/notifications.rst b/doc/radosgw/notifications.rst index 4da44ac10c4..36782579aea 100644 --- a/doc/radosgw/notifications.rst +++ b/doc/radosgw/notifications.rst @@ -385,7 +385,7 @@ pushed or pulled using the pubsub sync module. For example: { "eventVersion":"2.1", "eventSource":"ceph:s3", - "awsRegion":"us-east-1", + "awsRegion":"zonegroup1", "eventTime":"2019-11-22T13:47:35.124724Z", "eventName":"ObjectCreated:Put", "userIdentity":{ @@ -406,7 +406,7 @@ pushed or pulled using the pubsub sync module. For example: "ownerIdentity":{ "principalId":"tester" }, - "arn":"arn:aws:s3:us-east-1::mybucket1", + "arn":"arn:aws:s3:zonegroup1::mybucket1", "id":"503a4c37-85eb-47cd-8681-2817e80b4281.5332.38" }, "object":{ diff --git a/src/rgw/rgw_notify.cc b/src/rgw/rgw_notify.cc index 60f9eee5639..c5940059e5c 100644 --- a/src/rgw/rgw_notify.cc +++ b/src/rgw/rgw_notify.cc @@ -687,12 +687,15 @@ static inline void populate_event(reservation_t& res, // configurationId is filled from notification configuration event.bucket_name = res.bucket->get_name(); event.bucket_ownerIdentity = res.bucket->get_owner() ? res.bucket->get_owner()->get_id().id : ""; - event.bucket_arn = to_string(rgw::ARN(res.bucket->get_key())); + const auto region = res.store->get_zone()->get_zonegroup().get_api_name(); + rgw::ARN bucket_arn(res.bucket->get_key()); + bucket_arn.region = region; + event.bucket_arn = to_string(bucket_arn); event.object_key = res.object_name ? *res.object_name : obj->get_name(); event.object_size = size; event.object_etag = etag; event.object_versionId = version; - event.awsRegion = res.store->get_zone()->get_zonegroup().get_api_name(); + event.awsRegion = region; // use timestamp as per key sequence id (hex encoded) const utime_t ts(real_clock::now()); boost::algorithm::hex((const char*)&ts, (const char*)&ts + sizeof(utime_t), diff --git a/src/test/rgw/bucket_notification/test_bn.py b/src/test/rgw/bucket_notification/test_bn.py index 0f74ae991ad..cb09d4aa38b 100644 --- a/src/test/rgw/bucket_notification/test_bn.py +++ b/src/test/rgw/bucket_notification/test_bn.py @@ -895,6 +895,9 @@ def test_ps_s3_notification_filter_on_master(): notif_id = event['Records'][0]['s3']['configurationId'] key_name = event['Records'][0]['s3']['object']['key'] awsRegion = event['Records'][0]['awsRegion'] + assert_equal(awsRegion, zonegroup) + bucket_arn = event['Records'][0]['s3']['bucket']['arn'] + assert_equal(bucket_arn, "arn:aws:s3:"+awsRegion+"::"+bucket_name) if notif_id == notification_name+'_1': found_in1.append(key_name) elif notif_id == notification_name+'_2': @@ -909,7 +912,6 @@ def test_ps_s3_notification_filter_on_master(): assert_equal(set(found_in1), set(expected_in1)) assert_equal(set(found_in2), set(expected_in2)) assert_equal(set(found_in3), set(expected_in3)) - assert_equal(awsRegion, zonegroup) if not skip_notif4: assert_equal(set(found_in4), set(expected_in4))