diff --git a/docker/gitlab/prepare.sh b/docker/gitlab/prepare.sh index 019d3b3ee2b603ffa827b5e91f7ca0a0b9732bcb..b86420bf05fbb6ff29f5410970e6f03c42c869fa 100755 --- a/docker/gitlab/prepare.sh +++ b/docker/gitlab/prepare.sh @@ -12,7 +12,7 @@ test: &test adapter: postgresql encoding: unicode database: gitlabhq_dblab - username: ${DBLAB_USER} + username: gitlab password: ${DBLAB_PASSWORD} host: postgres-main prepared_statements: false @@ -22,7 +22,7 @@ test: &test adapter: postgresql encoding: unicode database: gitlabhq_dblab - username: ${DBLAB_USER} + username: gitlab password: ${DBLAB_PASSWORD} host: postgres-ci prepared_statements: false @@ -38,7 +38,7 @@ test: &test adapter: postgresql encoding: unicode database: gitlabhq_dblab - username: ${DBLAB_USER} + username: gitlab password: ${DBLAB_PASSWORD} host: postgres prepared_statements: false @@ -85,5 +85,14 @@ for db_host in $(echo "$ALL_DB_HOSTS" | tr ',' '\n'); do else echo "Unable to connect to database lab psql for optional configuration of ${db_host}" fi + + # Reset `gitlab` user password - this is the PG user we're going to use later to execute migrations + # We re-use $DBLAB_PASSWORD variable here + if timeout 60s bash -c "until pg_isready --quiet -h ${db_host} -U ${DBLAB_USER} --dbname=gitlabhq_dblab; do sleep 1; done"; then + echo "ALTER USER gitlab PASSWORD '${DBLAB_PASSWORD}'; GRANT EXECUTE ON FUNCTION pg_stat_statements_reset() to gitlab;" | PGPASSWORD="${DBLAB_PASSWORD}" psql -h "${db_host}" -U "${DBLAB_USER}" gitlabhq_dblab + else + echo "Unable to connect to database lab psql for mandatory user configuration on ${db_host}" + exit 1 + fi done