From 56b704f3ae277d33570aecb0285a4bdd3c47cef8 Mon Sep 17 00:00:00 2001 From: abhishekmadan30 Date: Mon, 20 Oct 2025 11:43:09 -0400 Subject: [PATCH] fix: removing HTTP error checking. The taskcluster package will return a TaskclusterRestFailure instead of an HTTP error so it can be deprecated --- src/taskgraph/actions/cancel.py | 12 ++---------- src/taskgraph/actions/cancel_all.py | 12 ++---------- src/taskgraph/util/taskcluster.py | 10 +++------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/taskgraph/actions/cancel.py b/src/taskgraph/actions/cancel.py index 014e2b762..0ddd52903 100644 --- a/src/taskgraph/actions/cancel.py +++ b/src/taskgraph/actions/cancel.py @@ -5,8 +5,6 @@ import logging -import requests - from taskcluster import TaskclusterRestFailure from taskgraph.util.taskcluster import cancel_task @@ -28,14 +26,8 @@ def cancel_action(parameters, graph_config, input, task_group_id, task_id): # only cancel tasks with the level-specific schedulerId. try: cancel_task(task_id) - except (requests.HTTPError, TaskclusterRestFailure) as e: - status_code = None - if isinstance(e, requests.HTTPError): - status_code = e.response.status_code if e.response else None - elif isinstance(e, TaskclusterRestFailure): - status_code = e.status_code - - if status_code == 409: + except TaskclusterRestFailure as e: + if e.status_code == 409: # A 409 response indicates that this task is past its deadline. It # cannot be cancelled at this time, but it's also not running # anymore, so we can ignore this error. diff --git a/src/taskgraph/actions/cancel_all.py b/src/taskgraph/actions/cancel_all.py index 53f7b24cd..619b2fb7f 100644 --- a/src/taskgraph/actions/cancel_all.py +++ b/src/taskgraph/actions/cancel_all.py @@ -7,8 +7,6 @@ import os from concurrent import futures -import requests - from taskcluster import TaskclusterRestFailure from taskgraph.util.taskcluster import ( CONCURRENCY, @@ -37,14 +35,8 @@ def do_cancel_task(task_id): logger.info(f"Cancelling task {task_id}") try: cancel_task(task_id) - except (requests.HTTPError, TaskclusterRestFailure) as e: - status_code = None - if isinstance(e, requests.HTTPError): - status_code = e.response.status_code if e.response else None - elif isinstance(e, TaskclusterRestFailure): - status_code = e.status_code - - if status_code == 409: + except TaskclusterRestFailure as e: + if e.status_code == 409: # A 409 response indicates that this task is past its deadline. It # cannot be cancelled at this time, but it's also not running # anymore, so we can ignore this error. diff --git a/src/taskgraph/util/taskcluster.py b/src/taskgraph/util/taskcluster.py index 17ce6f9a5..a4b12dff3 100644 --- a/src/taskgraph/util/taskcluster.py +++ b/src/taskgraph/util/taskcluster.py @@ -476,15 +476,11 @@ def get_ancestors(task_ids: Union[list[str], str]) -> dict[str, str]: for task_id in task_ids: try: task_def = get_task_definition(task_id) - except (requests.HTTPError, taskcluster.TaskclusterRestFailure) as e: + except taskcluster.TaskclusterRestFailure as e: # Task has most likely expired, which means it's no longer a # dependency for the purposes of this function. - if isinstance(e, requests.HTTPError): - if e.response and e.response.status_code == 404: - continue - elif isinstance(e, taskcluster.TaskclusterRestFailure): - if e.status_code == 404: - continue + if e.status_code == 404: + continue raise e dependencies = task_def.get("dependencies", [])