Skip to content

Commit

Permalink
Remove scripted waiting for db in favor of healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
baierjan committed Oct 4, 2024
1 parent ba06387 commit 0fcde18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 7 additions & 3 deletions container/webui/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ services:
start_period: 5s

db:
# Teporary fix version https://progress.opensuse.org/issues/167524
image: postgres:16
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: openqa
Expand All @@ -136,7 +135,12 @@ services:
volumes:
- ./workdir/db:/var/lib/postgresql/data:Z
healthcheck:
test: ["CMD", "sh", "-c", "echo 'select * from api_keys;' | psql -U openqa -v 'ON_ERROR_STOP=1' openqa"]
test:
- CMD-SHELL
- >-
pg_isready -U openqa -d openqa
&& echo 'select * from api_keys;'
| psql -U openqa -v 'ON_ERROR_STOP=1' openqa
interval: 10s
timeout: 10s
retries: 3
Expand Down
9 changes: 0 additions & 9 deletions container/webui/run_openqa.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash
set -e

function wait_for_db_creation() {
echo "Waiting for DB creation"
while ! su geekotest -c 'PGPASSWORD=openqa psql -h db -U openqa --list | grep -qe openqa'; do sleep .1; done
}

function upgradedb() {
wait_for_db_creation
su geekotest -c '/usr/share/openqa/script/upgradedb --upgrade_database'
}

Expand All @@ -20,17 +14,14 @@ function websockets() {
}

function gru() {
wait_for_db_creation
su geekotest -c /usr/share/openqa/script/openqa-gru
}

function livehandler() {
wait_for_db_creation
su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon
}

function webui() {
wait_for_db_creation
su geekotest -c /usr/share/openqa/script/openqa-webui-daemon
}

Expand Down

0 comments on commit 0fcde18

Please sign in to comment.