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

Added override flag to manager util #135

Merged
merged 2 commits into from
May 21, 2024
Merged
Changes from 1 commit
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
96 changes: 50 additions & 46 deletions src/_manage_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,64 +145,68 @@ function mod_autofix() {
}

function mod_check_etl_status() {
local migration_exited="running"
title "Checking Data Migration Status"
info "Checking Migration Status"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
while [ "$migration_exited" == "running" ]; do
# Check if the migration container has exited, e.g., migrations have completed or failed
if [ "${IGNORE_ETL_STATUS:-false}" == "false" ]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this line

local migration_exited="running"
title "Checking Data Migration Status"
info "Checking Migration Status"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
for s in / - \\ \|; do printf "\r$s"; sleep .1; done
done
printf "\r"
info "Migrations complete"
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")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
for s in / - \\ \|; do printf "\r$s"; sleep .1; done
done
printf "\r"
info "Migrations complete"

title "Checking Data ETL Status"
debug "Checking ETL health and status..."
ETL_OUTPUT=${ETL_OUTPUT:-true}
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local api_running=$(podman container inspect --format '{{.State.Status}}' "plextracapi" | wc -l)
else
local api_running=$(compose_client ps -q plextracapi | wc -l)
fi
if [ $api_running -gt 0 ]; then
title "Checking Data ETL Status"
debug "Checking ETL health and status..."
ETL_OUTPUT=${ETL_OUTPUT:-true}
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
RAW_OUTPUT=$(podman exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
local api_running=$(podman container inspect --format '{{.State.Status}}' "plextracapi" | wc -l)
else
RAW_OUTPUT=$(compose_client exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
fi
if [ "$RAW_OUTPUT" == "" ]; then
debug "No ETL status output found or it failed to run."
return
local api_running=$(compose_client ps -q plextracapi | wc -l)
fi
# Find the json content by looking for the first line that starts
# with an opening brace and the first line that starts with a closing brace.
JSON_OUTPUT=$(echo "$RAW_OUTPUT" | sed '/^{/,/^}/!d')

# Find the summary content by finding the first line that starts
# with a closing brace and selecting all remaining lines after that one.
SUMMARY_OUTPUT=$(echo "$RAW_OUTPUT" | sed '1,/^}/d')
ETLS_COMBINED_STATUS=$(echo $JSON_OUTPUT | jq -r .etlsCombinedStatus)
if [ "${ETL_OUTPUT:-true}" == "true" ]; then
msg "$SUMMARY_OUTPUT\n"
debug "$JSON_OUTPUT\n"
fi

if [[ "$ETLS_COMBINED_STATUS" == "HEALTHY" ]]; then
info "All ETLs are in a healthy status."
if [ $api_running -gt 0 ]; then
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
RAW_OUTPUT=$(podman exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
else
etl_failure
RAW_OUTPUT=$(compose_client exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
fi
if [ "$RAW_OUTPUT" == "" ]; then
debug "No ETL status output found or it failed to run."
return
fi
# Find the json content by looking for the first line that starts
# with an opening brace and the first line that starts with a closing brace.
JSON_OUTPUT=$(echo "$RAW_OUTPUT" | sed '/^{/,/^}/!d')

# Find the summary content by finding the first line that starts
# with a closing brace and selecting all remaining lines after that one.
SUMMARY_OUTPUT=$(echo "$RAW_OUTPUT" | sed '1,/^}/d')
ETLS_COMBINED_STATUS=$(echo $JSON_OUTPUT | jq -r .etlsCombinedStatus)
if [ "${ETL_OUTPUT:-true}" == "true" ]; then
msg "$SUMMARY_OUTPUT\n"
debug "$JSON_OUTPUT\n"
fi

if [[ "$ETLS_COMBINED_STATUS" == "HEALTHY" ]]; then
info "All ETLs are in a healthy status."
else
etl_failure
fi
else
info "PlexTrac API container not running, skipping ETL status check"
fi
else
info "PlexTrac API container not running, skipping ETL status check"
error "Skipping ETL status check"
Comment on lines 208 to +209
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these two lines

Your drunk Git, go home

fi
}

Expand Down