Fix authentication test to use correct PBS client commands
The issue was using 'proxmox-backup-client status' which doesn't exist. Changes: - Use 'proxmox-backup-client login' for authentication testing (This is the proper command to test credentials) - Use 'proxmox-backup-client list' instead of 'snapshot list' (Simpler command to verify datastore access) - Reduced timeouts from 30s to 15s (these commands are faster) - Added debug output showing the repository string being used - Improved error message display from PBS client This should resolve authentication timeouts and actually show real error messages when credentials are invalid. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8f8cd12a67
commit
fd5c876d7d
1 changed files with 14 additions and 8 deletions
|
|
@ -516,12 +516,12 @@ test_connection() {
|
||||||
fi
|
fi
|
||||||
log "Server is reachable"
|
log "Server is reachable"
|
||||||
|
|
||||||
# Step 2: Test authentication with a simple command
|
# Step 2: Test authentication
|
||||||
info "Step 2/3: Testing authentication..."
|
info "Step 2/3: Testing authentication..."
|
||||||
|
|
||||||
# Try to get datastore status (simpler than listing snapshots)
|
# Use the 'login' command which tests authentication and stores a ticket
|
||||||
local test_output
|
local test_output
|
||||||
if test_output=$(timeout 30 proxmox-backup-client status --output-format json 2>&1); then
|
if test_output=$(timeout 15 proxmox-backup-client login 2>&1); then
|
||||||
log "Authentication successful"
|
log "Authentication successful"
|
||||||
else
|
else
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
|
|
@ -533,7 +533,11 @@ test_connection() {
|
||||||
else
|
else
|
||||||
error "Authentication failed"
|
error "Authentication failed"
|
||||||
# Show the actual error from PBS client
|
# Show the actual error from PBS client
|
||||||
echo "$test_output" | grep -i "error\|permission\|authentication\|denied" | head -3
|
if echo "$test_output" | grep -q "error\|Error"; then
|
||||||
|
echo
|
||||||
|
echo "$test_output" | grep -i "error" | head -5
|
||||||
|
echo
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
error "Possible issues:"
|
error "Possible issues:"
|
||||||
|
|
@ -547,18 +551,20 @@ test_connection() {
|
||||||
echo " 2. Check datastore name: ${PBS_DATASTORE}"
|
echo " 2. Check datastore name: ${PBS_DATASTORE}"
|
||||||
echo " 3. Verify user has backup permissions"
|
echo " 3. Verify user has backup permissions"
|
||||||
echo " 4. For API tokens, format is: username@realm!tokenname"
|
echo " 4. For API tokens, format is: username@realm!tokenname"
|
||||||
|
echo
|
||||||
|
info "Debug info:"
|
||||||
|
echo " Repository: ${PBS_REPOSITORY}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 3: Verify datastore access
|
# Step 3: Verify datastore access by listing backup groups
|
||||||
info "Step 3/3: Verifying datastore access..."
|
info "Step 3/3: Verifying datastore access..."
|
||||||
if timeout 30 proxmox-backup-client snapshot list &>/dev/null; then
|
if timeout 15 proxmox-backup-client list 2>/dev/null; then
|
||||||
log "Datastore access verified"
|
log "Datastore access verified"
|
||||||
log "Connection test successful!"
|
log "Connection test successful!"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
warn "Could not list snapshots, but authentication works"
|
warn "Could not list backup groups (this is normal if no backups exist yet)"
|
||||||
info "This is normal if no backups exist yet"
|
|
||||||
log "Connection test successful!"
|
log "Connection test successful!"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue