From a4b906009701879dc6b7b2686c5b465b4a9e47f2 Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Wed, 3 Apr 2024 13:15:38 +0530 Subject: [PATCH] rgw/cloud: Handle RGWRESTStreamS3PutObj initialization failures With the recent code added to handle connection errors (commit#e200499bb3c5703862b92a4d7fb534d98601f1bf), RGWRESTStreamS3PutObj initialization could fail at times if there were any failed requests to the cloud endpoint within CONN_STATUS_EXPIRE_SECS period. This fix is to handle such errors and abort the transition/sync requests which can be retried later by LC/Sync worker threads. Signed-off-by: Soumya Koduri --- src/rgw/driver/rados/rgw_lc_tier.cc | 11 +++++++++-- src/rgw/driver/rados/rgw_sync_module_aws.cc | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/rgw/driver/rados/rgw_lc_tier.cc b/src/rgw/driver/rados/rgw_lc_tier.cc index 67df024459572..9fbc931ebcb95 100644 --- a/src/rgw/driver/rados/rgw_lc_tier.cc +++ b/src/rgw/driver/rados/rgw_lc_tier.cc @@ -486,6 +486,7 @@ int RGWLCStreamRead::read(off_t ofs, off_t end, RGWGetDataCB *out_cb) { } int RGWLCCloudStreamPut::init() { + int ret = -1; /* init output connection */ if (multipart.is_multipart) { char buf[32]; @@ -493,9 +494,14 @@ int RGWLCCloudStreamPut::init() { rgw_http_param_pair params[] = { { "uploadId", multipart.upload_id.c_str() }, { "partNumber", buf }, { nullptr, nullptr } }; - conn.put_obj_send_init(dest_obj, params, &out_req); + ret = conn.put_obj_send_init(dest_obj, params, &out_req); } else { - conn.put_obj_send_init(dest_obj, nullptr, &out_req); + ret = conn.put_obj_send_init(dest_obj, nullptr, &out_req); + } + + if (ret < 0 || !out_req) { + ldpp_dout(dpp, 0) << "ERROR: failed to create RGWRESTStreamS3PutObj request" << dendl; + return ret; } return 0; @@ -651,6 +657,7 @@ void RGWLCCloudStreamPut::init_send_attrs(const DoutPrefixProvider *dpp, void RGWLCCloudStreamPut::send_ready(const DoutPrefixProvider *dpp, const rgw_rest_obj& rest_obj) { auto r = static_cast(out_req); + ceph_assert(r); std::map new_attrs; if (!multipart.is_multipart) { diff --git a/src/rgw/driver/rados/rgw_sync_module_aws.cc b/src/rgw/driver/rados/rgw_sync_module_aws.cc index 3c269a7494986..19be83351e1d3 100644 --- a/src/rgw/driver/rados/rgw_sync_module_aws.cc +++ b/src/rgw/driver/rados/rgw_sync_module_aws.cc @@ -821,6 +821,7 @@ public: int init() override { /* init output connection */ RGWRESTStreamS3PutObj *out_req{nullptr}; + int ret = -1; if (multipart.is_multipart) { char buf[32]; @@ -828,9 +829,13 @@ public: rgw_http_param_pair params[] = { { "uploadId", multipart.upload_id.c_str() }, { "partNumber", buf }, { nullptr, nullptr } }; - target->conn->put_obj_send_init(dest_obj, params, &out_req); + ret = target->conn->put_obj_send_init(dest_obj, params, &out_req); } else { - target->conn->put_obj_send_init(dest_obj, nullptr, &out_req); + ret = target->conn->put_obj_send_init(dest_obj, nullptr, &out_req); + } + + if (ret < 0 || !out_req) { + return ret; } set_req(out_req); -- 2.39.5