generated from coulomb/repo-seed
Status probe checks k8s runner first; documents retirement of coulombcore interim host runner.
57 lines
2.5 KiB
Bash
Executable File
57 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -u
|
|
|
|
FORGEJO_URL="${FORGEJO_URL:-https://forgejo.coulomb.social}"
|
|
FORGEJO_KUBECONFIG="${FORGEJO_KUBECONFIG:-${HOME}/.kube/config-hosteurope}"
|
|
RUNNER_HOST="${RUNNER_HOST:-}"
|
|
RUNNER_SSH_USER="${RUNNER_SSH_USER:-}"
|
|
RUNNER_SSH_KEY="${RUNNER_SSH_KEY:-}"
|
|
SSH_CONNECT_TIMEOUT="${SSH_CONNECT_TIMEOUT:-5}"
|
|
|
|
section() { printf '\n## %s\n' "$1"; }
|
|
have() { command -v "$1" >/dev/null 2>&1; }
|
|
http_code() { curl -sS -m 8 -o /dev/null -w '%{http_code}' "$1" 2>/dev/null || printf 'error'; }
|
|
|
|
section "Tool availability"
|
|
for tool in curl ssh; do
|
|
if have "$tool"; then printf 'ok: %s\n' "$tool"; else printf 'missing: %s\n' "$tool"; fi
|
|
done
|
|
|
|
section "Forgejo endpoint checks"
|
|
if have curl; then
|
|
printf 'forgejo root: %s\n' "$(http_code "${FORGEJO_URL}/")"
|
|
printf 'forgejo api version: %s\n' "$(http_code "${FORGEJO_URL}/api/v1/version")"
|
|
printf 'forgejo registry /v2 (GET): %s\n' "$(curl -sS -m 8 -o /dev/null -w '%{http_code}' -X GET "${FORGEJO_URL}/v2/")"
|
|
else
|
|
echo "curl missing; skipping endpoint checks"
|
|
fi
|
|
|
|
section "In-cluster runner (railiance01)"
|
|
if have kubectl && [ -r "${FORGEJO_KUBECONFIG}" ]; then
|
|
KUBECONFIG="${FORGEJO_KUBECONFIG}" kubectl get deploy,pods,pvc -n forgejo -l app.kubernetes.io/name=forgejo-runner --ignore-not-found 2>/dev/null || true
|
|
KUBECONFIG="${FORGEJO_KUBECONFIG}" kubectl logs -n forgejo deploy/forgejo-runner -c runner --tail=5 2>/dev/null || true
|
|
else
|
|
echo "kubectl or kubeconfig missing; skipping in-cluster probe"
|
|
fi
|
|
|
|
section "Legacy host runner probe (optional)"
|
|
if [ -n "${RUNNER_HOST}" ] && have ssh; then
|
|
ssh_target="${RUNNER_HOST}"
|
|
if [ -n "${RUNNER_SSH_USER}" ]; then ssh_target="${RUNNER_SSH_USER}@${RUNNER_HOST}"; fi
|
|
ssh_args=(-o BatchMode=yes -o ConnectTimeout="${SSH_CONNECT_TIMEOUT}")
|
|
if [ -n "${RUNNER_SSH_KEY}" ]; then ssh_args+=(-i "${RUNNER_SSH_KEY}"); fi
|
|
ssh "${ssh_args[@]}" "${ssh_target}" '
|
|
set -u
|
|
echo "host=$(hostname)"
|
|
if command -v forgejo-runner >/dev/null 2>&1; then forgejo-runner -v || true; else echo "missing: forgejo-runner"; fi
|
|
if command -v docker >/dev/null 2>&1; then docker --version || true; else echo "missing: docker"; fi
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl is-active forgejo-runner 2>/dev/null || true
|
|
fi
|
|
if [ -f /var/lib/forgejo-runner/.runner ]; then echo "ok: /var/lib/forgejo-runner/.runner present"; fi
|
|
'
|
|
elif [ -n "${RUNNER_HOST}" ]; then
|
|
echo "ssh missing; skipping legacy host probe"
|
|
else
|
|
echo "RUNNER_HOST unset; skipping legacy host probe"
|
|
fi |