Skip to content

Commit 3494bcd

Browse files
fix(event): use fallback for accepted time (#2335)
fix(event): use fallback for accepted time When submitting failed Copr builds to the Pushgateway, we're using time of accepting the task, in some cases we don't have time of accepting, so use ‹created_at› as a fallback. Fixes #2258 Not sure about this change, since for the last occurrence in Sentry the difference between the reported time of failure and created_at is 5 minutes. I can the ‹task_accepted_time› only in DB, but this is happening even before the build starts, cause it's coming from an issue caused by submitting the build, so I would say that we should use the datetime.now()? But OTOH it doesn't feel like it's skipping the Celere queue and being handled right away. Reviewed-by: Maja Massarini
2 parents d22622b + 7e82c64 commit 3494bcd

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packit_service/worker/events/event.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ def from_event_dict(cls, event: dict):
113113
commit_sha = event.get("commit_sha")
114114
identifier = event.get("identifier")
115115
issue_id = event.get("issue_id")
116+
117+
time = event.get("task_accepted_time")
116118
task_accepted_time = (
117-
datetime.fromtimestamp(event.get("task_accepted_time"), timezone.utc)
118-
if event.get("task_accepted_time")
119-
else None
119+
datetime.fromtimestamp(time, timezone.utc) if time else None
120120
)
121+
121122
build_targets_override = event.get("build_targets_override")
122123
tests_targets_override = event.get("tests_targets_override")
123124
branches_override = event.get("branches_override")

packit_service/worker/helpers/build/copr_build.py

+11
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,17 @@ def monitor_not_submitted_copr_builds(self, number_of_builds: int, reason: str):
394394
Measure the time it took to set the failed status in case of event (e.g. failed SRPM)
395395
that prevents Copr build to be submitted.
396396
"""
397+
398+
# NOTE: When there is no ‹task_accepted_time›, we skip the submission to
399+
# the metrics, since there is no delay between the submission and
400+
# failure. We could probably track those by a separate metric as
401+
# suggested by Maja in the PR.
402+
if self.metadata.task_accepted_time is None:
403+
logger.warning(
404+
"No task_accepted_time for failed Copr build with reason: %s", reason
405+
)
406+
return
407+
397408
time = elapsed_seconds(
398409
begin=self.metadata.task_accepted_time, end=datetime.now(timezone.utc)
399410
)

0 commit comments

Comments
 (0)