Skip to content

Commit 9f88fe0

Browse files
authored
Merge pull request ceph#61942 from 9401adarsh/wip-adashoka-51855
rgw: add parameter for clients to time out incase they hit wrong url Reviewed-by: Yuval Lifshitz <[email protected]>
2 parents 38bd9e7 + 0a4be81 commit 9f88fe0

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/rgw/driver/rados/rgw_pubsub_push.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class RGWPubSubHTTPEndpoint : public RGWPubSubEndpoint {
101101
}
102102
bufferlist read_bl;
103103
RGWPostHTTPData request(cct, "POST", endpoint, &read_bl, verify_ssl);
104+
//default to 3 seconds for wrong url hits - if wrong endpoint configured
105+
request.set_req_connect_timeout(3);
104106
const auto post_data = json_format_pubsub_event(event);
105107
if (cloudevents) {
106108
// following: https://github.com/cloudevents/spec/blob/v1.0.1/http-protocol-binding.md

src/rgw/rgw_http_client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ int RGWHTTPClient::init_request(rgw_http_req_data *_req_data)
635635
}
636636
curl_easy_setopt(easy_handle, CURLOPT_PRIVATE, (void *)req_data);
637637
curl_easy_setopt(easy_handle, CURLOPT_TIMEOUT, req_timeout);
638+
curl_easy_setopt(easy_handle, CURLOPT_CONNECTTIMEOUT, req_connect_timeout);
638639

639640
return 0;
640641
}

src/rgw/rgw_http_client.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class RGWHTTPClient : public RGWIOProvider,
6464
param_vec_t headers;
6565

6666
long req_timeout{0L};
67+
long req_connect_timeout{0L};
6768

6869
void init();
6970

@@ -151,6 +152,12 @@ class RGWHTTPClient : public RGWIOProvider,
151152
req_timeout = timeout;
152153
}
153154

155+
// set request for connect phase timeout in seconds.
156+
// ensures wrong url hits don't stay alive post this limit
157+
void set_req_connect_timeout(long connect_timeout) {
158+
req_connect_timeout = connect_timeout;
159+
}
160+
154161
int process(const DoutPrefixProvider* dpp, optional_yield y);
155162

156163
int wait(const DoutPrefixProvider* dpp, optional_yield y);

0 commit comments

Comments
 (0)