Skip to content
Closed
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
36 changes: 0 additions & 36 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

# Common functions and variables used by initiate.sh and complete.sh

REPORTING_PROJECT_REF="ihmaxnjpcccasmrbkpvo"
REPORTING_CREDENTIALS_FILE="/root/upgrade-reporting-credentials"

REPORTING_ANON_KEY=""
if [ -f "$REPORTING_CREDENTIALS_FILE" ]; then
REPORTING_ANON_KEY=$(cat "$REPORTING_CREDENTIALS_FILE")
fi

function log {
echo "$(date -u '+%Y-%m-%d %H:%M:%S UTC') $*"
}
Expand Down Expand Up @@ -81,34 +73,6 @@ function conninfo_for_db {
printf "dbname='%s'" "$d"
}

function ship_logs {
LOG_FILE=$1

if [ -z "$REPORTING_ANON_KEY" ]; then
log "No reporting key found. Skipping log upload."
return 0
fi

if [ ! -f "$LOG_FILE" ]; then
log "No log file found. Skipping log upload."
return 0
fi

if [ ! -s "$LOG_FILE" ]; then
log "Log file is empty. Skipping log upload."
return 0
fi

HOSTNAME=$(hostname)
DERIVED_REF="${HOSTNAME##*-}"

printf -v BODY '{ "ref": "%s", "step": "%s", "content": %s }' "$DERIVED_REF" "completion" "$(cat "$LOG_FILE" | jq -Rs '.')"
curl -sf -X POST "https://$REPORTING_PROJECT_REF.supabase.co/rest/v1/error_logs" \
-H "apikey: ${REPORTING_ANON_KEY}" \
-H 'Content-type: application/json' \
-d "$BODY"
}

# Aborts if / has less than required_kb free. Nix realizes the new pg_upgrade
# store path onto / before the mounted data disk is touched, so a full root
# partition otherwise fails the upgrade mid-flight instead of at the start.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ function cleanup {
# would skip ship_logs and lose the diagnostics for the actual failure.
enable_conflicting_timers || log "WARNING: failed to re-enable one or more timers; check 'systemctl list-timers --all' on this host"
fi

ship_logs "$LOG_FILE" || true

exit "$EXIT_CODE"
}

Expand Down Expand Up @@ -387,11 +384,6 @@ function complete_pg_upgrade {
fi

log "Upgrade job completed"

# Clean runs ship nothing — only warn-but-completed upgrades are reported (hard failures ship via the ERR-trap cleanup)
if [ "$warnings" = 1 ]; then
ship_logs "$LOG_FILE" || true
fi
}

function copy_configs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ cleanup() {
cp -R "${MOUNT_POINT}/pgdata/pg_upgrade_output.d/" /var/log/ || true
chown -R postgres:postgres /var/log/pg_upgrade_output.d/
chmod -R 0750 /var/log/pg_upgrade_output.d/
ship_logs "$LOG_FILE" || true
tail -n +1 /var/log/pg_upgrade_output.d/*/* >/var/log/pg_upgrade_output.d/pg_upgrade.log || true
ship_logs "/var/log/pg_upgrade_output.d/pg_upgrade.log" || true
fi

if [ -L "/usr/share/postgresql/${PGVERSION}" ]; then
Expand Down
Loading