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

Bugfix: Check for migration container #143

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 8 additions & 10 deletions src/_manage_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,20 @@ function mod_check_etl_status() {
info "Checking Migration Status"
secs=300
endTime=$(( $(date +%s) + secs ))
if [[ $(container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}') != "" ]]; then
migration_exited="running"
else
migration_exited="exited"
debug "Migration container not found"
fi
while [ "$migration_exited" == "running" ]; do
# Check if the migration container has exited, e.g., migrations have completed or failed
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations" || migration_exited="exited")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'` || migration_exited="exited")
fi
local migration_exited=$(container_client inspect --format '{{.State.Status}}' `container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}'` || migration_exited="exited")
if [ $(date +%s) -gt $endTime ]; then
error "Migration container has been running for over 5 minutes or is still running. Please ensure they complete or fail before taking further action with the PlexTrac Manager Utility. You can check on the logs by running 'docker compose logs -f couchbase-migrations'"
die "Exiting PlexTrac Manager Utility."
fi
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
for s in / - \\ \|; do printf "\r\033[K$s $(podman inspect --format '{{.State.Status}}' migrations) -- $(podman logs migrations 2> /dev/null | tail -n 1 -q)"; sleep .1; done
else
for s in / - \\ \|; do printf "\r\033[K$s $(docker inspect --format '{{.State.Status}}' `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'`) -- $(docker logs `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'` 2> /dev/null | tail -n 1 -q)"; sleep .1; done
fi
for s in / - \\ \|; do printf "\r\033[K$s $(container_client inspect --format '{{.State.Status}}' `container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}'`) -- $(container_client logs `container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}'` 2> /dev/null | tail -n 1 -q)"; sleep .1; done
done
printf "\r\033[K"
info "Migrations complete"
Expand Down
12 changes: 2 additions & 10 deletions src/plextrac
Original file line number Diff line number Diff line change
Expand Up @@ -444,21 +444,13 @@ function run_cb_migrations() {
fi
# While the duraction of 5 minutes is running, check if the migration container has exited
while [ $(date +%s) -lt $endTime ]; do
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'`)
fi
local migration_exited=$(container_client inspect --format '{{.State.Status}}' `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'`)
if [ "$migration_exited" == "exited" ]; then
printf "\r\033[K"
info "Migrations completed"
break
fi
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
for s in / - \\ \|; do printf "\r\033[K$s $(podman inspect --format '{{.State.Status}}' migrations) -- $(podman logs migrations 2> /dev/null | tail -n 1 -q)"; sleep .1; done
else
for s in / - \\ \|; do printf "\r\033[K$s $(docker inspect --format '{{.State.Status}}' `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'`) -- $(docker logs `docker ps -a | grep migrations 2>/dev/null | awk '{print $1}'` 2> /dev/null | tail -n 1 -q)"; sleep .1; done
fi
for s in / - \\ \|; do printf "\r\033[K$s $(container_client inspect --format '{{.State.Status}}' `container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}'`) -- $(container_client logs `container_client ps -a | grep migrations 2>/dev/null | awk '{print $1}'` 2> /dev/null | tail -n 1 -q)"; sleep .1; done
sleep 1
done
if [ $(date +%s) -ge $endTime ]; then
Expand Down