sharenet/pip_ready.sh
continuist 6624c2a340
Some checks are pending
CI/CD Pipeline with Secure Ephemeral PiP / test-backend (push) Waiting to run
CI/CD Pipeline with Secure Ephemeral PiP / test-frontend (push) Blocked by required conditions
CI/CD Pipeline with Secure Ephemeral PiP / build-backend (push) Blocked by required conditions
CI/CD Pipeline with Secure Ephemeral PiP / build-frontend (push) Blocked by required conditions
CI/CD Pipeline with Secure Ephemeral PiP / cleanup (push) Blocked by required conditions
Security improvements #1
2025-09-04 22:15:49 -04:00

59 lines
No EOL
1.9 KiB
Bash

#!/bin/bash
set -euo pipefail
# pip_ready.sh - Socket-only readiness probe for PiP container
# Checks if PiP container can connect to host Podman via UNIX socket
RUN_ID="${GITHUB_RUN_ID:-local}"
PIP_CONTAINER_NAME="ci-pip-${RUN_ID}"
MAX_RETRIES=15
RETRY_DELAY=2
# Function to check PiP socket connectivity only
check_pip_ready() {
echo "🔍 Checking PiP container socket connectivity..."
# Check if container exists and is running
if ! podman inspect "${PIP_CONTAINER_NAME}" --format '{{.State.Status}}' 2>/dev/null | grep -q running; then
echo "❌ PiP container not running"
return 1
fi
# Test basic Podman command connectivity (socket only)
if ! podman exec "${PIP_CONTAINER_NAME}" podman info --format json >/dev/null 2>&1; then
echo "⚠️ PiP container running but socket connectivity failed"
return 1
fi
# Test version command (socket connectivity verification)
if ! podman exec "${PIP_CONTAINER_NAME}" podman version >/dev/null 2>&1; then
echo "⚠️ PiP container socket connection unstable"
return 1
fi
echo "✅ PiP container ready with socket connectivity"
return 0
}
# Main readiness check with retries
attempt=1
while [[ ${attempt} -le ${MAX_RETRIES} ]]; do
if check_pip_ready; then
echo "🎉 PiP container is ready for CI operations!"
exit 0
fi
echo "⏳ PiP socket connectivity not ready yet (attempt ${attempt}/${MAX_RETRIES}), retrying in ${RETRY_DELAY}s..."
sleep ${RETRY_DELAY}
attempt=$((attempt + 1))
done
# If we reach here, all retries failed
echo "❌ ERROR: PiP container failed to establish socket connectivity after ${MAX_RETRIES} attempts"
echo "📋 Container status:"
podman ps -a --filter "name=${PIP_CONTAINER_NAME}" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || true
echo "📋 Container logs:"
podman logs "${PIP_CONTAINER_NAME}" 2>/dev/null || echo "No logs available"
exit 1