@@ -111,6 +111,7 @@ class RGWGetBucketLoggingOp : public RGWOp {
111111 }
112112
113113 void send_response () override {
114+ set_req_state_err (s, op_ret);
114115 dump_errno (s);
115116 if (mtime) {
116117 dump_last_modified (s, *mtime);
@@ -123,6 +124,7 @@ class RGWGetBucketLoggingOp : public RGWOp {
123124 s->formatter ->close_section ();
124125 rgw_flush_formatter_and_reset (s, s->formatter );
125126 }
127+
126128 const char * name () const override { return " get_bucket_logging" ; }
127129 std::string canonical_name () const override { return fmt::format (" REST.{}.LOGGING" , s->info .method ); }
128130 RGWOpType get_type () override { return RGW_OP_GET_BUCKET_LOGGING; }
@@ -136,6 +138,7 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp {
136138 // and usd in execute()
137139 rgw::bucketlogging::configuration configuration;
138140 std::unique_ptr<rgw::sal::Bucket> target_bucket;
141+ std::string old_obj; // used when conf change triggers a rollover
139142
140143 int init_processing (optional_yield y) override {
141144 if (const auto ret = verify_bucket_logging_params (this , s); ret < 0 ) {
@@ -234,7 +237,7 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp {
234237 }
235238
236239 if (!configuration.enabled ) {
237- op_ret = rgw::bucketlogging::source_bucket_cleanup (this , driver, src_bucket.get (), true , y);
240+ op_ret = rgw::bucketlogging::source_bucket_cleanup (this , driver, src_bucket.get (), true , y, &old_obj );
238241 return ;
239242 }
240243
@@ -306,12 +309,27 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp {
306309 }
307310 } else if (*old_conf != configuration) {
308311 // conf changed - do cleanup
309- if (const auto ret = commit_logging_object (*old_conf, target_bucket, this , y, nullptr ); ret < 0 ) {
310- ldpp_dout (this , 1 ) << " WARNING: could not commit pending logging object when updating logging configuration of bucket '" <<
311- src_bucket->get_key () << " ', ret = " << ret << dendl;
312+ RGWObjVersionTracker objv_tracker;
313+ std::string obj_name;
314+ const auto region = driver->get_zone ()->get_zonegroup ().get_api_name ();
315+ if (const auto ret = rollover_logging_object (*old_conf,
316+ target_bucket,
317+ obj_name,
318+ this ,
319+ region,
320+ src_bucket,
321+ y,
322+ false , // rollover should happen even if commit failed
323+ &objv_tracker,
324+ &old_obj); ret < 0 ) {
325+ ldpp_dout (this , 1 ) << " WARNING: failed to flush pending logging object '" << obj_name << " '"
326+ << " to target bucket '" << target_bucket_id << " '. "
327+ << " last committed object is '" << old_obj <<
328+ " ' when updating logging configuration of bucket '" << src_bucket->get_key () << " . error: " << ret << dendl;
312329 } else {
313- ldpp_dout (this , 20 ) << " INFO: committed pending logging object when updating logging configuration of bucket '" <<
314- src_bucket->get_key () << " '" << dendl;
330+ ldpp_dout (this , 20 ) << " INFO: flushed pending logging object '" << old_obj
331+ << " ' to target bucket '" << target_bucket_id << " ' when updating logging configuration of bucket '"
332+ << src_bucket->get_key () << " '" << dendl;
315333 }
316334 if (old_conf->target_bucket != configuration.target_bucket ) {
317335 rgw_bucket old_target_bucket_id;
@@ -334,6 +352,19 @@ class RGWPutBucketLoggingOp : public RGWDefaultResponseOp {
334352 ldpp_dout (this , 20 ) << " INFO: logging configuration of bucket '" << src_bucket_id << " ' did not change" << dendl;
335353 }
336354 }
355+
356+ void send_response () override {
357+ set_req_state_err (s, op_ret);
358+ dump_errno (s);
359+ end_header (s, this , to_mime_type (s->format ));
360+ if (!old_obj.empty ()) {
361+ dump_start (s);
362+ s->formatter ->open_object_section_in_ns (" PutBucketLoggingOutput" , XMLNS_AWS_S3);
363+ s->formatter ->dump_string (" FlushedLoggingObject" , old_obj);
364+ s->formatter ->close_section ();
365+ rgw_flush_formatter_and_reset (s, s->formatter );
366+ }
367+ }
337368};
338369
339370// Post /<bucket name>/?logging
@@ -407,6 +438,7 @@ class RGWPostBucketLoggingOp : public RGWDefaultResponseOp {
407438 }
408439
409440 void send_response () override {
441+ set_req_state_err (s, op_ret);
410442 dump_errno (s);
411443 end_header (s, this , to_mime_type (s->format ));
412444 dump_start (s);
0 commit comments