From fb2b037355b265266556a772c9c8ed5dad934475 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Wed, 7 May 2025 09:34:30 +0000 Subject: [PATCH] rgw/logging: send flushed object name in API reply Fixes: https://tracker.ceph.com/issues/71219 Signed-off-by: Yuval Lifshitz --- doc/radosgw/s3/bucketops.rst | 15 +++++++++++++-- examples/rgw/boto3/service-2.sdk-extras.json | 13 +++++++++++++ src/rgw/rgw_rest_bucket_logging.cc | 13 ++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/doc/radosgw/s3/bucketops.rst b/doc/radosgw/s3/bucketops.rst index 496d8f674c9..da0fc29c191 100644 --- a/doc/radosgw/s3/bucketops.rst +++ b/doc/radosgw/s3/bucketops.rst @@ -916,7 +916,8 @@ HTTP Response Flush Bucket Logging -------------------- -Flushes all logging objects for a given source bucket (logging bucket are written lazily). +Flushes logging object for a given source bucket (if not flushed, the logging objects are written lazily to the log bucket). +Returns the name of the object that was flushed. An empty name will be returned if no object needs to be flushed. Syntax ~~~~~~ @@ -925,6 +926,16 @@ Syntax POST /{bucket}?logging HTTP/1.1 +Response Entities +~~~~~~~~~~~~~~~~~ + +Response is XML encoded in the body of the request, in the following format: + +:: + + + string + HTTP Response ~~~~~~~~~~~~~ @@ -932,7 +943,7 @@ HTTP Response +---------------+-----------------------+----------------------------------------------------------+ | HTTP Status | Status Code | Description | +===============+=======================+==========================================================+ -| ``201`` | Created | Flushed all logging objects successfully | +| ``201`` | Created | Flushed pending logging object successfully | +---------------+-----------------------+----------------------------------------------------------+ | ``404`` | NoSuchBucket | The bucket does not exist | +---------------+-----------------------+----------------------------------------------------------+ diff --git a/examples/rgw/boto3/service-2.sdk-extras.json b/examples/rgw/boto3/service-2.sdk-extras.json index d44dc14bb01..6812900143e 100644 --- a/examples/rgw/boto3/service-2.sdk-extras.json +++ b/examples/rgw/boto3/service-2.sdk-extras.json @@ -21,6 +21,7 @@ "responseCode":201 }, "input":{"shape":"PostBucketLoggingRequest"}, + "output": {"shape": "PostBucketLoggingOutput"}, "documentationUrl":"https://docs.ceph.com/docs/master/radosgw/s3/bucketops/#post-bucket-logging", "documentation":"

Flushes the logging objects of the buckets.

" }, @@ -392,6 +393,18 @@ } } }, + "PostBucketLoggingOutput": { + "type":"structure", + "members":{ + "FlushedLoggingObject": { + "shape":"FlushedLoggingObject", + "documentation":"

Name of the pending logging object that was flushed.

" + } + } + }, + "FlushedLoggingObject":{ + "type":"string" + }, "HeadBucketOutput":{ "type":"structure", "members":{ diff --git a/src/rgw/rgw_rest_bucket_logging.cc b/src/rgw/rgw_rest_bucket_logging.cc index 4564d5accff..2d053308812 100644 --- a/src/rgw/rgw_rest_bucket_logging.cc +++ b/src/rgw/rgw_rest_bucket_logging.cc @@ -341,6 +341,7 @@ class RGWPostBucketLoggingOp : public RGWDefaultResponseOp { rgw::bucketlogging::configuration configuration; std::unique_ptr target_bucket; std::unique_ptr source_bucket; + std::string old_obj; int init_processing(optional_yield y) override { if (const auto ret = verify_bucket_logging_params(this, s); ret < 0) { @@ -384,7 +385,7 @@ class RGWPostBucketLoggingOp : public RGWDefaultResponseOp { ldpp_dout(this, 1) << "ERROR: failed to get pending logging object name from target bucket '" << target_bucket_id << "'" << dendl; return; } - const auto old_obj = obj_name; + old_obj = obj_name; const auto region = driver->get_zone()->get_zonegroup().get_api_name(); op_ret = rgw::bucketlogging::rollover_logging_object(configuration, target_bucket, obj_name, this, region, source_bucket, null_yield, true, &objv_tracker); if (op_ret < 0) { @@ -395,6 +396,16 @@ class RGWPostBucketLoggingOp : public RGWDefaultResponseOp { ldpp_dout(this, 20) << "INFO: flushed pending logging object '" << old_obj << "' to target bucket '" << target_bucket_id << "'" << dendl; } + + void send_response() override { + dump_errno(s); + end_header(s, this, to_mime_type(s->format)); + dump_start(s); + s->formatter->open_object_section_in_ns("PostBucketLoggingOutput", XMLNS_AWS_S3); + s->formatter->dump_string("FlushedLoggingObject", old_obj); + s->formatter->close_section(); + rgw_flush_formatter_and_reset(s, s->formatter); + } }; RGWOp* RGWHandler_REST_BucketLogging_S3::create_post_op() { -- 2.39.5