Some checks failed
API CI / API Lint (push) Successful in 47s
API CI / API Type Check (push) Failing after 47s
API CI / API Test (push) Successful in 1m0s
API CI / API Build (push) Failing after 50s
API CI / Build Docker Image (push) Has been skipped
Build Crossplane Provider / build (push) Failing after 5m51s
CD Pipeline / Deploy to Staging (push) Failing after 29s
CI Pipeline / Lint and Type Check (push) Failing after 36s
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Test Backend (push) Failing after 1m33s
CI Pipeline / Test Frontend (push) Failing after 30s
CI Pipeline / Security Scan (push) Failing after 1m16s
Crossplane Provider CI / Go Test (push) Failing after 3m23s
Crossplane Provider CI / Go Lint (push) Failing after 7m27s
Crossplane Provider CI / Go Build (push) Failing after 3m27s
Deploy to Staging / Deploy to Staging (push) Failing after 30s
Portal CI / Portal Lint (push) Failing after 21s
Portal CI / Portal Type Check (push) Failing after 21s
Portal CI / Portal Test (push) Failing after 21s
Portal CI / Portal Build (push) Failing after 22s
Test Suite / frontend-tests (push) Failing after 30s
Test Suite / api-tests (push) Failing after 49s
Test Suite / blockchain-tests (push) Failing after 30s
Type Check / type-check (map[directory:. name:root]) (push) Failing after 23s
Type Check / type-check (map[directory:api name:api]) (push) Failing after 21s
Type Check / type-check (map[directory:portal name:portal]) (push) Failing after 19s
Validate Configuration Files / validate (push) Failing after 1m52s
CD Pipeline / Deploy to Production (push) Has been skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
125 lines
4.3 KiB
Bash
Executable File
125 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
log() {
|
|
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" >&2
|
|
}
|
|
|
|
error() {
|
|
log "ERROR: $*"
|
|
exit 1
|
|
}
|
|
|
|
IMAGE_NAME="docker.io/library/crossplane-provider-proxmox"
|
|
PROJECT_DIR="/home/intlc/projects/Sankofa/crossplane-provider-proxmox"
|
|
|
|
log "=========================================="
|
|
log "NUCLEAR CLEANUP AND REBUILD"
|
|
log "=========================================="
|
|
log ""
|
|
|
|
# Step 1: Remove ALL crossplane-provider-proxmox images from containerd
|
|
log "Step 1: Removing ALL crossplane-provider-proxmox images from containerd..."
|
|
ALL_IMAGES=$(sudo ctr -n k8s.io images ls -q | grep "${IMAGE_NAME}" || true)
|
|
if [ -n "$ALL_IMAGES" ]; then
|
|
echo "$ALL_IMAGES" | while read -r img; do
|
|
log " Removing: $img"
|
|
sudo ctr -n k8s.io images rm "$img" 2>/dev/null || true
|
|
done
|
|
log " ✅ All images removed"
|
|
else
|
|
log " No images found (already clean)"
|
|
fi
|
|
|
|
# Step 2: Prune containerd images (remove unused)
|
|
log ""
|
|
log "Step 2: Pruning unused containerd images..."
|
|
sudo ctr -n k8s.io images prune 2>&1 | head -10 || log " (Prune completed)"
|
|
|
|
# Step 3: Check Docker daemon and determine access method
|
|
log ""
|
|
log "Step 3: Checking Docker daemon..."
|
|
# If running as root (via sudo), use original user for Docker commands
|
|
# since Docker is running in rootless mode with user-specific socket
|
|
DOCKER_CMD="docker"
|
|
if [ "$EUID" -eq 0 ]; then
|
|
ORIGINAL_USER="${SUDO_USER:-${USER}}"
|
|
if [ -n "$ORIGINAL_USER" ] && [ "$ORIGINAL_USER" != "root" ]; then
|
|
log " Running Docker commands as user: $ORIGINAL_USER (rootless Docker)"
|
|
# Preserve DOCKER_HOST and other Docker env vars
|
|
DOCKER_HOST_VAL="${DOCKER_HOST:-unix:///run/user/$(id -u $ORIGINAL_USER)/docker.sock}"
|
|
DOCKER_CMD="sudo -u $ORIGINAL_USER env DOCKER_HOST=$DOCKER_HOST_VAL docker"
|
|
fi
|
|
else
|
|
# Not root - preserve current DOCKER_HOST if set
|
|
if [ -n "${DOCKER_HOST:-}" ]; then
|
|
DOCKER_CMD="env DOCKER_HOST=$DOCKER_HOST docker"
|
|
fi
|
|
fi
|
|
|
|
# Verify Docker access
|
|
if ! $DOCKER_CMD ps >/dev/null 2>&1; then
|
|
error "Docker daemon is not accessible! Please ensure Docker is running. Try: docker ps"
|
|
fi
|
|
log " ✅ Docker daemon is accessible (using: $DOCKER_CMD)"
|
|
|
|
# Step 4: Remove Docker images locally
|
|
log ""
|
|
log "Step 4: Removing local Docker images..."
|
|
$DOCKER_CMD rmi crossplane-provider-proxmox:latest crossplane-provider-proxmox:final-fix 2>/dev/null || log " (Images not found in Docker, continuing...)"
|
|
|
|
# Step 5: Clean Docker build cache
|
|
log ""
|
|
log "Step 5: Cleaning Docker build cache..."
|
|
$DOCKER_CMD builder prune -af --filter "until=24h" 2>&1 | tail -5 || log " (Cache clean completed)"
|
|
|
|
# Step 6: Rebuild image from scratch (no cache)
|
|
log ""
|
|
log "Step 6: Rebuilding image from scratch (NO CACHE)..."
|
|
cd "$PROJECT_DIR" || error "Cannot cd to $PROJECT_DIR"
|
|
$DOCKER_CMD build --no-cache --pull -t crossplane-provider-proxmox:latest . 2>&1 | tail -20
|
|
|
|
# Step 7: Save the fresh image
|
|
log ""
|
|
log "Step 7: Saving fresh image..."
|
|
$DOCKER_CMD save crossplane-provider-proxmox:latest -o /tmp/crossplane-fresh-nuclear.tar
|
|
log " ✅ Image saved to /tmp/crossplane-fresh-nuclear.tar"
|
|
ls -lh /tmp/crossplane-fresh-nuclear.tar
|
|
|
|
# Step 8: Import to containerd
|
|
log ""
|
|
log "Step 8: Importing fresh image to containerd..."
|
|
sudo ctr -n k8s.io images import /tmp/crossplane-fresh-nuclear.tar
|
|
log " ✅ Image imported"
|
|
|
|
# Step 9: Verify import
|
|
log ""
|
|
log "Step 9: Verifying import..."
|
|
IMPORTED=$(sudo ctr -n k8s.io images ls -q | grep "${IMAGE_NAME}:latest" || true)
|
|
if [ -z "$IMPORTED" ]; then
|
|
error "Image ${IMAGE_NAME}:latest not found after import!"
|
|
fi
|
|
log " ✅ Image verified: $IMPORTED"
|
|
|
|
# Step 10: Show final state
|
|
log ""
|
|
log "Step 10: Final image state:"
|
|
sudo ctr -n k8s.io images ls | grep "${IMAGE_NAME}" || error "No crossplane images found!"
|
|
|
|
log ""
|
|
log "=========================================="
|
|
log "CLEANUP AND REBUILD COMPLETE"
|
|
log "=========================================="
|
|
log ""
|
|
log "Next steps:"
|
|
log " 1. Apply the deployment:"
|
|
log " kubectl apply -f $PROJECT_DIR/config/provider.yaml"
|
|
log ""
|
|
log " 2. Wait for pod to be ready:"
|
|
log " kubectl wait --for=condition=ready pod -n crossplane-system -l app=crossplane-provider-proxmox --timeout=120s"
|
|
log ""
|
|
log " 3. Verify [FIXED CODE] appears in logs:"
|
|
log " kubectl logs -n crossplane-system -l app=crossplane-provider-proxmox | grep '\[FIXED CODE\]'"
|
|
|
|
|