feat(hub): retire WDMI projects from error reporting (BIT-24704)
Block ingest for retired WDMI slugs, purge project data via migration, remove WDMI runbooks, and add offboard-project helper for future retirements. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
ea41eb2205
commit
8773f12b25
24 files changed
+196
-1858
No files matched your search
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Acceptance check for BIT-1044: BatchMode SSH from this host to WDMI Importer (LAN).
|
||||
# See docs/RUNBOOK_DEVOPS_IMPORTER_SSH_BIT1044.md
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/devops/verify_importer_ssh_bit1044.sh
|
||||
# IMPORTER_HOST=192.168.1.123 SSH_USER=root ./scripts/devops/verify_importer_ssh_bit1044.sh
|
||||
# ./scripts/devops/verify_importer_ssh_bit1044.sh --diagnose # print route/neigh/ping, then SSH; exit code from SSH only
|
||||
set -euo pipefail
|
||||
|
||||
readonly IMPORTER_HOST="${IMPORTER_HOST:-192.168.1.123}"
|
||||
readonly SSH_USER="${SSH_USER:-root}"
|
||||
readonly CONNECT_TIMEOUT="${SSH_CONNECT_TIMEOUT:-10}"
|
||||
|
||||
_diagnose=0
|
||||
if [[ "${1:-}" == "--diagnose" ]]; then
|
||||
_diagnose=1
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
sed -n '1,20p' "$0"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n "${1:-}" && "${1}" != "--diagnose" ]]; then
|
||||
echo "unknown argument: $1 (use --diagnose or no args)" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ((_diagnose)); then
|
||||
echo "verify_importer_ssh_bit1044: route to ${IMPORTER_HOST}"
|
||||
ip route get "${IMPORTER_HOST}" 2>/dev/null || true
|
||||
echo "verify_importer_ssh_bit1044: neighbour ${IMPORTER_HOST}"
|
||||
ip neigh show "${IMPORTER_HOST}" 2>/dev/null || true
|
||||
echo "verify_importer_ssh_bit1044: ping (2 probes, 2s max wait)"
|
||||
ping -c 2 -W 2 "${IMPORTER_HOST}" 2>&1 || true
|
||||
fi
|
||||
|
||||
echo "verify_importer_ssh_bit1044: ssh BatchMode ${SSH_USER}@${IMPORTER_HOST} echo ok"
|
||||
if ssh -o BatchMode=yes -o ConnectTimeout="${CONNECT_TIMEOUT}" -o StrictHostKeyChecking=accept-new \
|
||||
"${SSH_USER}@${IMPORTER_HOST}" echo ok; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "verify_importer_ssh_bit1044: SSH failed; neighbour ${IMPORTER_HOST}:" >&2
|
||||
ip neigh show "${IMPORTER_HOST}" 2>/dev/null || true
|
||||
echo "verify_importer_ssh_bit1044: hint: run with --diagnose for route + ping" >&2
|
||||
exit 1
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
# offboard-project.sh — revoke keys, disable collectors, and delete a project from error_reporting.
|
||||
#
|
||||
# Usage:
|
||||
# offboard-project.sh <slug>
|
||||
#
|
||||
# Example:
|
||||
# ./scripts/offboard-project.sh wdmi-store
|
||||
#
|
||||
# Environment:
|
||||
# DATABASE_URL If set and mysql client available, applies SQL directly.
|
||||
# Otherwise prints SQL to stdout.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
_die() { echo "error: $*" >&2; exit 1; }
|
||||
|
||||
[[ $# -eq 1 ]] || _die "Usage: offboard-project.sh <slug>"
|
||||
|
||||
SLUG="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')"
|
||||
[[ "${SLUG}" =~ ^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$ ]] \
|
||||
|| _die "slug must be 2-64 lowercase alphanumeric/hyphens: ${SLUG}"
|
||||
|
||||
SQL="$(cat <<EOSQL
|
||||
-- Offboard project: ${SLUG}
|
||||
BEGIN;
|
||||
|
||||
UPDATE er_ingest_keys k
|
||||
INNER JOIN er_projects p ON p.id = k.project_id
|
||||
SET k.status = 'revoked',
|
||||
k.revoked_at = NOW(6)
|
||||
WHERE LOWER(p.slug) = '${SLUG}';
|
||||
|
||||
UPDATE er_collector_sources cs
|
||||
INNER JOIN er_projects p ON p.id = cs.project_id
|
||||
SET cs.is_active = FALSE
|
||||
WHERE LOWER(p.slug) = '${SLUG}';
|
||||
|
||||
DELETE FROM er_projects WHERE LOWER(slug) = '${SLUG}';
|
||||
|
||||
COMMIT;
|
||||
EOSQL
|
||||
)"
|
||||
|
||||
echo "================================================================"
|
||||
echo " Offboard project slug: ${SLUG}"
|
||||
echo "================================================================"
|
||||
echo ""
|
||||
echo "--- SQL (apply to error_reporting database) ---"
|
||||
echo "${SQL}"
|
||||
echo ""
|
||||
|
||||
if [[ -n "${DATABASE_URL:-}" ]] && command -v mysql >/dev/null 2>&1; then
|
||||
echo "DATABASE_URL is set. Applying SQL..."
|
||||
DB_URL="${DATABASE_URL#mysql://}"
|
||||
DB_USER="${DB_URL%%:*}"
|
||||
DB_REST="${DB_URL#*:}"
|
||||
DB_PASS="${DB_REST%%@*}"
|
||||
DB_REST="${DB_REST#*@}"
|
||||
DB_HOST="${DB_REST%%:*}"
|
||||
DB_REST="${DB_REST#*:}"
|
||||
DB_PORT="${DB_REST%%/*}"
|
||||
DB_NAME="${DB_REST#*/}"
|
||||
|
||||
echo "${SQL}" | mysql -h"${DB_HOST}" -P"${DB_PORT}" -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}"
|
||||
echo "Applied successfully."
|
||||
fi
|
||||
Reference in new issue
Block a user