From: Tom Schoonjans Date: Wed, 5 May 2021 19:13:20 +0000 (+0000) Subject: rgw: remove s3: prefix in eventName value of s3 event message structure X-Git-Tag: v16.2.7~115^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cb4f077d231cd31429fcd43262b376226c026bc8;p=ceph.git rgw: remove s3: prefix in eventName value of s3 event message structure This change is necessary to match the event message structure seen on AWS. Signed-off-by: Tom Schoonjans Fixes bug https://tracker.ceph.com/issues/50115 (cherry picked from commit 893ce6b64a6138cea9428803a13d287c05a93244) Conflicts: src/test/rgw/bucket_notification/test_bn.py PendingReleaseNotes --- diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 2d81f949a2b3..793428101691 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -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 diff --git a/doc/radosgw/notifications.rst b/doc/radosgw/notifications.rst index d4b5069a8afb..dc7520a1b3ce 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: "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 diff --git a/src/rgw/rgw_notify.cc b/src/rgw/rgw_notify.cc index f40c2adaf588..14679f7004ee 100644 --- a/src/rgw/rgw_notify.cc +++ b/src/rgw/rgw_notify.cc @@ -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 diff --git a/src/rgw/rgw_notify_event_type.cc b/src/rgw/rgw_notify_event_type.cc index 10c77c281845..4af9a32f7e3b 100644 --- a/src/rgw/rgw_notify_event_type.cc +++ b/src/rgw/rgw_notify_event_type.cc @@ -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; diff --git a/src/rgw/rgw_notify_event_type.h b/src/rgw/rgw_notify_event_type.h index 0d86bf3f3219..f255bfd744eb 100644 --- a/src/rgw/rgw_notify_event_type.h +++ b/src/rgw/rgw_notify_event_type.h @@ -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 diff --git a/src/rgw/rgw_sync_module_pubsub.cc b/src/rgw/rgw_sync_module_pubsub.cc index d241ec4b9e6e..662396ba4adb 100644 --- a/src/rgw/rgw_sync_module_pubsub.cc +++ b/src/rgw/rgw_sync_module_pubsub.cc @@ -269,7 +269,7 @@ static void make_s3_event_ref(CephContext *cct, const rgw_bucket& bucket, EventRef& 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 diff --git a/src/test/rgw/rgw_multi/tests_ps.py b/src/test/rgw/rgw_multi/tests_ps.py index 5171401a6155..7e251341fc28 100644 --- a/src/test/rgw/rgw_multi/tests_ps.py +++ b/src/test/rgw/rgw_multi/tests_ps.py @@ -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