Repository navigation
Skip test task when its build no longer exists - #241
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: newbuild_exists()helper. Takes the build id fromcallback_href(/api/v1/tests/<build_id>/...) and sendsGETto the build endpoint.run_testsreturns early on a 404. On any other status, request error, or acallback_hrefwithout a build id, the tests run as usual. The check runs again on each Celery retry.alts/shared/models.py: newbs_build_endpointconfig option, defaults to/api/v1/builds/{build_id}/.tests/worker/test_tasks.py: new unit tests forbuild_exists()andrun_tests. They also cover the 4xx callback change from Don't retry test task on 4xx callback errors #240.Notes
bs_task_idis the package id), so it's parsed fromcallback_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).build_exists(): only a 404 counts as missing; 200, 403, 500, a connection error, or acallback_hrefwithout a build id all let the tests run.run_testson a missing build: returnsNonewithout creating a runner or posting a callback.retry()is called andHTTPErroris raised.🤖 Generated with Claude Code