Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve retries in dev/run cluster setup #4953

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
nickva committed Jan 6, 2024
commit ac8d01ad8e1629b0b586dc0cb8e9e46f9f6fa150
28 changes: 17 additions & 11 deletions dev/run
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down