@@ -32,12 +32,21 @@ namespace {
3232 }
3333 return 0 ;
3434 }
35+
36+ void update_mtime_attribute (const DoutPrefixProvider* dpp, rgw::sal::Attrs& attrs) {
37+ bufferlist mtime_bl;
38+ const auto mtime = ceph::coarse_real_time::clock::now ();
39+ encode (mtime, mtime_bl);
40+ attrs[RGW_ATTR_BUCKET_LOGGING_MTIME] = std::move (mtime_bl);
41+ ldpp_dout (dpp, 20 ) << " INFO: logging config modified at: " << mtime << dendl;
42+ }
3543}
3644
3745// GET /<bucket name>/?logging
3846// reply is XML encoded
3947class RGWGetBucketLoggingOp : public RGWOp {
4048 rgw::bucketlogging::configuration configuration;
49+ std::optional<ceph::real_time> mtime;
4150
4251public:
4352 int verify_permission (optional_yield y) override {
@@ -73,6 +82,20 @@ class RGWGetBucketLoggingOp : public RGWOp {
7382 try {
7483 configuration.enabled = true ;
7584 decode (configuration, iter->second );
85+ if (auto mtime_it = src_bucket->get_attrs ().find (RGW_ATTR_BUCKET_LOGGING_MTIME);
86+ mtime_it != src_bucket->get_attrs ().end ()) {
87+ try {
88+ ceph::real_time tmp_mtime;
89+ decode (tmp_mtime, mtime_it->second );
90+ mtime = std::move (tmp_mtime);
91+ } catch (buffer::error& err) {
92+ ldpp_dout (this , 5 ) << " WARNING: failed to decode logging mtime attribute '" << RGW_ATTR_BUCKET_LOGGING_MTIME
93+ << " ' for bucket '" << src_bucket_id << " ', error: " << err.what () << dendl;
94+ }
95+ } else {
96+ ldpp_dout (this , 5 ) << " WARNING: no logging mtime attribute '" << RGW_ATTR_BUCKET_LOGGING_MTIME
97+ << " ' for bucket '" << src_bucket_id << " '" << dendl;
98+ }
7699 } catch (buffer::error& err) {
77100 ldpp_dout (this , 1 ) << " WARNING: failed to decode logging attribute '" << RGW_ATTR_BUCKET_LOGGING
78101 << " ' for bucket '" << src_bucket_id << " ', error: " << err.what () << dendl;
@@ -89,6 +112,9 @@ class RGWGetBucketLoggingOp : public RGWOp {
89112
90113 void send_response () override {
91114 dump_errno (s);
115+ if (mtime) {
116+ dump_last_modified (s, *mtime);
117+ }
92118 end_header (s, this , to_mime_type (s->format ));
93119 dump_start (s);
94120
@@ -253,13 +279,15 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp {
253279 if (!old_conf || (old_conf && *old_conf != configuration)) {
254280 // conf changed (or was unknown) - update
255281 it->second = conf_bl;
282+ update_mtime_attribute (this , attrs);
256283 return src_bucket->merge_and_store_attrs (this , attrs, y);
257284 }
258285 // nothing to update
259286 return 0 ;
260287 }
261288 // conf was added
262289 attrs.insert (std::make_pair (RGW_ATTR_BUCKET_LOGGING, conf_bl));
290+ update_mtime_attribute (this , attrs);
263291 return src_bucket->merge_and_store_attrs (this , attrs, y);
264292 }, y);
265293 if (op_ret < 0 ) {
0 commit comments