From 7b74603513981c622fb3d25d8cd13f13a4c4dcb0 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 22 Dec 2021 13:33:52 -0500 Subject: [PATCH] rgwlc: harmonize lifecycle notifications with the others After working with notification configurations, it seemed to make more sense to organize the different lifecycle notification sub-types along the same lines as the official AWS ones. So, there are now ObjectExpirationCurrent and ObjectExpirationNoncurrent types, and an ObjectExpiration wildcard. Similarly, ObjectTransition contains Current and Noncurrent sub-types. Note that I have defined an ObjectExpirationAbortMPU notification sub-type, but do not currently generate it--this is to avoid changing the rgw::sal interface, but most likely we would support this in future. Signed-off-by: Matt Benjamin --- doc/radosgw/s3-notification-compatibility.rst | 62 +++++++++++-------- src/rgw/rgw_lc.cc | 8 +-- src/rgw/rgw_notify_event_type.cc | 52 +++++++++++++--- src/rgw/rgw_notify_event_type.h | 14 +++-- 4 files changed, 96 insertions(+), 40 deletions(-) diff --git a/doc/radosgw/s3-notification-compatibility.rst b/doc/radosgw/s3-notification-compatibility.rst index bb2cfb31393..d0259d1bb20 100644 --- a/doc/radosgw/s3-notification-compatibility.rst +++ b/doc/radosgw/s3-notification-compatibility.rst @@ -79,31 +79,43 @@ However, the following fields may be sent empty, under the different deployment Event Types ----------- -+----------------------------------------------+-----------------+-------------------------------------------+ -| Event | Notification | PubSub | -+==============================================+=================+===========================================+ -| ``s3:ObjectCreated:*`` | Supported | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectCreated:Put`` | Supported | Supported at ``s3:ObjectCreated:*`` level | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectCreated:Post`` | Supported | Not Supported | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectCreated:Copy`` | Supported | Supported at ``s3:ObjectCreated:*`` level | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectCreated:CompleteMultipartUpload`` | Supported | Supported at ``s3:ObjectCreated:*`` level | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectRemoved:*`` | Supported | Supported only the specific events below | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectRemoved:Delete`` | Supported | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectRemoved:DeleteMarkerCreated`` | Supported | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectRestore:Post`` | Not applicable to Ceph | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ObjectRestore:Complete`` | Not applicable to Ceph | -+----------------------------------------------+-----------------+-------------------------------------------+ -| ``s3:ReducedRedundancyLostObject`` | Not applicable to Ceph | -+----------------------------------------------+-----------------+-------------------------------------------+ ++------------------------------------------------+-----------------+-------------------------------------------+ +| Event | Notification | PubSub | ++================================================+=================+===========================================+ +| ``s3:ObjectCreated:*`` | Supported | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectCreated:Put`` | Supported | Supported at ``s3:ObjectCreated:*`` level | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectCreated:Post`` | Supported | Not Supported | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectCreated:Copy`` | Supported | Supported at ``s3:ObjectCreated:*`` level | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectCreated:CompleteMultipartUpload`` | Supported | Supported at ``s3:ObjectCreated:*`` level | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectRemoved:*`` | Supported | Supported only the specific events below | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectRemoved:Delete`` | Supported | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectRemoved:DeleteMarkerCreated`` | Supported | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Expiration:Current`` | Supported, Ceph extension | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Expiration:NonCurrent`` | Supported, Ceph extension | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Expiration:DeleteMarker`` | Supported, Ceph extension | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Expiration:AbortMultipartUpload`` | Defined, Ceph extension (not generated) | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Transition:Current`` | Supported, Ceph extension | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectLifecycle:Transition:NonCurrent`` | Supported, Ceph extension | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectRestore:Post`` | Not applicable to Ceph | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ObjectRestore:Complete`` | Not applicable to Ceph | ++------------------------------------------------+-----------------+-------------------------------------------+ +| ``s3:ReducedRedundancyLostObject`` | Not applicable to Ceph | ++----------------------------------------------+-----------------+---------------------------------------------+ .. note:: diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 2f8d381ddf5..9af8422d6f2 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -1117,7 +1117,7 @@ public: int r; if (o.is_delete_marker()) { r = remove_expired_obj(oc.dpp, oc, true, - rgw::notify::ObjectDeleteMarkerExpiration); + rgw::notify::ObjectExpirationDeleteMarker); if (r < 0) { ldpp_dout(oc.dpp, 0) << "ERROR: current is-dm remove_expired_obj " << oc.bucket << ":" << o.key @@ -1131,7 +1131,7 @@ public: } else { /* ! o.is_delete_marker() */ r = remove_expired_obj(oc.dpp, oc, !oc.bucket->versioned(), - rgw::notify::ObjectExpiration); + rgw::notify::ObjectExpirationCurrent); if (r < 0) { ldpp_dout(oc.dpp, 0) << "ERROR: remove_expired_obj " << oc.bucket << ":" << o.key @@ -1179,7 +1179,7 @@ public: int process(lc_op_ctx& oc) { auto& o = oc.o; int r = remove_expired_obj(oc.dpp, oc, true, - rgw::notify::ObjectNoncurrentExpiration); + rgw::notify::ObjectExpirationNoncurrent); if (r < 0) { ldpp_dout(oc.dpp, 0) << "ERROR: remove_expired_obj (non-current expiration) " << oc.bucket << ":" << o.key @@ -1224,7 +1224,7 @@ public: int process(lc_op_ctx& oc) { auto& o = oc.o; int r = remove_expired_obj(oc.dpp, oc, true, - rgw::notify::ObjectDeleteMarkerExpiration); + rgw::notify::ObjectExpirationDeleteMarker); if (r < 0) { ldpp_dout(oc.dpp, 0) << "ERROR: remove_expired_obj (delete marker expiration) " << oc.bucket << ":" << o.key diff --git a/src/rgw/rgw_notify_event_type.cc b/src/rgw/rgw_notify_event_type.cc index fd1dc8538f0..059cfc3469a 100644 --- a/src/rgw/rgw_notify_event_type.cc +++ b/src/rgw/rgw_notify_event_type.cc @@ -24,12 +24,24 @@ namespace rgw::notify { return "s3:ObjectRemoved:Delete"; case ObjectRemovedDeleteMarkerCreated: return "s3:ObjectRemoved:DeleteMarkerCreated"; + case ObjectLifecycle: + return "s3:ObjectLifecycle:*"; case ObjectExpiration: - return "s3:ObjectLifecycle:Expiration"; - case ObjectNoncurrentExpiration: - return "s3:ObjectLifecycle:NoncurrentExpiration"; - case ObjectDeleteMarkerExpiration: - return "s3:ObjectLifecycle:DeleteMarkerExpiration"; + return "s3:ObjectLifecycle:Expiration:*"; + case ObjectExpirationCurrent: + return "s3:ObjectLifecycle:Expiration:Current"; + case ObjectExpirationNoncurrent: + return "s3:ObjectLifecycle:Expiration:Noncurrent"; + case ObjectExpirationDeleteMarker: + return "s3:ObjectLifecycle:Expiration:DeleteMarker"; + case ObjectExpirationAbortMPU: + return "s3:ObjectLifecycle:Expiration:AbortMPU"; + case ObjectTransition: + return "s3:ObjectLifecycle:Transition:*"; + case ObjectTransitionCurrent: + return "s3:ObjectLifecycle:Transition:Current"; + case ObjectTransitionNoncurrent: + return "s3:ObjectLifecycle:Transition:Noncurrent"; case UnknownEvent: return "s3:UnknownEvent"; } @@ -48,10 +60,18 @@ namespace rgw::notify { return "OBJECT_DELETE"; case ObjectRemovedDeleteMarkerCreated: return "DELETE_MARKER_CREATE"; + case ObjectLifecycle: + return "OBJECT_LIFECYCLE"; case ObjectExpiration: - case ObjectNoncurrentExpiration: - case ObjectDeleteMarkerExpiration: + case ObjectExpirationCurrent: + case ObjectExpirationNoncurrent: + case ObjectExpirationDeleteMarker: + case ObjectExpirationAbortMPU: return "OBJECT_EXPIRATION"; + case ObjectTransition: + case ObjectTransitionCurrent: + case ObjectTransitionNoncurrent: + return "OBJECT_TRANSITION"; case ObjectRemoved: case UnknownEvent: return "UNKNOWN_EVENT"; @@ -80,6 +100,24 @@ namespace rgw::notify { return ObjectRemovedDelete; if (s == "s3:ObjectRemoved:DeleteMarkerCreated" || s == "DELETE_MARKER_CREATE") return ObjectRemovedDeleteMarkerCreated; + if (s == "s3:ObjectLifecycle:*") + return ObjectLifecycle; + if (s == "s3:ObjectLifecycle:Expiration:*" || s == "OBJECT_EXPIRATION") + return ObjectExpiration; + if (s == "s3:ObjectLifecycle:Expiration:Current") + return ObjectExpirationCurrent; + if (s == "s3:ObjectLifecycle:Expiration:Noncurrent") + return ObjectExpirationNoncurrent; + if (s == "s3:ObjectLifecycle:Expiration:DeleteMarker") + return ObjectExpirationDeleteMarker; + if (s == "s3:ObjectLifecycle:Expiration:AbortMultipartUpload") + return ObjectExpirationAbortMPU; + if (s == "s3:ObjectLifecycle:Transition:*" || s == "OBJECT_TRANSITION") + return ObjectTransition; + if (s == "s3:ObjectLifecycle:Transition:Current") + return ObjectTransitionCurrent; + if (s == "s3:ObjectLifecycle:Transition:Noncurrent") + return ObjectTransitionNoncurrent; return UnknownEvent; } diff --git a/src/rgw/rgw_notify_event_type.h b/src/rgw/rgw_notify_event_type.h index 89e3e254550..bbfff88f5e1 100644 --- a/src/rgw/rgw_notify_event_type.h +++ b/src/rgw/rgw_notify_event_type.h @@ -16,10 +16,16 @@ namespace rgw::notify { ObjectRemovedDelete = 0x10, ObjectRemovedDeleteMarkerCreated = 0x20, // lifecycle events (RGW extension) - ObjectExpiration = 0x40, - ObjectNoncurrentExpiration = 0x80, - ObjectDeleteMarkerExpiration = 0x100, - UnknownEvent = 0x200 + ObjectLifecycle = 0xFF00, + ObjectExpiration = 0xF00, + ObjectExpirationCurrent = 0x100, + ObjectExpirationNoncurrent = 0x200, + ObjectExpirationDeleteMarker = 0x400, + ObjectExpirationAbortMPU = 0x800, + ObjectTransition = 0xF000, + ObjectTransitionCurrent = 0x1000, + ObjectTransitionNoncurrent = 0x2000, + UnknownEvent = 0x10000 }; using EventTypeList = std::vector; -- 2.39.5