Bug 1472776: add a 'cancel' action to cancel one task; r?tomprince draft
authorDustin J. Mitchell <dustin@mozilla.com>
Wed, 27 Jun 2018 15:01:40 +0000
changeset 813792 be764bc4969acbffe6d948d0683be1595fb44b54
parent 810823 348090c6b5c421c67b9dccc48742b54a854d6d0e
push id115010
push userdmitchell@mozilla.com
push dateTue, 03 Jul 2018 21:56:46 +0000
reviewerstomprince
bugs1472776
milestone63.0a1
Bug 1472776: add a 'cancel' action to cancel one task; r?tomprince MozReview-Commit-ID: E3MTcM4TR7e
taskcluster/taskgraph/actions/cancel.py
new file mode 100644
--- /dev/null
+++ b/taskcluster/taskgraph/actions/cancel.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from taskgraph.util.taskcluster import cancel_task
+from .registry import register_callback_action
+
+
+@register_callback_action(
+    title='Cancel Task',
+    name='cancel',
+    symbol='cx',
+    kind='hook',
+    generic=True,
+    description=(
+        'Cancel the given task'
+    ),
+    order=100,
+    context=[{}]
+)
+def cancel_action(parameters, graph_config, input, task_group_id, task_id, task):
+    # Note that this is limited by the scopes afforded to generic actions to
+    # only cancel tasks with the level-specific schedulerId.
+    cancel_task(task_id, use_proxy=True)