Skip to content
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

[FIX] 20-postgres-wait: avoid assuming you have permission to list database #621

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion entrypoint.d/20-postgres-wait
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ fi

log INFO Waiting until postgres is listening at $PGHOST...
while true; do
psql --list > /dev/null 2>&1 && break
# If your postgres connection has minimal permissions, you should
# have at least an empty PGDATABASE and rights on this
# databases. The following will then succeed:
[ -n "$PGDATABASE" ] && echo "SELECT 1;" | psql "$PGDATABASE" > /dev/null 2>&1 && break

# if previous check failed (if PGDATABASE is set, but not yet
# created), you are in a more common scenario where odoo is
# expected to manage databases, and it should have the permissions
# to create it and will attempt to do it. In that case, you'll
# probably also have the permissions to list the databases.
psql -l > /dev/null 2>&1 && break
sleep 1
done
Loading