Skip to content

Commit

Permalink
Unset srpm url if all tasks have failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwaizer committed Sep 25, 2024
1 parent 350f851 commit b1cb97f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion alws/dramatiq/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
from alws.crud import build_node as build_node_crud
from alws.crud import test
from alws.crud.build_node import get_failed_build_tasks_matrix
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.errors import (
Expand Down Expand Up @@ -183,6 +184,31 @@ async def _build_done(request: build_node_schema.BuildDone):
await build_node_crud.fast_fail_other_tasks_by_ref(db, build_task)
await db.flush()

build_id = await _get_build_id(db, request.task_id)

# We need to unset srpm_url if all tasks failed
build_tasks = await db.execute(
select(models.BuildTask).where(
models.BuildTask.build_id == build_id,
models.BuildTask.ref_id == build_task.ref_id,
)
)
for tasks_dicts in build_tasks.values():
failed_tasks = [
task
for task in tasks_dicts.values()
if task.status == BuildTaskStatus.FAILED
]
drop_srpm = False
if len(failed_tasks) == len(tasks_dicts):
drop_srpm = True

for task in failed_tasks:
if task.built_srpm_url and drop_srpm:
task.built_srpm_url = None

await db.flush()

# We don't want to create the test tasks until all build tasks
# of the same build_id are completed.
# The last completed task will trigger the creation of the test tasks
Expand All @@ -192,7 +218,6 @@ async def _build_done(request: build_node_schema.BuildDone):
)

if all_build_tasks_completed:
build_id = await _get_build_id(db, request.task_id)
cancel_testing = (
await db.execute(
select(models.Build.cancel_testing).where(
Expand Down

0 comments on commit b1cb97f

Please sign in to comment.