Add timeout and better error messages to connection test
The connection test now: - Has a 30-second timeout to prevent indefinite hanging - Shows "This may take up to 30 seconds..." message - Differentiates between timeout (unreachable) and auth errors - Provides specific troubleshooting steps based on error type - Displays helpful commands for diagnosing connection issues This fixes the issue where the script would hang indefinitely when the PBS server was unreachable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8e958159d1
commit
fde5a9edf2
1 changed files with 29 additions and 4 deletions
|
|
@ -486,16 +486,41 @@ create_encryption_key() {
|
||||||
# Test connection to PBS
|
# Test connection to PBS
|
||||||
test_connection() {
|
test_connection() {
|
||||||
log "Testing connection to PBS server..."
|
log "Testing connection to PBS server..."
|
||||||
|
info "This may take up to 30 seconds..."
|
||||||
|
|
||||||
export PBS_REPOSITORY="$PBS_REPOSITORY"
|
export PBS_REPOSITORY="$PBS_REPOSITORY"
|
||||||
export PBS_PASSWORD="$PBS_PASSWORD"
|
export PBS_PASSWORD="$PBS_PASSWORD"
|
||||||
|
|
||||||
if proxmox-backup-client snapshot list &>/dev/null; then
|
# Use timeout to prevent hanging (30 seconds max)
|
||||||
|
if timeout 30 proxmox-backup-client snapshot list &>/dev/null; then
|
||||||
log "Connection test successful!"
|
log "Connection test successful!"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
local exit_code=$?
|
||||||
|
echo
|
||||||
error "Connection test failed"
|
error "Connection test failed"
|
||||||
error "Please verify your server details and credentials"
|
|
||||||
|
if [ $exit_code -eq 124 ]; then
|
||||||
|
error "Connection timed out after 30 seconds"
|
||||||
|
error "Possible issues:"
|
||||||
|
error " - PBS server is unreachable (check IP/hostname)"
|
||||||
|
error " - Firewall blocking port ${PBS_PORT}"
|
||||||
|
error " - Network connectivity issues"
|
||||||
|
else
|
||||||
|
error "Authentication or configuration error"
|
||||||
|
error "Possible issues:"
|
||||||
|
error " - Invalid credentials (username/password/token)"
|
||||||
|
error " - Datastore does not exist on server"
|
||||||
|
error " - User lacks permissions for the datastore"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
info "Troubleshooting:"
|
||||||
|
echo " 1. Verify server is reachable: ping ${PBS_SERVER}"
|
||||||
|
echo " 2. Test HTTPS connection: curl -k https://${PBS_SERVER}:${PBS_PORT}"
|
||||||
|
echo " 3. Verify credentials in PBS web interface"
|
||||||
|
echo " 4. Check datastore name matches exactly"
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue