Bug 1517645 - fix list_task_group and rename it
authorDustin J. Mitchell <dustin@mozilla.com>
Mon, 07 Jan 2019 17:52:14 +0000
changeset 511125 e256dba8d711838fdb983f287d8f0311241cb8ff
parent 511124 53380666b5c70c68da513dc8ba0c8ff7dfca48c5
child 511126 26624f7c3b4d591883f159fc2c7ee3900049a836
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1517645
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517645 - fix list_task_group and rename it Reviewers: bstack Subscribers: tomprince Tags: #secure-revision Bug #: 1517645 Differential Revision: https://phabricator.services.mozilla.com/D15855
taskcluster/taskgraph/actions/cancel_all.py
taskcluster/taskgraph/util/taskcluster.py
--- a/taskcluster/taskgraph/actions/cancel_all.py
+++ b/taskcluster/taskgraph/actions/cancel_all.py
@@ -6,17 +6,17 @@
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import concurrent.futures as futures
 import logging
 import os
 
 from taskgraph.util.taskcluster import (
-    list_task_group,
+    list_task_group_incomplete_tasks,
     cancel_task,
     CONCURRENCY,
 )
 from .registry import register_callback_action
 
 logger = logging.getLogger(__name__)
 
 
@@ -34,15 +34,14 @@ logger = logging.getLogger(__name__)
     context=[]
 )
 def cancel_all_action(parameters, graph_config, input, task_group_id, task_id, task):
     def do_cancel_task(task_id):
         logger.info('Cancelling task {}'.format(task_id))
         cancel_task(task_id, use_proxy=True)
 
     own_task_id = os.environ.get('TASK_ID', '')
+    to_cancel = [t for t in list_task_group_incomplete_tasks(task_group_id) if t != own_task_id]
+    logger.info("Cancelling {} tasks".format(len(to_cancel)))
     with futures.ThreadPoolExecutor(CONCURRENCY) as e:
-        cancel_futs = [
-            e.submit(do_cancel_task, t)
-            for t in list_task_group(task_group_id) if t != own_task_id
-        ]
+        cancel_futs = [e.submit(do_cancel_task, t) for t in to_cancel]
         for f in futures.as_completed(cancel_futs):
             f.result()
--- a/taskcluster/taskgraph/util/taskcluster.py
+++ b/taskcluster/taskgraph/util/taskcluster.py
@@ -68,17 +68,17 @@ def get_session():
     return session
 
 
 def _do_request(url, force_get=False, **kwargs):
     session = get_session()
     if kwargs and not force_get:
         response = session.post(url, **kwargs)
     else:
-        response = session.get(url, stream=True)
+        response = session.get(url, stream=True, **kwargs)
     if response.status_code >= 400:
         # Consume content before raise_for_status, so that the connection can be
         # reused.
         response.content
     response.raise_for_status()
     return response
 
 
@@ -276,18 +276,18 @@ def send_email(address, subject, content
     _do_request(url, json={
         'address': address,
         'subject': subject,
         'content': content,
         'link': link,
     })
 
 
-def list_task_group(task_group_id):
-    """Generate the tasks in a task group"""
+def list_task_group_incomplete_tasks(task_group_id):
+    """Generate the incomplete tasks in a task group"""
     params = {}
     while True:
         url = liburls.api(get_root_url(), 'queue', 'v1',
                           'task-group/{}/list'.format(task_group_id))
         resp = _do_request(url, force_get=True, params=params).json()
         for task in [t['status'] for t in resp['tasks']]:
             if task['state'] in ['running', 'pending', 'unscheduled']:
                 yield task['taskId']