From: Omri Zeneva Date: Tue, 30 Nov 2021 09:05:34 +0000 (+0200) Subject: rgw: implement single trace for multipart upload ops X-Git-Tag: v17.1.0~294^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=14b151c381bcb68a6c52ea1b9da3c12e87e450e4;p=ceph-ci.git rgw: implement single trace for multipart upload ops Signed-off-by: Omri Zeneva --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c86d3dd793d..4f69431a786 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -148,6 +148,7 @@ using ceph::crypto::MD5; #define RGW_ATTR_BUCKET_ENCRYPTION_POLICY RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "policy" #define RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "key-id" +#define RGW_ATTR_TRACE RGW_ATTR_PREFIX "trace" #define RGW_FORMAT_PLAIN 0 #define RGW_FORMAT_XML 1 diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index b2354f3140f..ec80c7f34d6 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3923,11 +3923,14 @@ void RGWPutObj::execute(optional_yield y) rgw_placement_rule *pdest_placement = &s->dest_placement; if (multipart) { - s->trace->SetAttribute(tracing::rgw::UPLOAD_ID, multipart_upload_id); std::unique_ptr upload; upload = s->bucket->get_multipart_upload(s->object->get_name(), multipart_upload_id); op_ret = upload->get_info(this, s->yield, s->obj_ctx, &pdest_placement); + + s->trace->SetAttribute(tracing::rgw::UPLOAD_ID, multipart_upload_id); + multipart_trace = tracing::rgw::tracer.add_span(name(), upload->get_trace()); + if (op_ret < 0) { if (op_ret != -ENOENT) { ldpp_dout(this, 0) << "ERROR: get_multipart_info returned " << op_ret << ": " << cpp_strerror(-op_ret) << dendl; @@ -3972,7 +3975,6 @@ void RGWPutObj::execute(optional_yield y) << dendl; return; } - if ((! copy_source.empty()) && !copy_source_range) { std::unique_ptr bucket; op_ret = store->get_bucket(nullptr, copy_source_bucket_info, &bucket); @@ -3997,7 +3999,6 @@ void RGWPutObj::execute(optional_yield y) } else { lst = copy_source_range_lst; } - fst = copy_source_range_fst; // no filters by default @@ -6125,7 +6126,7 @@ void RGWInitMultipart::pre_exec() void RGWInitMultipart::execute(optional_yield y) { - bufferlist aclbl; + bufferlist aclbl, tracebl; rgw::sal::Attrs attrs; if (get_params(y) < 0) @@ -6134,6 +6135,11 @@ void RGWInitMultipart::execute(optional_yield y) if (rgw::sal::Object::empty(s->object.get())) return; + if (multipart_trace) { + tracing::encode(multipart_trace->GetContext(), tracebl); + attrs[RGW_ATTR_TRACE] = tracebl; + } + policy.encode(aclbl); attrs[RGW_ATTR_ACL] = aclbl; @@ -6158,6 +6164,7 @@ void RGWInitMultipart::execute(optional_yield y) upload_id = upload->get_upload_id(); } s->trace->SetAttribute(tracing::rgw::UPLOAD_ID, upload_id); + multipart_trace->UpdateName(tracing::rgw::MULTIPART + upload_id); } @@ -6279,8 +6286,6 @@ void RGWCompleteMultipart::execute(optional_yield y) upload = s->bucket->get_multipart_upload(s->object->get_name(), upload_id); - s->trace->SetAttribute(tracing::rgw::UPLOAD_ID, upload_id); - RGWCompressionInfo cs_info; bool compressed = false; uint64_t accounted_size = 0; @@ -6317,7 +6322,12 @@ void RGWCompleteMultipart::execute(optional_yield y) << " ret=" << op_ret << dendl; return; } + s->trace->SetAttribute(tracing::rgw::UPLOAD_ID, upload_id); + jspan_context trace_ctx(false, false); + extract_span_context(meta_obj->get_attrs(), trace_ctx); + multipart_trace = tracing::rgw::tracer.add_span(name(), trace_ctx); + // make reservation for notification if needed std::unique_ptr res = store->get_notification(meta_obj.get(), s, rgw::notify::ObjectCreatedCompleteMultipartUpload, &s->object->get_name()); @@ -6488,7 +6498,7 @@ void RGWAbortMultipart::execute(optional_yield y) op_ret = -EINVAL; string upload_id; upload_id = s->info.args.get("uploadId"); - rgw_obj meta_obj; + std::unique_ptr meta_obj; std::unique_ptr upload; if (upload_id.empty() || rgw::sal::Object::empty(s->object.get())) @@ -6496,6 +6506,19 @@ void RGWAbortMultipart::execute(optional_yield y) upload = s->bucket->get_multipart_upload(s->object->get_name(), upload_id); RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); + + meta_obj = upload->get_meta_obj(); + meta_obj->set_in_extra_data(true); + op_ret = meta_obj->get_obj_attrs(obj_ctx, s->yield, this); + if (op_ret < 0) { + ldpp_dout(this, 0) << "ERROR: failed to get obj attrs, obj=" << meta_obj + << " ret=" << op_ret << dendl; + return; + } + jspan_context trace_ctx(false, false); + extract_span_context(meta_obj->get_attrs(), trace_ctx); + multipart_trace = tracing::rgw::tracer.add_span(name(), trace_ctx); + op_ret = upload->abort(this, s->cct, obj_ctx); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index fa2c69fab57..8afa37b3cff 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -52,6 +52,7 @@ #include "cls/rgw/cls_rgw_client.h" #include "rgw_public_access.h" #include "rgw_bucket_encryption.h" +#include "rgw_tracer.h" #include "services/svc_sys_obj.h" #include "services/svc_tier_rados.h" @@ -1211,6 +1212,7 @@ protected: std::string multipart_upload_id; std::string multipart_part_str; int multipart_part_num = 0; + jspan multipart_trace; boost::optional delete_at; //append obj @@ -1833,11 +1835,13 @@ protected: std::string upload_id; RGWAccessControlPolicy policy; ceph::real_time mtime; + jspan multipart_trace; public: RGWInitMultipart() {} void init(rgw::sal::Store* store, struct req_state *s, RGWHandler *h) override { + multipart_trace = tracing::rgw::tracer.start_trace(tracing::rgw::MULTIPART); RGWOp::init(store, s, h); policy.set_ctx(s->cct); } @@ -1860,6 +1864,7 @@ protected: std::string version_id; bufferlist data; rgw::sal::MPSerializer* serializer; + jspan multipart_trace; public: RGWCompleteMultipart() : serializer(nullptr) {} @@ -1879,6 +1884,8 @@ public: }; class RGWAbortMultipart : public RGWOp { +protected: + jspan multipart_trace; public: RGWAbortMultipart() {} diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 6bad56ceb32..cfcc987afae 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -17,6 +17,7 @@ #include "rgw_user.h" #include "rgw_notify_event_type.h" +#include "common/tracer.h" class RGWGetDataCB; struct RGWObjState; @@ -1128,7 +1129,7 @@ class MultipartUpload { protected: Bucket* bucket; std::map> parts; - + jspan_context trace_ctx{false, false}; public: MultipartUpload(Bucket* _bucket) : bucket(_bucket) {} virtual ~MultipartUpload() = default; @@ -1147,6 +1148,9 @@ public: /** Get all the cached parts that make up this upload */ std::map>& get_parts() { return parts; } + /** Get the trace context of this upload */ + const jspan_context& get_trace() { return trace_ctx; } + /** Get the Object that represents this upload */ virtual std::unique_ptr get_meta_obj() = 0; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 1bf8417d186..aff124f0267 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -29,6 +29,7 @@ #include "rgw_acl_s3.h" #include "rgw_aio.h" #include "rgw_aio_throttle.h" +#include "rgw_tracer.h" #include "rgw_zone.h" #include "rgw_rest_conn.h" @@ -2379,6 +2380,8 @@ int RadosMultipartUpload::get_info(const DoutPrefixProvider *dpp, optional_yield return ret; } + extract_span_context(meta_obj->get_attrs(), trace_ctx); + if (attrs) { /* Attrs are filled in by prepare */ *attrs = meta_obj->get_attrs(); diff --git a/src/rgw/rgw_tracer.h b/src/rgw/rgw_tracer.h index 4c50b4ea00b..77d4689d257 100644 --- a/src/rgw/rgw_tracer.h +++ b/src/rgw/rgw_tracer.h @@ -3,6 +3,8 @@ #pragma once #include "common/tracer.h" +#include "rgw_common.h" + namespace tracing { namespace rgw { @@ -14,6 +16,7 @@ const auto RETURN = "return"; const auto UPLOAD_ID = "upload_id"; const auto TYPE = "type"; const auto REQUEST = "request"; +const auto MULTIPART = "multipart_upload "; #ifdef HAVE_JAEGER extern thread_local tracing::Tracer tracer; @@ -24,3 +27,12 @@ extern tracing::Tracer tracer; } // namespace rgw } // namespace tracing +static inline void extract_span_context(const rgw::sal::Attrs& attr, jspan_context& span_ctx) { + auto trace_iter = attr.find(RGW_ATTR_TRACE); + if (trace_iter != attr.end()) { + try { + auto trace_bl_iter = trace_iter->second.cbegin(); + tracing::decode(span_ctx, trace_bl_iter); + } catch (buffer::error& err) {} + } +}