Skip to content

Commit b56fccc

Browse files
authored
Merge pull request ceph#65023 from soumyakoduri/wip-skoduri-restore-notification
rgw/restore: Add notifications for restore events
2 parents aab3e7a + 5e2d2b5 commit b56fccc

17 files changed

+164
-15
lines changed

doc/radosgw/s3-notification-compatibility.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ Event Types
142142
+--------------------------------------------------------+-------------------------------------------+
143143
| ``s3:Replication:DeletionMarkerCreated`` | Defined, Supported (not generated) |
144144
+--------------------------------------------------------+-------------------------------------------+
145-
| ``s3:ObjectRestore:Post`` | Not applicable |
145+
| ``s3:ObjectRestore:*`` | Supported |
146146
+--------------------------------------------------------+-------------------------------------------+
147-
| ``s3:ObjectRestore:Complete`` | Not applicable |
147+
| ``s3:ObjectRestore:Post`` | Supported |
148+
+--------------------------------------------------------+-------------------------------------------+
149+
| ``s3:ObjectRestore:Completed`` | Supported |
150+
+--------------------------------------------------------+-------------------------------------------+
151+
| ``s3:ObjectRestore:Delete`` | Supported |
148152
+--------------------------------------------------------+-------------------------------------------+
149153
| ``s3:ReducedRedundancyLostObject`` | Not applicable |
150154
+--------------------------------------------------------+-------------------------------------------+

src/rgw/driver/daos/rgw_sal_daos.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ int DaosObject::restore_obj_from_cloud(Bucket* bucket,
10351035
uint64_t olh_epoch,
10361036
std::optional<uint64_t> days,
10371037
bool& in_progress,
1038+
uint64_t& size,
10381039
const DoutPrefixProvider* dpp,
10391040
optional_yield y)
10401041
{

src/rgw/driver/daos/rgw_sal_daos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ class DaosObject : public StoreObject {
661661
uint64_t olh_epoch,
662662
std::optional<uint64_t> days,
663663
bool& in_progress,
664+
uint64_t& size,
664665
const DoutPrefixProvider* dpp,
665666
optional_yield y) override;
666667
virtual bool placement_rules_match(rgw_placement_rule& r1,

src/rgw/driver/posix/rgw_sal_posix.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,6 +3243,7 @@ int POSIXObject::restore_obj_from_cloud(Bucket* bucket,
32433243
CephContext* cct,
32443244
std::optional<uint64_t> days,
32453245
bool& in_progress,
3246+
uint64_t& size,
32463247
const DoutPrefixProvider* dpp,
32473248
optional_yield y)
32483249
{

src/rgw/driver/posix/rgw_sal_posix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ class POSIXObject : public StoreObject {
10801080
CephContext* cct,
10811081
std::optional<uint64_t> days,
10821082
bool& in_progress,
1083+
uint64_t& size,
10831084
const DoutPrefixProvider* dpp,
10841085
optional_yield y) override;
10851086
virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override;

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5472,6 +5472,7 @@ int RGWRados::restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
54725472
RGWObjTier& tier_config,
54735473
std::optional<uint64_t> days,
54745474
bool& in_progress,
5475+
uint64_t& size,
54755476
const DoutPrefixProvider *dpp,
54765477
optional_yield y) {
54775478

@@ -5693,7 +5694,9 @@ int RGWRados::restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
56935694
return ret;
56945695
}
56955696

5696-
return ret;
5697+
// set size to be used to send bucket notification
5698+
size = accounted_size;
5699+
return 0;
56975700
}
56985701

56995702
int RGWRados::check_bucket_empty(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, optional_yield y)

src/rgw/driver/rados/rgw_rados.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
12941294
RGWObjTier& tier_config,
12951295
std::optional<uint64_t> days,
12961296
bool& in_progress,
1297+
uint64_t& size,
12971298
const DoutPrefixProvider *dpp,
12981299
optional_yield y);
12991300

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,7 @@ int RadosObject::restore_obj_from_cloud(Bucket* bucket,
30793079
CephContext* cct,
30803080
std::optional<uint64_t> days,
30813081
bool& in_progress,
3082+
uint64_t& size,
30823083
const DoutPrefixProvider* dpp,
30833084
optional_yield y)
30843085
{
@@ -3154,7 +3155,7 @@ int RadosObject::restore_obj_from_cloud(Bucket* bucket,
31543155
* avoid any races */
31553156
ret = store->getRados()->restore_obj_from_cloud(tier_ctx, *rados_ctx,
31563157
bucket->get_info(), get_obj(),
3157-
tier_config, days, in_progress, dpp, y);
3158+
tier_config, days, in_progress, size, dpp, y);
31583159

31593160
if (ret < 0) { //failed to restore
31603161
ldpp_dout(dpp, 0) << "Restoring object(" << get_key() << ") from the cloud endpoint(" << endpoint << ") failed, ret=" << ret << dendl;
@@ -3364,13 +3365,26 @@ int RadosObject::handle_obj_expiry(const DoutPrefixProvider* dpp, optional_yield
33643365
attrs[RGW_ATTR_INTERNAL_MTIME] = std::move(bl);
33653366
}
33663367
const req_context rctx{dpp, y, nullptr};
3367-
return obj_op.write_meta(0, 0, attrs, rctx, head_obj->get_trace(), false);
3368+
ret = obj_op.write_meta(0, 0, attrs, rctx, head_obj->get_trace(), false);
3369+
3370+
// send notification in case the temporary copy of restored obj is expired
3371+
if (!ret) { //send notification
3372+
string etag;
3373+
attr_iter = attrs.find(RGW_ATTR_ETAG);
3374+
if (attr_iter != attrs.end()) {
3375+
etag = rgw_bl_str(attr_iter->second);
3376+
}
3377+
store->get_rgwrestore()->send_notification(dpp, store, this, bucket, etag, 0,
3378+
get_obj().key.instance,
3379+
{rgw::notify::ObjectRestoreExpired}, y);
3380+
3381+
}
33683382
} catch (const buffer::end_of_buffer&) {
33693383
// ignore empty manifest; it's not cloud-tiered
33703384
} catch (const std::exception& e) {
33713385
}
33723386
}
3373-
return 0;
3387+
return ret;
33743388
}
33753389
}
33763390
// object is not restored/temporary; go for regular deletion

