Add build timeout handling and TIMED_OUT state #204
+371
−62
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.
Fixes #201
Summary
This PR implements a 15-minute timeout for builds to prevent them from remaining indefinitely in the
RUNNINGstate. It introduces a newTIMED_OUTbuild state and enforces timeout handling independently in the builder and progress updater, following maintainer guidance.Changes Made
1. Core Timeout Infrastructure
BuildState.TIMED_OUTto represent builds terminated due to timeoutBUILD_TIMEOUT_SECONDS = 900) incommon/config.pytime_started_runningtoBuildInfoto track when a build actually begins executionerror_messagetoBuildInfoto store timeout and failure details2. Builder (
builder/builder.py)configure,clean,build) usingtimeout=BUILD_TIMEOUT_SECONDSsubprocess.TimeoutExpired:__check_if_timed_out()to detect if the progress updater has already marked a build asTIMED_OUT3. Build Manager (
build_manager/manager.py)mark_build_timed_out()to safely transition builds toTIMED_OUTSUCCESS,FAILURE)time_started_runningwhen a build enters theRUNNINGstateBuildInfo.to_dict()usinggetattr()to maintain backward compatibility with existing Redis entries4. Progress Updater (
build_manager/progress_updater.py)__check_build_timeout()invoked from the existing periodic update looptime_started_running(nottime_created) for accuracytime_started_runningis not yet availableTIMED_OUTonce the timeout threshold is exceededTIMED_OUTin state and progress update paths5. Web API (
web/app.py)/api/builds/<build_id>/statusendpoint for lightweight pollingget_all_builds()by skipping and logging individual build errors instead of failing the entire requestremote_name/commit_ref)Implementation Details
As suggested by the maintainer, timeout handling is implemented independently in two places:
Builder subprocess timeout
Each subprocess call is bounded by
BUILD_TIMEOUT_SECONDS. If exceeded, the process is terminated and the build is aborted.Progress updater timeout detection
The existing periodic task checks whether any
RUNNINGbuild has exceeded the timeout since entering the running state and marks it asTIMED_OUT.Both mechanisms coordinate via
BuildState.TIMED_OUT:This preserves separation of responsibilities while keeping behavior consistent.
Testing
Backward Compatibility
time_started_running,error_message) are accessed viagetattr()Future Work (not included)
Supporting Images (checked for 2 minutes)