fix: container update pattern in run_updater_fixes

This commit is contained in:
Jake Turner 2026-03-05 04:32:09 +00:00
parent 744504dd1e
commit 0e94d5daa4
No known key found for this signature in database
GPG Key ID: 6DCBBAE4FEAB53EB

View File

@ -177,17 +177,27 @@ rebuild_sidecar() {
} }
restart_sidecar() { restart_sidecar() {
echo -e "${YELLOW}#${RESET} Restarting the updater container..." echo -e "${YELLOW}#${RESET} Stopping and removing existing updater containers..."
if ! docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" up -d --force-recreate updater; then
echo -e "${RED}#${RESET} Failed to restart the updater container." # Stop and remove via compose first (handles the compose-tracked container)
docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" stop updater >> /dev/null 2>&1 || true
docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" rm -f updater >> /dev/null 2>&1 || true
# Force-remove any stale container still holding the name (e.g. hash-prefixed remnants)
docker rm -f nomad_updater >> /dev/null 2>&1 || true
echo -e "${YELLOW}#${RESET} Starting the updated updater container..."
if ! docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" up -d updater; then
echo -e "${RED}#${RESET} Failed to start the updater container."
exit 1 exit 1
fi fi
echo -e "${GREEN}#${RESET} Updater container restarted.\n" echo -e "${GREEN}#${RESET} Updater container started.\n"
} }
verify_sidecar_running() { verify_sidecar_running() {
sleep 3 sleep 3
if docker ps --filter "name=nomad_updater" --filter "status=running" --format '{{.Names}}' | grep -q "nomad_updater"; then # Use exact name match to avoid false positives from hash-prefixed stale containers
if docker ps --filter "name=^nomad_updater$" --filter "status=running" --format '{{.Names}}' | grep -qx "nomad_updater"; then
echo -e "${GREEN}#${RESET} Updater container is running.\n" echo -e "${GREEN}#${RESET} Updater container is running.\n"
else else
echo -e "${RED}#${RESET} Updater container does not appear to be running." echo -e "${RED}#${RESET} Updater container does not appear to be running."