-
Notifications
You must be signed in to change notification settings - Fork 9
Don't use wait for host port instead use pg_isready #61
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
Merged
bastelfreak
merged 1 commit into
OpenVoxProject:main
from
sebastianrakel:fix-postgres-online-check
Dec 28, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ set -e | |
| # OPENVOXDB_POSTGRES_HOSTNAME Specified in Dockerfile, defaults to postgres | ||
| # OPENVOXSERVER_HOSTNAME DNS name of puppetserver to wait on, defaults to puppet | ||
|
|
||
|
|
||
| msg() { | ||
| echo "($0) $1" | ||
| } | ||
|
|
@@ -26,43 +25,18 @@ error() { | |
| exit 1 | ||
| } | ||
|
|
||
| # Alpine as high as 3.9 seems to have failures reaching addresses sporadically | ||
| # In local repro scenarios, performing a DNS lookup with dig increases reliability | ||
| wait_for_host_name_resolution() { | ||
| # host and dig are in the bind-tools Alpine package | ||
| # k8s nodes may not be reachable with a ping | ||
| # performing a dig prior to a host may help prime the cache in Alpine | ||
| # https://github.com/Microsoft/opengcs/issues/303 | ||
| /wtfc.sh --timeout="${2}" --interval=1 --progress "dig $1 && host $1" | ||
| # additionally log the DNS lookup information for diagnostic purposes | ||
| NAME_RESOLVED=$? | ||
| dig $1 | ||
| if [ $NAME_RESOLVED -ne 0 ]; then | ||
| error "dependent service at $1 cannot be resolved or contacted" | ||
| fi | ||
| } | ||
|
|
||
| wait_for_host_port() { | ||
| # -v verbose -w connect / final net read timeout -z scan and don't send data | ||
| /wtfc.sh --timeout=${3} --interval=1 --progress "nc -v -w 1 -z '${1}' ${2}" | ||
| if [ $? -ne 0 ]; then | ||
| error "host $1:$2 does not appear to be listening" | ||
| fi | ||
| } | ||
|
|
||
| OPENVOXDB_WAITFORHOST_SECONDS=${OPENVOXDB_WAITFORHOST_SECONDS:-30} | ||
| OPENVOXDB_WAITFORPOSTGRES_SECONDS=${OPENVOXDB_WAITFORPOSTGRES_SECONDS:-60} | ||
| OPENVOXDB_WAITFORHEALTH_SECONDS=${OPENVOXDB_WAITFORHEALTH_SECONDS:-360} | ||
| OPENVOXDB_POSTGRES_HOSTNAME="${OPENVOXDB_POSTGRES_HOSTNAME:-postgres}" | ||
| OPENVOXSERVER_HOSTNAME="${OPENVOXSERVER_HOSTNAME:-puppet}" | ||
| OPENVOXSERVER_PORT="${OPENVOXSERVER_PORT:-8140}" | ||
|
|
||
| # wait for postgres DNS | ||
| wait_for_host_name_resolution $OPENVOXDB_POSTGRES_HOSTNAME $OPENVOXDB_WAITFORHOST_SECONDS | ||
| # wait for postgres is ready | ||
| /wtfc.sh --timeout="${OPENVOXDB_WAITFORHOST_SECONDS}" --interval=1 --progress "pg_isready -h ${OPENVOXDB_POSTGRES_HOSTNAME} --port '${OPENVOXDB_POSTGRES_PORT:-5432}'" | ||
|
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. Should this be using |
||
|
|
||
| # wait for puppetserver DNS, then healthcheck | ||
|
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. This is now outdated |
||
| if [ "$USE_OPENVOXSERVER" = true ]; then | ||
| wait_for_host_name_resolution $OPENVOXSERVER_HOSTNAME $OPENVOXDB_WAITFORHOST_SECONDS | ||
| HEALTH_COMMAND="curl --silent --fail --insecure 'https://${OPENVOXSERVER_HOSTNAME}:"${OPENVOXSERVER_PORT}"/status/v1/simple' | grep -q '^running$'" | ||
| fi | ||
|
|
||
|
|
@@ -72,6 +46,3 @@ if [ -n "$HEALTH_COMMAND" ]; then | |
| error "Required health check failed" | ||
| fi | ||
| fi | ||
|
|
||
| # wait for postgres | ||
| wait_for_host_port $OPENVOXDB_POSTGRES_HOSTNAME "${OPENVOXDB_POSTGRES_PORT:-5432}" $OPENVOXDB_WAITFORPOSTGRES_SECONDS | ||
Oops, something went wrong.
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.
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.
And this is now redundant as well.