Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/taskgraph/actions/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import requests

from taskcluster import TaskclusterRestFailure
from taskgraph.util.taskcluster import cancel_task

from .registry import register_callback_action
Expand All @@ -27,8 +28,14 @@ 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 as e:
if e.response.status_code == 409:
except (requests.HTTPError, TaskclusterRestFailure) as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to catch HTTPError? I didn't think it would still be possible to get this, same Q for the other two places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think is possible either, I wanted to keep to air on the side of caution and remove it a later in a less sensitive time

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good, I don't see any harm in leaving it for now.. Though maybe file an issue to clean it up later?

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:
# 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.
Expand Down
11 changes: 9 additions & 2 deletions src/taskgraph/actions/cancel_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import requests

from taskcluster import TaskclusterRestFailure
from taskgraph.util.taskcluster import (
CONCURRENCY,
cancel_task,
Expand Down Expand Up @@ -36,8 +37,14 @@ def do_cancel_task(task_id):
logger.info(f"Cancelling task {task_id}")
try:
cancel_task(task_id)
except requests.HTTPError as e:
if e.response.status_code == 409:
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:
# 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.
Expand Down
3 changes: 2 additions & 1 deletion src/taskgraph/actions/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from functools import reduce

from requests.exceptions import HTTPError
from taskcluster.exceptions import TaskclusterRestFailure

from taskgraph import create
from taskgraph.decision import read_artifact, rename_artifact, write_artifact
Expand All @@ -36,7 +37,7 @@ def fetch_graph_and_labels(parameters, graph_config, task_group_id=None):
try:
# Look up the decision_task id in the index
decision_task_id = find_decision_task(parameters, graph_config)
except KeyError:
except (KeyError, TaskclusterRestFailure):
if not task_group_id:
raise
# Not found (e.g. from github-pull-request), fall back to the task group id.
Expand Down
4 changes: 3 additions & 1 deletion src/taskgraph/optimize/strategies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
from datetime import datetime

from taskcluster.exceptions import TaskclusterRestFailure

from taskgraph.optimize.base import OptimizationStrategy, register_strategy
from taskgraph.util.path import match as match_path
from taskgraph.util.taskcluster import find_task_id, status_task
Expand Down Expand Up @@ -64,7 +66,7 @@ def should_replace_task(self, task, params, deadline, arg):
continue

return task_id
except KeyError:
except (KeyError, TaskclusterRestFailure):
# go on to the next index path
pass

Expand Down
10 changes: 7 additions & 3 deletions src/taskgraph/util/taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,15 @@ 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 as e:
except (requests.HTTPError, taskcluster.TaskclusterRestFailure) as e:
# Task has most likely expired, which means it's no longer a
# dependency for the purposes of this function.
if e.response.status_code == 404:
continue
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
raise e

dependencies = task_def.get("dependencies", [])
Expand Down
Loading