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

Commit

Permalink
log the work item id when notifying ado (#2291)
Browse files Browse the repository at this point in the history
* log the work item id when notifying ado

* format

* refactoring

* fix build

* fix

* format
  • Loading branch information
chkeita authored Aug 26, 2022
1 parent 55a29cf commit c94ae0b
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/api-service/__app__/onefuzzlib/notifications/ado.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def existing_work_items(self) -> Iterator[WorkItem]:
continue
yield item

def update_existing(self, item: WorkItem) -> None:
def update_existing(self, item: WorkItem, notification_info: str) -> None:
if self.config.on_duplicate.comment:
comment = self.render(self.config.on_duplicate.comment)
self.client.add_comment(
Expand Down Expand Up @@ -175,6 +175,13 @@ def update_existing(self, item: WorkItem) -> None:

if document:
self.client.update_work_item(document, item.id, project=self.project)
logging.info(
f"notify ado: updated work item {item.id} - {notification_info}"
)
else:
logging.info(
f"notify ado: no update for work item {item.id} - {notification_info}"
)

def render_new(self) -> Tuple[str, List[JsonPatchOperation]]:
task_type = self.render(self.config.type)
Expand All @@ -195,7 +202,7 @@ def render_new(self) -> Tuple[str, List[JsonPatchOperation]]:
)
return (task_type, document)

def create_new(self) -> None:
def create_new(self) -> WorkItem:
task_type, document = self.render_new()

entry = self.client.create_work_item(
Expand All @@ -209,15 +216,19 @@ def create_new(self) -> None:
self.project,
entry.id,
)
return entry

def process(self) -> None:
def process(self, notification_info: str) -> None:
seen = False
for work_item in self.existing_work_items():
self.update_existing(work_item)
self.update_existing(work_item, notification_info)
seen = True

if not seen:
self.create_new()
entry = self.create_new()
logging.info(
"notify ado: created new work item" f" {entry.id} - {notification_info}"
)


def is_transient(err: Exception) -> bool:
Expand Down Expand Up @@ -251,18 +262,16 @@ def notify_ado(
return

notification_info = (
"job_id:%s task_id:%s container:%s filename:%s",
report.job_id,
report.task_id,
container,
filename,
f"job_id:%s{report.job_id} task_id:{report.task_id}"
f" container:{container} filename:{filename}"
)

logging.info("notify ado: %s", notification_info)

try:
ado = ADO(container, filename, config, report)
ado.connect()
ado.process()
ado.process(notification_info)
except (
AzureDevOpsAuthenticationError,
AzureDevOpsClientError,
Expand Down

0 comments on commit c94ae0b

Please sign in to comment.