From 3be2b4bcc5686a5ff5e348dba2deda444d336bb8 Mon Sep 17 00:00:00 2001 From: Kalpesh Pandya Date: Wed, 14 Jul 2021 14:08:42 +0530 Subject: [PATCH] rgw/notifications: Changing the Multipart Upload notification behavior Changing the notification behavior in case of Multipart Upload, updating the related test cases and adding the documentation changes for the same. Signed-off-by: Kalpesh Pandya --- PendingReleaseNotes | 5 +++++ doc/radosgw/s3-notification-compatibility.rst | 4 ++++ src/rgw/rgw_op.cc | 22 +++++-------------- src/test/rgw/bucket_notification/test_bn.py | 10 ++++----- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 8d71887b7e436..855e71283b535 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -40,6 +40,11 @@ If you want to return back the old behavior add 'ssl_options=' (empty) to ``rgw frontends`` configuration. +* RGW: The behavior for Multipart Upload was modified so that only + CompleteMultipartUpload notification is sent at the end of the multipart upload. + The POST notification at the beginning of the upload, and PUT notifications that + were sent on each part are not sent anymore. + >=16.0.0 -------- * mgr/nfs: ``nfs`` module is moved out of volumes plugin. Prior using the diff --git a/doc/radosgw/s3-notification-compatibility.rst b/doc/radosgw/s3-notification-compatibility.rst index 008c33a59bd8a..09054bed39245 100644 --- a/doc/radosgw/s3-notification-compatibility.rst +++ b/doc/radosgw/s3-notification-compatibility.rst @@ -109,6 +109,10 @@ Event Types The ``s3:ObjectRemoved:DeleteMarkerCreated`` event presents information on the latest version of the object +.. note:: + + In case of multipart upload, an ``ObjectCreated:CompleteMultipartUpload`` notification will be sent at the end of the process. + Topic Configuration ------------------- In the case of bucket notifications, the topics management API will be derived from `AWS Simple Notification Service API`_. diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 583181152c7d7..d6366c8f611c4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3810,9 +3810,11 @@ void RGWPutObj::execute(optional_yield y) // make reservation for notification if needed std::unique_ptr res = store->get_notification(s->object.get(), s, rgw::notify::ObjectCreatedPut); - op_ret = res->publish_reserve(this, obj_tags.get()); - if (op_ret < 0) { - return; + if(!multipart) { + op_ret = res->publish_reserve(this, obj_tags.get()); + if (op_ret < 0) { + return; + } } // create the object processor @@ -5994,14 +5996,6 @@ void RGWInitMultipart::execute(optional_yield y) return; } - // make reservation for notification if needed - std::unique_ptr res = store->get_notification(s->object.get(), - s, rgw::notify::ObjectCreatedPost); - op_ret = res->publish_reserve(this); - if (op_ret < 0) { - return; - } - do { char buf[33]; std::unique_ptr obj; @@ -6039,12 +6033,6 @@ void RGWInitMultipart::execute(optional_yield y) op_ret = obj_op->write_meta(this, bl.length(), 0, s->yield); } while (op_ret == -EEXIST); - // send request to notification manager - int ret = res->publish_commit(this, s->obj_size, ceph::real_clock::now(), attrs[RGW_ATTR_ETAG].to_str(), ""); - if (ret < 0) { - ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl; - // too late to rollback operation, hence op_ret is not set here - } } int RGWCompleteMultipart::verify_permission(optional_yield y) diff --git a/src/test/rgw/bucket_notification/test_bn.py b/src/test/rgw/bucket_notification/test_bn.py index 2a5d305bc59bf..ac72b1c2bc16b 100644 --- a/src/test/rgw/bucket_notification/test_bn.py +++ b/src/test/rgw/bucket_notification/test_bn.py @@ -1406,7 +1406,7 @@ def ps_s3_creation_triggers_on_master(external_endpoint_address=None, ca_locatio # create s3 notification notification_name = bucket_name + NOTIFICATION_SUFFIX topic_conf_list = [{'Id': notification_name,'TopicArn': topic_arn, - 'Events': ['s3:ObjectCreated:Put', 's3:ObjectCreated:Copy'] + 'Events': ['s3:ObjectCreated:Put', 's3:ObjectCreated:Copy', 's3:ObjectCreated:CompleteMultipartUpload'] }] s3_notification_conf = PSNotificationS3(conn, bucket_name, topic_conf_list) @@ -1661,12 +1661,10 @@ def test_ps_s3_multipart_on_master(): # check amqp receiver events = receiver1.get_and_reset_events() - assert_equal(len(events), 3) + assert_equal(len(events), 1) events = receiver2.get_and_reset_events() - assert_equal(len(events), 1) - assert_equal(events[0]['Records'][0]['eventName'], 'ObjectCreated:Post') - assert_equal(events[0]['Records'][0]['s3']['configurationId'], notification_name+'_2') + assert_equal(len(events), 0) events = receiver3.get_and_reset_events() assert_equal(len(events), 1) @@ -1769,7 +1767,7 @@ def test_ps_s3_metadata_on_master(): time.sleep(5) # check amqp receiver events = receiver.get_and_reset_events() - assert_equal(len(events), 4) # PUT, COPY, Multipart start, Multipart End + assert_equal(len(events), 3) # PUT, COPY, Multipart start, Multipart End for event in events: assert(event['Records'][0]['s3']['object']['key'] in expected_keys) -- 2.39.5