]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove s3: prefix in eventName value of s3 event message structure 42945/head
authorTom Schoonjans <Tom.Schoonjans@rfi.ac.uk>
Wed, 5 May 2021 19:13:20 +0000 (19:13 +0000)
committerYuval Lifshitz <ylifshit@redhat.com>
Fri, 27 Aug 2021 07:46:01 +0000 (10:46 +0300)
This change is necessary to match the event message structure seen on
AWS.

Signed-off-by: Tom Schoonjans <Tom.Schoonjans@rfi.ac.uk>
Fixes bug https://tracker.ceph.com/issues/50115

(cherry picked from commit 893ce6b64a6138cea9428803a13d287c05a93244)

Conflicts:
src/test/rgw/bucket_notification/test_bn.py
PendingReleaseNotes

PendingReleaseNotes
doc/radosgw/notifications.rst
src/rgw/rgw_notify.cc
src/rgw/rgw_notify_event_type.cc
src/rgw/rgw_notify_event_type.h
src/rgw/rgw_sync_module_pubsub.cc
src/test/rgw/rgw_multi/tests_ps.py

index 2d81f949a2b3443612985fce721ce253e8647fbd..7934281016912a8fab77c800bc8174011f3a62e2 100644 (file)
@@ -32,8 +32,9 @@
 >=16.0.0
 --------
 
-* RGW: S3 bucket notification events now contain `eTag` instead of `etag`, fixing
-  a deviation from the message format observed on AWS.
+* RGW: S3 bucket notification events now contain an `eTag` key instead of `etag`,
+  and eventName values no longer carry the `s3:` prefix, fixing deviations from
+  the message format observed on AWS.
 * `ceph-mgr-modules-core` debian package does not recommend `ceph-mgr-rook`
   anymore. As the latter depends on `python3-numpy` which cannot be imported in
   different Python sub-interpreters multi-times if the version of
index d4b5069a8afba833cda48a5aa61ae9de3e52fb2a..dc7520a1b3ce2a52ad5b51cf61d2dbee6da69cb9 100644 (file)
@@ -385,7 +385,7 @@ pushed or pulled using the pubsub sync module. For example:
            "eventSource":"ceph:s3",
            "awsRegion":"us-east-1",
            "eventTime":"2019-11-22T13:47:35.124724Z",
-           "eventName":"s3:ObjectCreated:Put",
+           "eventName":"ObjectCreated:Put",
            "userIdentity":{
                "principalId":"tester"
            },
@@ -424,7 +424,7 @@ pushed or pulled using the pubsub sync module. For example:
 
 - awsRegion: zonegroup
 - eventTime: timestamp indicating when the event was triggered
-- eventName: for list of supported events see: `S3 Notification Compatibility`_
+- eventName: for list of supported events see: `S3 Notification Compatibility`_. Note that the eventName values do not start with the `s3:` prefix.
 - userIdentity.principalId: user that triggered the change
 - requestParameters.sourceIPAddress: not supported
 - responseElements.x-amz-request-id: request ID of the original change
index f40c2adaf588bb07796fbb7daf1c6202c38cfd9a..14679f7004ee00b0852b6fcf96cef9bbc680ecee 100644 (file)
@@ -676,7 +676,7 @@ void populate_event_from_request(const reservation_t& res,
         rgw_pubsub_s3_event& event) {
   const auto s = res.s;
   event.eventTime = mtime;
-  event.eventName = to_string(event_type);
+  event.eventName = to_event_string(event_type);
   event.userIdentity = s->user->get_id().id;    // user that triggered the change
   event.x_amz_request_id = s->req_id;          // request ID of the original change
   event.x_amz_id_2 = s->host_id;               // RGW on which the change was made
index 10c77c2818455d3bdf82d2d8700533e9afdfb3a2..4af9a32f7e3b36eb6e26028a4c685781bcdc0482 100644 (file)
@@ -49,6 +49,10 @@ namespace rgw::notify {
     return "UNKNOWN_EVENT";
   }
 
+  std::string to_event_string(EventType t) {
+    return to_string(t).substr(3);
+  }
+
   EventType from_string(const std::string& s) {
     if (s == "s3:ObjectCreated:*" || s == "OBJECT_CREATE")
         return ObjectCreated;
index 0d86bf3f3219f3c81fe37ab742c59bd1dd55bbf8..f255bfd744eb23971d1153d26dcc6efcba904fe8 100644 (file)
@@ -27,6 +27,8 @@ namespace rgw::notify {
 
   std::string to_ceph_string(EventType t);
 
+  std::string to_event_string(EventType t);
+
   EventType from_string(const std::string& s);
  
   // create a vector of event types from comma separated list of event types
index d241ec4b9e6ea9fd28e8affc303449d040acc566..662396ba4adb3455f66c57bf9de112fa3292ba30 100644 (file)
@@ -269,7 +269,7 @@ static void make_s3_event_ref(CephContext *cct, const rgw_bucket& bucket,
 
   EventRef<rgw_pubsub_s3_event>& e = *event;
   e->eventTime = mtime;
-  e->eventName = rgw::notify::to_string(event_type);
+  e->eventName = rgw::notify::to_event_string(event_type);
   // userIdentity: not supported in sync module
   // x_amz_request_id: not supported in sync module
   // x_amz_id_2: not supported in sync module
index 5171401a61554a6b58f562668a98062d1833fe41..7e251341fc288675926847f66ca05bb5c471db8a 100644 (file)
@@ -335,11 +335,11 @@ def verify_s3_records_by_elements(records, keys, exact_match=False, deletions=Fa
                 for record in record_list['Records']:
                     if record['s3']['bucket']['name'] == key.bucket.name and \
                         record['s3']['object']['key'] == key.name:
-                        if deletions and 'ObjectRemoved' in record['eventName']:
+                        if deletions and record['eventName'].startswith('ObjectRemoved'):
                             key_found = True
                             object_size = record['s3']['object']['size']
                             break
-                        elif not deletions and 'ObjectCreated' in record['eventName']:
+                        elif not deletions and record['eventName'].startswith('ObjectCreated'):
                             key_found = True
                             object_size = record['s3']['object']['size']
                             break
@@ -347,11 +347,11 @@ def verify_s3_records_by_elements(records, keys, exact_match=False, deletions=Fa
             for record in records['Records']:
                 if record['s3']['bucket']['name'] == key.bucket.name and \
                     record['s3']['object']['key'] == key.name:
-                    if deletions and 'ObjectRemoved' in record['eventName']:
+                    if deletions and record['eventName'].startswith('ObjectRemoved'):
                         key_found = True
                         object_size = record['s3']['object']['size']
                         break
-                    elif not deletions and 'ObjectCreated' in record['eventName']:
+                    elif not deletions and record['eventName'].startswith('ObjectCreated'):
                         key_found = True
                         object_size = record['s3']['object']['size']
                         break