[CI/Build] Clean up timed-out K8s E2E runs and fail fast on backend exits - #1031
ruizhang0101 merged 4 commits into
Conversation
Signed-off-by: Lifan Sun <lifansun1412@gmail.com>
Signed-off-by: Lifan Sun <lifansun1412@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request enhances the wait-for-backends.sh script by introducing process ID and log file tracking for the backends, allowing the script to fail early and print diagnostic logs if a backend exits. The review feedback suggests making the script more robust under set -e by ensuring print_backend_log always returns 0 and explicitly returning 0 from check_backend_process to avoid implicit exit status issues.
| print_backend_log() { | ||
| local backend_name=$1 | ||
| local log_file=$2 | ||
|
|
||
| if [ -n "$log_file" ] && [ -f "$log_file" ]; then | ||
| echo "Last 50 lines from ${backend_name} log (${log_file}):" | ||
| tail -n 50 "$log_file" | ||
| fi | ||
| } |
There was a problem hiding this comment.
Since print_backend_log is a diagnostic helper, any failure within it (e.g., if tail fails due to permission issues or if the file is removed) should not cause the entire script to exit under set -e.
To prevent this, we should ensure the function always returns 0 by appending || true to the tail command and adding an explicit return 0 at the end of the function.
| print_backend_log() { | |
| local backend_name=$1 | |
| local log_file=$2 | |
| if [ -n "$log_file" ] && [ -f "$log_file" ]; then | |
| echo "Last 50 lines from ${backend_name} log (${log_file}):" | |
| tail -n 50 "$log_file" | |
| fi | |
| } | |
| print_backend_log() { | |
| local backend_name=$1 | |
| local log_file=$2 | |
| if [ -n "$log_file" ] && [ -f "$log_file" ]; then | |
| echo "Last 50 lines from ${backend_name} log (${log_file}):" | |
| tail -n 50 "$log_file" || true | |
| fi | |
| return 0 | |
| } |
| check_backend_process() { | ||
| local backend_name=$1 | ||
| local backend_pid=$2 | ||
| local log_file=$3 | ||
|
|
||
| if [ -n "$backend_pid" ] && ! kill -0 "$backend_pid" 2>/dev/null; then | ||
| echo "❌ ${backend_name} process exited before becoming reachable" | ||
| print_backend_log "$backend_name" "$log_file" | ||
| return 1 | ||
| fi | ||
| } |
There was a problem hiding this comment.
In Bash, if a function finishes without an explicit return, its exit status is that of the last executed command. If the if condition is false, the if statement returns 0, but relying on this implicit behavior can be fragile and less readable.
Adding an explicit return 0 at the end of check_backend_process makes the success path clear and robust.
| check_backend_process() { | |
| local backend_name=$1 | |
| local backend_pid=$2 | |
| local log_file=$3 | |
| if [ -n "$backend_pid" ] && ! kill -0 "$backend_pid" 2>/dev/null; then | |
| echo "❌ ${backend_name} process exited before becoming reachable" | |
| print_backend_log "$backend_name" "$log_file" | |
| return 1 | |
| fi | |
| } | |
| check_backend_process() { | |
| local backend_name=$1 | |
| local backend_pid=$2 | |
| local log_file=$3 | |
| if [ -n "$backend_pid" ] && ! kill -0 "$backend_pid" 2>/dev/null; then | |
| echo "❌ ${backend_name} process exited before becoming reachable" | |
| print_backend_log "$backend_name" "$log_file" | |
| return 1 | |
| fi | |
| return 0 | |
| } |
Signed-off-by: Lifan Sun <lifansun1412@gmail.com>
Summary
In several recent PRs, a timed-out K8s E2E test could leave GPU pods running, causing the subsequent static-discovery job to fail due to insufficient GPU memory. The job then continued polling the unreachable backends even though their processes had already exited.
A representative example is PR #1027, attempt 2:
This PR improves failure handling and observability in the router E2E workflow:
always uninstall the K8s discovery Helm release after the test step, including when the step times out.
track the two static backend processes while waiting for them to become reachable, fail immediately if either backend exits during startup.
print the last 50 lines of the relevant backend log.
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
-swhen doinggit commit[Bugfix],[Feat], and[CI].Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]for bug fixes.[CI/Build]for build or continuous integration improvements.[Doc]for documentation fixes and improvements.[Feat]for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]for changes to thevllm_router(e.g., routing algorithm, router observability, etc.).[Misc]for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
pre-committo format your code. SeeREADME.mdfor installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:header which certifies agreement with the terms of the DCO.Using
-swithgit commitwill automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.