cloudstack/scripts/vm
James Peru Mmbono 9f281c4851
NAS backup: resume paused VM on backup failure and fix missing exit (#12822)
* NAS backup: resume paused VM on backup failure and fix missing exit

When a NAS backup job fails (e.g. due to backup storage being full or
I/O errors), the VM may remain indefinitely paused because:

1. The cleanup() function never checks or resumes the VM's paused state
   that was set by virsh backup-begin during the push backup operation.

2. The 'Failed' case in the backup job monitoring loop calls cleanup()
   but lacks an 'exit' statement, causing an infinite loop where the
   script repeatedly detects the failed job and calls cleanup().

3. Similarly, backup_stopped_vm() calls cleanup() on qemu-img convert
   failure but does not exit, allowing the loop to continue with
   subsequent disks despite the failure.

This fix:
- Adds VM state detection and resume to cleanup(), ensuring the VM is
  always resumed if found in a paused state during error handling
- Adds missing 'exit 1' after cleanup() in the Failed backup job case
  to prevent the infinite monitoring loop
- Adds missing 'exit 1' after cleanup() in backup_stopped_vm() on
  qemu-img convert failure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ci: retrigger workflow (flaky/stale shards)

* nasbackup.sh: keep cleanup() best-effort if domstate fails

With set -eo pipefail, a non-zero virsh domstate (libvirt unavailable or the
domain gone) in the vm_state assignment would abort cleanup() before the
rm/umount/rmdir. Append '|| true' so cleanup always runs to completion.
Addresses the review suggestion (Copilot, endorsed by @abh1sar and @weizhouapache).

Signed-off-by: James Peru <jmsperu@gmail.com>

---------

Signed-off-by: James Peru <jmsperu@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: jmsperu <jmsperu@users.noreply.github.com>
2026-07-07 13:04:50 +02:00
..
hypervisor NAS backup: resume paused VM on backup failure and fix missing exit (#12822) 2026-07-07 13:04:50 +02:00
network Replace deprecated 'egrep' commands with 'grep -E'. (#12306) 2025-12-22 14:27:41 +01:00
systemvm pre-commit: add hook to trim trailing whitespace (#8205) 2024-05-28 09:01:30 +02:00
pingtest.sh pre-commit: add hook to trim trailing whitespace (#8205) 2024-05-28 09:01:30 +02:00