-
Notifications
You must be signed in to change notification settings - Fork 514
[CI/Build] Clean up timed-out K8s E2E runs and fail fast on backend exits #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
11195b2
027c8e2
48984e7
c95a6bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,14 +6,46 @@ echo "⏳ Waiting for backends to be ready" | |||||||||||||||||||||||||||||||||||||||||||||||
| timeout=${1:-120} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend1=${2:-"http://localhost:8001"} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend2=${3:-"http://localhost:8002"} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend1_pid=${4:-} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend2_pid=${5:-} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend1_log=${6:-} | ||||||||||||||||||||||||||||||||||||||||||||||||
| backend2_log=${7:-} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Bash, if a function finishes without an explicit Adding an explicit
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| start_time=$(date +%s) | ||||||||||||||||||||||||||||||||||||||||||||||||
| echo "⏳ Waiting for backends to become reachable..." | ||||||||||||||||||||||||||||||||||||||||||||||||
| while true; do | ||||||||||||||||||||||||||||||||||||||||||||||||
| current_time=$(date +%s) | ||||||||||||||||||||||||||||||||||||||||||||||||
| elapsed=$((current_time - start_time)) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| check_backend_process "Backend 1" "$backend1_pid" "$backend1_log" || exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| check_backend_process "Backend 2" "$backend2_pid" "$backend2_log" || exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if [ $elapsed -ge "$timeout" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Backends failed to become reachable after ${timeout} seconds" | ||||||||||||||||||||||||||||||||||||||||||||||||
| print_backend_log "Backend 1" "$backend1_log" | ||||||||||||||||||||||||||||||||||||||||||||||||
| print_backend_log "Backend 2" "$backend2_log" | ||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
print_backend_logis a diagnostic helper, any failure within it (e.g., iftailfails due to permission issues or if the file is removed) should not cause the entire script to exit underset -e.To prevent this, we should ensure the function always returns
0by appending|| trueto thetailcommand and adding an explicitreturn 0at the end of the function.