]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/logging: send flushed object name in API reply
authorYuval Lifshitz <ylifshit@ibm.com>
Wed, 7 May 2025 09:34:30 +0000 (09:34 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Mon, 9 Jun 2025 17:37:59 +0000 (17:37 +0000)
Fixes: https://tracker.ceph.com/issues/71219
Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
doc/radosgw/s3/bucketops.rst
examples/rgw/boto3/service-2.sdk-extras.json
src/rgw/rgw_rest_bucket_logging.cc

index 496d8f674c90e05e6a5a3ed4da39c36509544d85..da0fc29c1919cfbd90dd3ad89c0f51a507e9db83 100644 (file)
@@ -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:
+
+::
+
+  <PostBucketLoggingOutput xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+    <FlushedLoggingObject>string</FlushedLoggingObject>
+  </PostBucketLoggingOutput>
 
 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                                |
 +---------------+-----------------------+----------------------------------------------------------+
index d44dc14bb01aa2c8861ea130973dd7ae701adbef..6812900143e1be59f0ef1ee967f66e27a2e770fd 100644 (file)
@@ -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":"<p>Flushes the logging objects of the buckets.</p>"
         },
                 }
             }
         },
+        "PostBucketLoggingOutput": {
+            "type":"structure",
+            "members":{
+              "FlushedLoggingObject": {
+                "shape":"FlushedLoggingObject",
+                "documentation":"<p>Name of the pending logging object that was flushed.</p>"
+              }
+            }
+        },
+        "FlushedLoggingObject":{
+            "type":"string"
+        },
         "HeadBucketOutput":{
             "type":"structure",
             "members":{
index 4564d5accff5ef2447058fa7f9e3cfa049b94fc5..2d053308812825d4c93cc149c209dbc04092a5be 100644 (file)
@@ -341,6 +341,7 @@ class RGWPostBucketLoggingOp : public RGWDefaultResponseOp {
   rgw::bucketlogging::configuration configuration;
   std::unique_ptr<rgw::sal::Bucket> target_bucket;
   std::unique_ptr<rgw::sal::Bucket> 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() {