Skip to content

Commit fff81c0

Browse files
fix: removing HTTP error checking. (taskcluster#831)
The taskcluster package will return a TaskclusterRestFailure instead of an HTTP error so it can be deprecated
1 parent 8facd85 commit fff81c0

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

src/taskgraph/actions/cancel.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import logging
77

8-
import requests
9-
108
from taskcluster import TaskclusterRestFailure
119
from taskgraph.util.taskcluster import cancel_task
1210

@@ -28,14 +26,8 @@ def cancel_action(parameters, graph_config, input, task_group_id, task_id):
2826
# only cancel tasks with the level-specific schedulerId.
2927
try:
3028
cancel_task(task_id)
31-
except (requests.HTTPError, TaskclusterRestFailure) as e:
32-
status_code = None
33-
if isinstance(e, requests.HTTPError):
34-
status_code = e.response.status_code if e.response else None
35-
elif isinstance(e, TaskclusterRestFailure):
36-
status_code = e.status_code
37-
38-
if status_code == 409:
29+
except TaskclusterRestFailure as e:
30+
if e.status_code == 409:
3931
# A 409 response indicates that this task is past its deadline. It
4032
# cannot be cancelled at this time, but it's also not running
4133
# anymore, so we can ignore this error.

src/taskgraph/actions/cancel_all.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import os
88
from concurrent import futures
99

10-
import requests
11-
1210
from taskcluster import TaskclusterRestFailure
1311
from taskgraph.util.taskcluster import (
1412
CONCURRENCY,
@@ -37,14 +35,8 @@ def do_cancel_task(task_id):
3735
logger.info(f"Cancelling task {task_id}")
3836
try:
3937
cancel_task(task_id)
40-
except (requests.HTTPError, TaskclusterRestFailure) as e:
41-
status_code = None
42-
if isinstance(e, requests.HTTPError):
43-
status_code = e.response.status_code if e.response else None
44-
elif isinstance(e, TaskclusterRestFailure):
45-
status_code = e.status_code
46-
47-
if status_code == 409:
38+
except TaskclusterRestFailure as e:
39+
if e.status_code == 409:
4840
# A 409 response indicates that this task is past its deadline. It
4941
# cannot be cancelled at this time, but it's also not running
5042
# anymore, so we can ignore this error.

src/taskgraph/util/taskcluster.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,11 @@ def get_ancestors(task_ids: Union[list[str], str]) -> dict[str, str]:
467467
for task_id in task_ids:
468468
try:
469469
task_def = get_task_definition(task_id)
470-
except (requests.HTTPError, taskcluster.TaskclusterRestFailure) as e:
470+
except taskcluster.TaskclusterRestFailure as e:
471471
# Task has most likely expired, which means it's no longer a
472472
# dependency for the purposes of this function.
473-
if isinstance(e, requests.HTTPError):
474-
if e.response and e.response.status_code == 404:
475-
continue
476-
elif isinstance(e, taskcluster.TaskclusterRestFailure):
477-
if e.status_code == 404:
478-
continue
473+
if e.status_code == 404:
474+
continue
479475
raise e
480476

481477
dependencies = task_def.get("dependencies", [])

0 commit comments

Comments
 (0)