Bug 1330385 - Make the job priorities endpoint work for tc; r=jmaher

MozReview-Commit-ID: Fl4jbyNKnGz

--HG--
extra : rebase_source : aa175aba6adfa11ce20b53a6247eb3803aea4b23
This commit is contained in:
Rob Wood 2017-02-01 18:00:44 -05:00
Родитель a2a797193b
Коммит 95470fc250
1 изменённых файлов: 22 добавлений и 5 удалений

Просмотреть файл

@ -32,6 +32,18 @@ class SETA(object):
# cached push_ids that failed to retrieve datetime for # cached push_ids that failed to retrieve datetime for
self.failed_json_push_calls = [] self.failed_json_push_calls = []
def _get_task_string(self, task_tuple):
# convert task tuple to single task string, so the task label sent in can match
# remove any empty parts of the tuple
task_tuple = [x for x in task_tuple if len(x) != 0]
if len(task_tuple) == 0:
return ''
if len(task_tuple) != 3:
return ' '.join(task_tuple)
return 'test-%s/%s-%s' % (task_tuple[0], task_tuple[1], task_tuple[2])
def query_low_value_tasks(self, project): def query_low_value_tasks(self, project):
# Request the set of low value tasks from the SETA service. Low value tasks will be # Request the set of low value tasks from the SETA service. Low value tasks will be
# optimized out of the task graph. # optimized out of the task graph.
@ -47,12 +59,17 @@ class SETA(object):
args=(url, ), args=(url, ),
kwargs={'timeout': 5, 'headers': headers}) kwargs={'timeout': 5, 'headers': headers})
task_list = json.loads(response.content).get('jobtypes', '') task_list = json.loads(response.content).get('jobtypes', '')
if len(task_list) > 0:
low_value_tasks = task_list.values()[0]
# Bug 1315145, disable SETA for tier-1 platforms until backfill is implemented. if type(task_list) == dict and len(task_list) > 0:
low_value_tasks = [x for x in low_value_tasks if x.find('debug') == -1] if type(task_list.values()[0]) == list and len(task_list.values()[0]) > 0:
low_value_tasks = [x for x in low_value_tasks if x.find('asan') == -1] low_value_tasks = task_list.values()[0]
# bb job types return a list instead of a single string,
# convert to a single string to match tc tasks format
if type(low_value_tasks[0]) == list:
low_value_tasks = [self._get_task_string(x) for x in low_value_tasks]
# ensure no build tasks slipped in, we never want to optimize out those
low_value_tasks = [x for x in low_value_tasks if 'build' not in x.lower()]
# In the event of request times out, requests will raise a TimeoutError. # In the event of request times out, requests will raise a TimeoutError.
except exceptions.Timeout: except exceptions.Timeout: