From 988a7f88c18ff977a8cd3cf305120b8322edcde7 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Tue, 13 May 2025 16:45:27 +0000 Subject: [PATCH] rgw/logging: part upload operation name should be REST.PUT.PART (in standard mode) Fixes: https://tracker.ceph.com/issues/71312 Signed-off-by: Yuval Lifshitz (cherry picked from commit 8dbe7117b658835a6f4e158b18ca35ac5f49c097) --- src/rgw/rgw_bucket_logging.cc | 4 ++-- src/rgw/rgw_op.cc | 17 ++++++++++++++++- src/rgw/rgw_op.h | 3 +++ src/rgw/rgw_process.cc | 2 +- src/rgw/rgw_rest.h | 5 ++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_bucket_logging.cc b/src/rgw/rgw_bucket_logging.cc index 840a3493f7705..d2429aad40ab7 100644 --- a/src/rgw/rgw_bucket_logging.cc +++ b/src/rgw/rgw_bucket_logging.cc @@ -628,8 +628,8 @@ int log_record(rgw::sal::Driver* driver, bool async_completion, bool log_source_bucket) { if (!s->bucket) { - // logging only bucket operations - return 0; + ldpp_dout(dpp, 1) << "ERROR: only bucket operations are logged in bucket logging" << dendl; + return -EINVAL; } // check if bucket logging is needed const auto& bucket_attrs = s->bucket->get_attrs(); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 859ade5a7998a..232aca1f4662d 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -4835,8 +4835,23 @@ void RGWPutObj::execute(optional_yield y) return; } + auto ret = rgw::bucketlogging::log_record(driver, + rgw::bucketlogging::LoggingType::Standard, + s->object.get(), + s, + (multipart ? "REST.PUT.PART" : canonical_name()), + etag, + s->object->get_size(), + this, + y, + true, + false); + if (ret < 0) { + ldpp_dout(this, 5) << "WARNING: in Standard mode, put object operation ignores bucket logging failure: " << ret << dendl; + } + // send request to notification manager - int ret = res->publish_commit(this, s->obj_size, mtime, etag, s->object->get_instance()); + ret = res->publish_commit(this, s->obj_size, mtime, etag, s->object->get_instance()); if (ret < 0) { ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl; // too late to rollback operation, hence op_ret is not set here diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 87d2dfccfb8e5..c8a5a4a960094 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -309,6 +309,8 @@ public: virtual const char* name() const = 0; virtual RGWOpType get_type() { return RGW_OP_UNKNOWN; } virtual std::string canonical_name() const { return fmt::format("REST.{}.{}", s->info.method, name()); } + // by default we log all bucket operations + virtual bool always_do_bucket_logging() const { return s->bucket != nullptr; } virtual uint32_t op_mask() { return 0; } @@ -1327,6 +1329,7 @@ public: RGWOpType get_type() override { return RGW_OP_PUT_OBJ; } uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; } dmc::client_id dmclock_client() override { return dmc::client_id::data; } + bool always_do_bucket_logging() const override { return false; } }; class RGWPostObj : public RGWOp { diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 46a754bf54388..704a6a7c2eea4 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -466,7 +466,7 @@ done: rgw_log_op(rest, s, op, penv.olog.get()); } - if (op) { + if (op && op->always_do_bucket_logging()) { std::ignore = rgw::bucketlogging::log_record(driver, rgw::bucketlogging::LoggingType::Standard, s->object.get(), diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index d0c1e49c065a1..de3938262a68b 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -248,7 +248,10 @@ public: int get_params(optional_yield y) override; int get_data(bufferlist& bl) override; - virtual std::string canonical_name() const override { return fmt::format("REST.{}.OBJECT", s->info.method); } + virtual std::string canonical_name() const override { + const bool multipart = !multipart_upload_id.empty(); + return fmt::format("REST.{}.{}", s->info.method, multipart ? "PART" : "OBJECT"); + } }; class RGWPostObj_ObjStore : public RGWPostObj -- 2.39.5