Skip to content

Commit

Permalink
removed the conditional around check (#173)
Browse files Browse the repository at this point in the history
* remove the conditional around check for running version so it is always validated

* Update src/_stop.sh

Co-authored-by: ali <amyahya@gmail.com>

---------

Co-authored-by: ali <amyahya@gmail.com>
  • Loading branch information
mmorgan-pt and mrala authored Feb 5, 2025
1 parent 41f57c6 commit 74b077c
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/_stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,27 @@ function mod_stop() {
title "Attempting to gracefully stop PlexTrac..."
debug "Stopping API Services..."

# Before stopping, check if stable is being used and the current image tag for stable is correct
if [[ "$UPGRADE_STRATEGY" == "stable" ]]; then
debug "Running stable, validating the expected version against current running version"
# Before stopping, check if the current image tag matches the image defined by compose files
debug "Validating the expected version against current running version"
running_backend_version="$(for i in $(compose_client ps plextracapi -q); do docker container inspect "$i" --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")'; done | sort -u)"
running_frontend_version="$(for i in $(compose_client ps plextracnginx -q); do docker container inspect "$i" --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")'; done | sort -u)"
expected_backend_tag="$(compose_client config | grep image | grep plextracapi | head -n 1 | awk '{print $2}')"
expected_frontend_tag="$(compose_client config | grep image | grep plextracnginx | head -n 1 | awk '{print $2}')"
expected_backend_version="$(docker image inspect $expected_backend_tag --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")')"
expected_frontend_version="$(docker image inspect $expected_frontend_tag --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")')"


if [[ "$running_backend_version" != "$expected_backend_version" ]]; then
error "The running backend version ${running_backend_version} does not match the expected version (${expected_backend_version})"
error "During a system reboot or shutdown, the docker engine normally handles this gracefully and automatically, so using 'plextrac stop' may be unnecessary"
die "Since 'plextrac stop' runs a docker compose down, we cannot guarantee a 'plextrac start' will bring up the correct version. Please change UPGRADE_STRATEGY to the current running version ${running_backend_version} or run an update first"
fi
if [[ "$running_frontend_version" != "$expected_frontend_version" ]]; then
error "The running frontend version (${running_frontend_version}) does not match the expected version (${expected_frontend_version})"
error "During a system reboot or shutdown, the docker engine normally handles this gracefully and automatically, so using 'plextrac stop' may be unnecessary"
die "Since 'plextrac stop' runs a docker compose down, we cannot guarantee a 'plextrac start' will bring up the correct version. Please change UPGRADE_STRATEGY to the current running version ${running_frontend_version} or run an update first"
fi
debug "Validating the expected version against current running version"
running_backend_version="$(for i in $(compose_client ps plextracapi -q); do docker container inspect "$i" --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")'; done | sort -u)"
running_frontend_version="$(for i in $(compose_client ps plextracnginx -q); do docker container inspect "$i" --format json | jq -r '(.[].Config.Labels | ."org.opencontainers.image.version")'; done | sort -u)"
expected_backend_tag="$(compose_client config | grep image | grep plextracapi | head -n 1 | awk '{print $2}')"
Expand All @@ -27,7 +45,6 @@ function mod_stop() {
error "During a system reboot or shutdown, the docker engine normally handles this gracefully and automatically, so using 'plextrac stop' may be unnecessary"
die "Since 'plextrac stop' runs a docker compose down, we cannot guarantee a 'plextrac start' will bring up the correct version. Please change UPGRADE_STRATEGY to the current running version ${running_frontend_version} or run an update first"
fi
fi

for service in $(container_client ps --format '{{.Names}}' | grep -Eo 'plextracapi|plextracnginx|notification-engine|notification-sender|contextual-scoring-service'); do
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
Expand Down

0 comments on commit 74b077c

Please sign in to comment.