-
Notifications
You must be signed in to change notification settings - Fork 113
ci: retry Railway preview service discovery #2800
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 1 commit
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -185,6 +185,55 @@ EOF | |||||||||
| jq -r --arg service_name "${service_name}" '.data.environment.serviceInstances.edges[] | select(.node.serviceName == $service_name) | .node.serviceId' <<< "${response}" | ||||||||||
| } | ||||||||||
|
|
||||||||||
| railway_wait_for_environment_id() { | ||||||||||
| local project_id="$1" | ||||||||||
| local env_name="$2" | ||||||||||
| local max_attempts="${3:-30}" | ||||||||||
| local sleep_seconds="${4:-2}" | ||||||||||
| local attempt="" | ||||||||||
| local env_id="" | ||||||||||
|
|
||||||||||
| for attempt in $(seq 1 "${max_attempts}"); do | ||||||||||
| env_id="$(railway_environment_id "${project_id}" "${env_name}")" | ||||||||||
| if [ -n "${env_id}" ]; then | ||||||||||
| printf '%s' "${env_id}" | ||||||||||
| return 0 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [ "${attempt}" -lt "${max_attempts}" ]; then | ||||||||||
| sleep_with_jitter "${sleep_seconds}" | ||||||||||
| fi | ||||||||||
| done | ||||||||||
|
|
||||||||||
| echo "Unable to resolve Railway environment ID for ${env_name}." >&2 | ||||||||||
| return 1 | ||||||||||
| } | ||||||||||
|
|
||||||||||
| railway_wait_for_service_id_for_env() { | ||||||||||
| local env_id="$1" | ||||||||||
| local service_name="$2" | ||||||||||
| local env_name="$3" | ||||||||||
| local max_attempts="${4:-30}" | ||||||||||
| local sleep_seconds="${5:-2}" | ||||||||||
| local attempt="" | ||||||||||
| local service_id="" | ||||||||||
|
|
||||||||||
| for attempt in $(seq 1 "${max_attempts}"); do | ||||||||||
| service_id="$(railway_service_id_for_env "${env_id}" "${service_name}")" | ||||||||||
| if [ -n "${service_id}" ]; then | ||||||||||
| printf '%s' "${service_id}" | ||||||||||
| return 0 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [ "${attempt}" -lt "${max_attempts}" ]; then | ||||||||||
| sleep_with_jitter "${sleep_seconds}" | ||||||||||
| fi | ||||||||||
| done | ||||||||||
|
|
||||||||||
| echo "Unable to resolve Railway service ID for ${service_name} in ${env_name}." >&2 | ||||||||||
| return 1 | ||||||||||
| } | ||||||||||
|
|
||||||||||
| railway_ensure_tcp_proxy() { | ||||||||||
| local project_id="$1" | ||||||||||
| local env_name="$2" | ||||||||||
|
|
@@ -199,17 +248,8 @@ railway_ensure_tcp_proxy() { | |||||||||
| local active="" | ||||||||||
| local attempt="" | ||||||||||
|
|
||||||||||
| env_id="$(railway_environment_id "${project_id}" "${env_name}")" | ||||||||||
| if [ -z "${env_id}" ]; then | ||||||||||
| echo "Unable to resolve Railway environment ID for ${env_name}." >&2 | ||||||||||
| return 1 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| service_id="$(railway_service_id_for_env "${env_id}" "${service_name}")" | ||||||||||
| if [ -z "${service_id}" ]; then | ||||||||||
| echo "Unable to resolve Railway service ID for ${service_name} in ${env_name}." >&2 | ||||||||||
| return 1 | ||||||||||
| fi | ||||||||||
| env_id="$(railway_wait_for_environment_id "${project_id}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" | ||||||||||
| service_id="$(railway_wait_for_service_id_for_env "${env_id}" "${service_name}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" | ||||||||||
|
||||||||||
| env_id="$(railway_wait_for_environment_id "${project_id}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" | |
| service_id="$(railway_wait_for_service_id_for_env "${env_id}" "${service_name}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" | |
| env_id="$(railway_wait_for_environment_id "${project_id}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" || return 1 | |
| service_id="$(railway_wait_for_service_id_for_env "${env_id}" "${service_name}" "${env_name}" "${max_attempts}" "${sleep_seconds}")" || return 1 |
Refs:
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.
Fixed in 54759a603 by restoring explicit error propagation on both wait-command substitutions with || return 1. That preserves the original fail-fast behavior when environment discovery fails.
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.
Nit (non-blocking):
railway_ensure_tcp_proxyforwards its fullmax_attempts/sleep_secondsto each of the two new wait functions, then runs its own polling loop with the same budget. Worst-case wall time tripled from ~60 s to ~180 s (30 × 2 s × 3 phases) compared to the previous single-phase version.This is probably fine in practice — the environment and service IDs should resolve quickly — but it's worth being aware of. If CI timeout pressure becomes a concern later, consider giving the discovery phases a smaller attempt budget (e.g., 10) while keeping the TCP-proxy polling at 30.