Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

mark task as failued if ADO notification fails #77

Merged
merged 2 commits into from
Oct 2, 2020
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
31 changes: 28 additions & 3 deletions src/api-service/__app__/onefuzzlib/notifications/ado.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
WorkItemTrackingClient,
)
from memoization import cached
from onefuzztypes.models import ADOTemplate, Report
from onefuzztypes.enums import ErrorCode, TaskState
from onefuzztypes.models import ADOTemplate, Error, Report

from ..tasks.main import Task
from .common import Render


Expand Down Expand Up @@ -194,13 +196,36 @@ def process(self) -> None:
self.create_new()


def fail_task(report: Report, error: Exception) -> None:
logging.error(
"ADO report failed: job_id:%s task_id:%s err:%s",
report.job_id,
report.task_id,
error,
)

task = Task.get(report.job_id, report.task_id)
if task:
task.error = Error(code=ErrorCode.NOTIFICATION_FAILURE, errors=[str(error)])
task.state = TaskState.stopping
task.save()


def notify_ado(
config: ADOTemplate, container: str, filename: str, report: Report
) -> None:
logging.info(
"notify ado: job_id:%s task_id:%s container:%s filename:%s",
report.job_id,
report.task_id,
container,
filename,
)

try:
ado = ADO(container, filename, config, report)
ado.process()
except AzureDevOpsServiceError as err:
logging.error("ADO report failed: %s", err)
fail_task(report, err)
except ValueError as err:
logging.error("ADO report value error: %s", err)
fail_task(report, err)
1 change: 1 addition & 0 deletions src/pytypes/onefuzztypes/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class ErrorCode(Enum):
UNABLE_TO_FIND = 467
TASK_FAILED = 468
INVALID_NODE = 469
NOTIFICATION_FAILURE = 470


class HeartbeatType(Enum):
Expand Down