This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch import-cluster-setup-retries in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ac8d01ad8e1629b0b586dc0cb8e9e46f9f6fa150 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Sat Jan 6 16:32:29 2024 -0500 Improve retries in dev/run cluster setup Noticed we still get connection refused errors for nouveau tests cluster setup tests. Try to handle retries for connection errors which are thrown not just due to a status code. After retries are exhausted, then fail as before. --- dev/run | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/dev/run b/dev/run index f4b689929..078bb14b5 100755 --- a/dev/run +++ b/dev/run @@ -1104,17 +1104,23 @@ def try_request( ): while True: conn = httpclient.HTTPConnection(host, port) - if headers is not None: - conn.request(meth, path, body=body, headers=headers) - else: - conn.request(meth, path, body=body) - resp = conn.getresponse() - if resp.status in success_codes: - result = (resp.status, resp.read()) - resp.close() - return result - elif retries <= 0: - assert resp.status in success_codes, "%s%s" % (error, resp.read()) + try: + if headers is not None: + conn.request(meth, path, body=body, headers=headers) + else: + conn.request(meth, path, body=body) + resp = conn.getresponse() + if resp.status in success_codes: + result = (resp.status, resp.read()) + resp.close() + return result + elif retries <= 0: + assert resp.status in success_codes, "%s%s" % (error, resp.read()) + except Exception as e: + if retries <= 0: + print("Connection failed %s %s" % (e, error)) + raise e + print("Retrying ... %s " % e) retries -= 1 time.sleep(retry_dt)
