Files
Sankofa/scripts/fix-vm-lock.sh
defiQUG 9daf1fd378 Apply Composer changes: comprehensive API updates, migrations, middleware, and infrastructure improvements
- Add comprehensive database migrations (001-024) for schema evolution
- Enhance API schema with expanded type definitions and resolvers
- Add new middleware: audit logging, rate limiting, MFA enforcement, security, tenant auth
- Implement new services: AI optimization, billing, blockchain, compliance, marketplace
- Add adapter layer for cloud integrations (Cloudflare, Kubernetes, Proxmox, storage)
- Update Crossplane provider with enhanced VM management capabilities
- Add comprehensive test suite for API endpoints and services
- Update frontend components with improved GraphQL subscriptions and real-time updates
- Enhance security configurations and headers (CSP, CORS, etc.)
- Update documentation and configuration files
- Add new CI/CD workflows and validation scripts
- Implement design system improvements and UI enhancements
2025-12-12 18:01:35 -08:00

79 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Fix VM lock issues on Proxmox nodes
set -e
VMID=${1:-100}
NODE=${2:-ml110-01}
echo "=== Fixing VM Lock for VMID $VMID on $NODE ==="
echo ""
# Load environment variables
if [ -f .env ]; then
source .env
else
echo "ERROR: .env file not found"
exit 1
fi
echo "1. Checking VM status:"
echo "----------------------------------------"
sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "qm status $VMID" || echo " ⚠️ Could not get VM status"
echo ""
echo "2. Checking for lock file:"
echo "----------------------------------------"
LOCK_FILE="/var/lock/qemu-server/lock-$VMID.conf"
if sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "test -f $LOCK_FILE"; then
echo " ⚠️ Lock file exists: $LOCK_FILE"
echo " Lock file contents:"
sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "cat $LOCK_FILE" || echo " Could not read lock file"
else
echo " ✅ No lock file found"
fi
echo ""
echo "3. Checking for stuck processes:"
echo "----------------------------------------"
PROCS=$(sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "ps aux | grep -E 'qm (start|stop|destroy|set)' | grep -v grep || echo ''")
if [ -n "$PROCS" ]; then
echo " ⚠️ Found processes:"
echo "$PROCS" | sed 's/^/ /'
else
echo " ✅ No stuck processes found"
fi
echo ""
echo "4. Attempting to unlock VM:"
echo "----------------------------------------"
if sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "qm unlock $VMID" 2>&1; then
echo " ✅ Unlock command executed"
else
echo " ⚠️ Unlock command failed or VM not locked"
fi
echo ""
echo "5. Removing lock file (if exists):"
echo "----------------------------------------"
if sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "rm -f $LOCK_FILE" 2>&1; then
echo " ✅ Lock file removed (if it existed)"
else
echo " ⚠️ Could not remove lock file"
fi
echo ""
echo "6. Final VM status:"
echo "----------------------------------------"
sshpass -p "$PROXMOX_ROOT_PASS" ssh -o StrictHostKeyChecking=no root@$NODE "qm status $VMID" || echo " ⚠️ Could not get VM status"
echo ""
echo "=== Done ==="
echo ""
echo "If issues persist, you may need to:"
echo "1. Stop the VM: qm stop $VMID"
echo "2. Wait a few seconds"
echo "3. Remove lock file: rm -f $LOCK_FILE"
echo "4. Retry the operation"