]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: add region to bucket ARN 47864/head
authorYuval Lifshitz <ylifshit@redhat.com>
Tue, 30 Aug 2022 08:00:48 +0000 (11:00 +0300)
committerYuval Lifshitz <ylifshit@redhat.com>
Tue, 30 Aug 2022 08:00:48 +0000 (11:00 +0300)
Fixes: https://tracker.ceph.com/issues/53186
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
doc/radosgw/notifications.rst
src/rgw/rgw_notify.cc
src/test/rgw/bucket_notification/test_bn.py

index 4da44ac10c49706fa072d66ab3afd448230fb8e7..36782579aeaf536b377fd297bdd6cd0547dd8932 100644 (file)
@@ -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":{
index 60f9eee5639d7f5054c69a53c94d3e1af96f1c02..c5940059e5cf576fc549e777b323cc9f58046dd2 100644 (file)
@@ -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), 
index 0f74ae991ad99e0fda2f8d4e0f6d25adf31c3cdd..cb09d4aa38b74549a22a7b26b6bd1f16298436ec 100644 (file)
@@ -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))