src/rgw/driver/rados/rgw_sal_rados.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ class RadosObject : public StoreObject {
644644
CephContext* cct,
645645
std::optional<uint64_t> days,
646646
bool& in_progress,
647+
uint64_t& size,
647648
const DoutPrefixProvider* dpp,
648649
optional_yield y) override;
649650
virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override;

src/rgw/rgw_notify_event_type.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ namespace rgw::notify {
6666
return "s3:Replication:Delete";
6767
case ReplicationDeletionMarkerCreated:
6868
return "s3:Replication:DeletionMarkerCreated";
69+
case ObjectRestore:
70+
return "s3:ObjectRestore:*";
71+
case ObjectRestoreInitiated:
72+
return "s3:ObjectRestore:Post";
73+
case ObjectRestoreCompleted:
74+
return "s3:ObjectRestore:Completed";
75+
case ObjectRestoreExpired:
76+
return "s3:ObjectRestore:Delete";
6977
case UnknownEvent:
7078
return "s3:UnknownEvent";
7179
}
@@ -139,6 +147,14 @@ namespace rgw::notify {
139147
return ReplicationDelete;
140148
if (s == "s3:Replication:DeletionMarkerCreated")
141149
return ReplicationDeletionMarkerCreated;
150+
if (s =="s3:ObjectRestore:*")
151+
return ObjectRestore;
152+
if (s == "s3:ObjectRestore:Post")
153+
return ObjectRestoreInitiated;
154+
if (s == "s3:ObjectRestore:Completed")
155+
return ObjectRestoreCompleted;
156+
if (s == "s3:ObjectRestore:Delete")
157+
return ObjectRestoreExpired;
142158
return UnknownEvent;
143159
}
144160

0 commit comments

Comments
 (0)