Skip to content

Skip test task when its build no longer exists - #241

Merged
anfimovdm merged 2 commits into
clfrom
al-alts-check-build-exists
Nov 5, 2026
Merged

anfimovdm merged 2 commits into
clfrom
al-alts-check-build-exists

Conversation

@anfimovdm

@anfimovdm anfimovdm commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Before running tests, the worker checks the build still exists in the build system and skips the task when it answers 404. This avoids spending a VM/container on tests whose result callback would be rejected anyway (e.g. the build was deleted while the task waited in the queue).

Changes

  • alts/worker/tasks.py: new build_exists() helper. Takes the build id from callback_href (/api/v1/tests/<build_id>/...) and sends GET to the build endpoint. run_tests returns early on a 404. On any other status, request error, or a callback_href without a build id, the tests run as usual. The check runs again on each Celery retry.
  • alts/shared/models.py: new bs_build_endpoint config option, defaults to /api/v1/builds/{build_id}/.
  • tests/worker/test_tasks.py: new unit tests for build_exists() and run_tests. They also cover the 4xx callback change from Don't retry test task on 4xx callback errors #240.

Notes

  • The build id isn't in the task payload (bs_task_id is the package id), so it's parsed from callback_href.
  • GET /api/v1/builds/<id>/ returns the full build document. It's one request per task, with a 30s timeout.

Testing

  • CELERY_CONFIG_PATH=tests/tests_config.yaml SCHEDULER_CONFIG_PATH=tests/tests_config.yaml pytest tests/worker tests/scheduler: 21 passed (14 new).
  • The new tests cover:
    • build_exists(): only a 404 counts as missing; 200, 403, 500, a connection error, or a callback_href without a build id all let the tests run.
    • run_tests on a missing build: returns None without creating a runner or posting a callback.
    • A 4xx callback answer: the summary is returned and the task isn't retried.
    • A 5xx callback answer: retry() is called and HTTPError is raised.
  • Breaking either change on purpose makes the matching tests fail.
  • The runner and HTTP calls are mocked; no real Docker, OpenNebula or build-system run.

🤖 Generated with Claude Code

Before running tests, the worker requests the build from the build system (build id taken from callback_href) and skips the task on a 404, instead of spending a VM on tests whose result would be rejected. Any other answer or a request error runs the tests as usual.
Cover build_exists answers, skipping tests of a missing build, and that a 4xx callback answer ends the task while a 5xx one still retries it.
@anfimovdm
anfimovdm merged commit c6bdeca into cl Nov 5, 2026
1 of 3 checks passed
@anfimovdm
anfimovdm deleted the al-alts-check-build-exists branch November 5, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant