Fix 404 on log retrieval for retries of a step

Retries of a step may execute on different workers.
Each worker only exposes the logs that were generated by that worker.
When assembling the URL for the step, we need to ensure
that we include the retry number as part of the key lookup for a step,
so that it can use the correct worker reference.

Updated ActionsHelper.get_step to use try_number.
The test is included.

Change-Id: I2f8cf9ed70ce344f53ecdcc4edbec924ba6a00c9
This commit is contained in:
skovaleff
2018-09-10 19:36:26 -07:00
parent e022b0178d
commit 9f453dd22b
3 changed files with 151 additions and 3 deletions

View File

@@ -145,15 +145,23 @@ class ActionsHelper(object):
return steps
def get_step(self, step_id):
def get_step(self, step_id, try_number=None):
"""
:param step_id: Step ID - task_id in db
:param try_number: Number of try - try_number in db
returns: Step
"""
# Retrieve step. Note that we will get a list and it will
# be the content of step[0]
step_list = [x for x in
self._get_all_steps()
if step_id == x['task_id']]
if step_id == x['task_id'] and
(try_number is None or try_number == x['try_number'])
]
# try_number is needed to get correct task from correct worker
# the worker host for request URL
# is referenced in correct task's 'hostname' field
if not step_list:
raise ApiError(