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

lock/query: make robust against paddles errors #1642

Merged
merged 1 commit into from
Apr 29, 2021
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
38 changes: 24 additions & 14 deletions teuthology/lock/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from teuthology import misc
from teuthology.config import config
from teuthology.contextutil import safe_while
from teuthology.util.compat import urlencode


Expand All @@ -14,13 +15,15 @@
def get_status(name):
name = misc.canonicalize_hostname(name, user=None)
uri = os.path.join(config.lock_server, 'nodes', name, '')
response = requests.get(uri)
success = response.ok
if success:
return response.json()
with safe_while(
sleep=1, increment=0.5, action=f'get_status {name}') as proceed:
while proceed():
response = requests.get(uri)
if response.ok:
return response.json()
log.warning(
"Failed to query lock server for status of {name}".format(name=name))
return None
return dict()


def get_statuses(machines):
Expand Down Expand Up @@ -59,14 +62,16 @@ def list_locks(keyed_by_name=False, **kwargs):
if 'machine_type' in kwargs:
kwargs['machine_type'] = kwargs['machine_type'].replace(',','|')
uri += '?' + urlencode(kwargs)
try:
response = requests.get(uri)
except requests.ConnectionError:
success = False
log.exception("Could not contact lock server: %s", config.lock_server)
else:
success = response.ok
if success:
with safe_while(
sleep=1, increment=0.5, action='list_locks') as proceed:
while proceed():
try:
response = requests.get(uri)
if response.ok:
break
except requests.ConnectionError:
log.exception("Could not contact lock server: %s, retrying...", config.lock_server)
if response.ok:
if not keyed_by_name:
return response.json()
else:
Expand Down Expand Up @@ -122,7 +127,12 @@ def node_job_is_active(node, cache):
(name, job_id) = description.split('/')[-2:]
url = os.path.join(config.results_server, 'runs', name, 'jobs', job_id,
'')
resp = requests.get(url)
with safe_while(
sleep=1, increment=0.5, action='node_is_active') as proceed:
while proceed():
resp = requests.get(url)
if resp.ok:
break
if not resp.ok:
return False
job_info = resp.json()
Expand Down