Repository navigation
Nasbackup quiesce fixes - #14305
Nasbackup quiesce fixes#14305
Conversation
|
@MitchDrage thanks for the PR. I'll review/test it in the next few days. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Ambiguous freeze/thaw and job-status failures can still leave guests frozen or delete destinations under active jobs, while failed-row retention remains incomplete.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Fixes NAS backup quiescing, cleanup, and failed scheduled-backup handling.
Changes:
- Adds configurable guest-agent freeze/thaw timeouts.
- Aborts active libvirt jobs before cleanup.
- Preserves metadata for failed scheduled backups and expands tests.
| File | Description |
|---|---|
BackupManagerTest.java |
Tests failed scheduled-backup linkage. |
BackupManagerImpl.java |
Persists metadata on failed backups. |
nasbackup.sh |
Handles quiescing, aborts, and cleanup. |
LibvirtTakeBackupCommandWrapperTest.java |
Tests timeout argument forwarding. |
LibvirtTakeBackupCommandWrapper.java |
Passes timeout to the script. |
NASBackupProviderTest.java |
Tests failure and cleanup behavior. |
NASBackupProvider.java |
Adds timeout configuration and returns Error backups. |
TakeBackupCommand.java |
Carries the quiesce timeout. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14305 +/- ##
============================================
+ Coverage 18.00% 18.03% +0.03%
- Complexity 16219 16261 +42
============================================
Files 5936 5936
Lines 535716 535849 +133
Branches 65596 65614 +18
============================================
+ Hits 96459 96665 +206
+ Misses 428268 428166 -102
- Partials 10989 11018 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@vladimirpetrov @sureshanaparti could this go into the 4.22.2 milestone? It's a bug fix against 4.22. |
abh1sar
left a comment
There was a problem hiding this comment.
LGTM. Reviewed and tested.
- Failed scheduled backup shown as MANUAL - Verified
- Guest agent timeout not configurable - Verified that the timeout value is transmitted and honoured
- cleanup() removing the destination under a running job. - Verified that cleanup aborted the job
- Failed freeze never thawed - Verified that the guest was thawed in this case.
Also did regression testing around common backup operations and incremental backups. All passed.
|
@blueorangutan package |
|
@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19472 |
Damans227
left a comment
There was a problem hiding this comment.
thanks @MitchDrage, fixes look right. LGTM
|
@blueorangutan test |
|
@abh1sar a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-17107)
|
|
Can we mere this @vladimirpetrov @sureshanaparti ? |
|
Merging on the basis of reviews/tests and smokes results |
|
Awesome work, congrats on your first merged pull request! |
… integrity check Rebased onto 4.22 as a single commit (the branch history had several merges of 4.22, which a commit-by-commit rebase cannot replay cleanly). Resolved against "Nasbackup quiesce fixes (apache#14305)": TakeBackupCommand and NASBackupProvider keep both the enhancement details and the new quiesce timeout and cleanup alert; nasbackup.sh keeps both option sets and takes the upstream 'exit 1' after a failed backup job; the PR's enhancement-flag tests move to LibvirtTakeBackupCommandWrapperEnhancementFlagsTest next to the upstream LibvirtTakeBackupCommandWrapperTest. Squashed from: - address review (apache#12898): restore fails closed when the encryption state cannot be read - address review (apache#12898): nasbackup.sh compression/encryption guard, rate-limit probe, honest throttle logging, accept leaked clusters - address review (apache#12898): validate enhancement settings before the backup row exists, reject compression with encryption - Restore wrapper tests: count only qemu-img calls - address review (apache#12898): restore LUKS-encrypted backups - address review (apache#12898): reorder java.io imports alphabetically; drop trailing '(Copilot review)' comment artifacts - refactor(backup): extract NAS backup enhancement logic into dedicated methods + tests - refactor(backup): consolidate detail keys in TakeBackupCommand - Fix build: use reflection for protected ConfigKey.valueOf() in test - Fix NASBackupProviderTest failures for zone-scoped ConfigKey values - Fix tee masking exit codes and missing return in nasbackup.sh - Address Copilot review feedback on NAS backup PR apache#12898 - NAS backup enhancements: compression, encryption, bandwidth throttle, integrity check Claude-Session: https://claude.ai/code/session_01BhiE1Abhs315m3n3UPy6V7
A pull-mode backup job never finishes on its own; nasbackup.sh ends it with domjobabort once the data is read. Any exit the script did not plan for -- an unexpected error under "set -e", SIGINT/SIGTERM/SIGHUP -- left the job running, keeping the NBD server and the growing fleecing images alive and blocking every later backup or migration of the VM. Arm an EXIT trap once the scratch dir exists: it aborts the job (through apache#14305's BACKUP_JOB_ACTIVE/abort_backup_job), removes the scratch dir and runs cleanup(). This replaces the per-error-path abort/cleanup copies. The agent kills a timed-out script with SIGKILL, which no trap can catch, so LibvirtTakeBackupCommandWrapper aborts the job itself after a pull-mode timeout.
Rebased on the latest main as one commit (the old branch had a merge from main that no longer replays cleanly). Same changes as before, combined with the quiesce and job-abort fixes from apache#14305: - BACKUP_TIMEOUT (default 6 h) bounds the domjobinfo wait loop; the deadline also covers the query retries from apache#14305, and on timeout cleanup() aborts the job through abort_backup_job() before removing the destination - MIN_FREE_SPACE (default 1 GiB) is checked right after mount, for running and stopped VMs - trap cleanup EXIT so every exit path resumes a paused VM, aborts an active backup job and unmounts; CLEANUP_STARTED guards re-entry, and cleanup only removes/unmounts what exists and is mounted - backup_stopped_vm unmounts on success so the trap does not remove a completed backup - mount_operation tests mount's own exit status instead of tee's Signed-off-by: James Peru <jmsperu@gmail.com>
… integrity check Rebased onto 4.22 as a single commit (the branch history had several merges of 4.22, which a commit-by-commit rebase cannot replay cleanly). Resolved against "Nasbackup quiesce fixes (apache#14305)": TakeBackupCommand and NASBackupProvider keep both the enhancement details and the new quiesce timeout and cleanup alert; nasbackup.sh keeps both option sets and takes the upstream 'exit 1' after a failed backup job; the PR's enhancement-flag tests move to LibvirtTakeBackupCommandWrapperEnhancementFlagsTest next to the upstream LibvirtTakeBackupCommandWrapperTest. Squashed from: - address review (apache#12898): restore fails closed when the encryption state cannot be read - address review (apache#12898): nasbackup.sh compression/encryption guard, rate-limit probe, honest throttle logging, accept leaked clusters - address review (apache#12898): validate enhancement settings before the backup row exists, reject compression with encryption - Restore wrapper tests: count only qemu-img calls - address review (apache#12898): restore LUKS-encrypted backups - address review (apache#12898): reorder java.io imports alphabetically; drop trailing '(Copilot review)' comment artifacts - refactor(backup): extract NAS backup enhancement logic into dedicated methods + tests - refactor(backup): consolidate detail keys in TakeBackupCommand - Fix build: use reflection for protected ConfigKey.valueOf() in test - Fix NASBackupProviderTest failures for zone-scoped ConfigKey values - Fix tee masking exit codes and missing return in nasbackup.sh - Address Copilot review feedback on NAS backup PR apache#12898 - NAS backup enhancements: compression, encryption, bandwidth throttle, integrity check Claude-Session: https://claude.ai/code/session_01BhiE1Abhs315m3n3UPy6V7
… integrity check Rebased onto 4.22 as a single commit (the branch history had several merges of 4.22, which a commit-by-commit rebase cannot replay cleanly). Resolved against "Nasbackup quiesce fixes (apache#14305)": TakeBackupCommand and NASBackupProvider keep both the enhancement details and the new quiesce timeout and cleanup alert; nasbackup.sh keeps both option sets and takes the upstream 'exit 1' after a failed backup job; the PR's enhancement-flag tests move to LibvirtTakeBackupCommandWrapperEnhancementFlagsTest next to the upstream LibvirtTakeBackupCommandWrapperTest. Squashed from: - address review (apache#12898): restore fails closed when the encryption state cannot be read - address review (apache#12898): nasbackup.sh compression/encryption guard, rate-limit probe, honest throttle logging, accept leaked clusters - address review (apache#12898): validate enhancement settings before the backup row exists, reject compression with encryption - Restore wrapper tests: count only qemu-img calls - address review (apache#12898): restore LUKS-encrypted backups - address review (apache#12898): reorder java.io imports alphabetically; drop trailing '(Copilot review)' comment artifacts - refactor(backup): extract NAS backup enhancement logic into dedicated methods + tests - refactor(backup): consolidate detail keys in TakeBackupCommand - Fix build: use reflection for protected ConfigKey.valueOf() in test - Fix NASBackupProviderTest failures for zone-scoped ConfigKey values - Fix tee masking exit codes and missing return in nasbackup.sh - Address Copilot review feedback on NAS backup PR apache#12898 - NAS backup enhancements: compression, encryption, bandwidth throttle, integrity check Claude-Session: https://claude.ai/code/session_01BhiE1Abhs315m3n3UPy6V7
… the merges The merges of main into this branch lost most of apache#14305 in nasbackup.sh: - --quiesce-timeout was no longer parsed, so a quiesced backup, for which the agent passes it by default, failed with an invalid option on every storage - abort_backup_job() was gone, though the pull mode path of the Linstor backup still calls it, so a failed pull job kept the scratch devices busy - the push mode path lost the freeze timeout, the thaw after every freeze attempt, the thaw retries, the abort of the job in cleanup() and the retry of the domjobinfo query The script is main's again, plus what the rbd method adds. The rbd path now freezes and thaws the guest with the same helpers, resuming a paused Instance before it thaws.
* test: support Ceph/RBD primary storage in NAS backup smoke test test_backup_recovery_nas.py only allowed NFS primary storage, since it reused the primary storage pool's own path as the NAS backup repository address, and always required incremental-backup semantics that only qcow2/NFS storage can provide. Neither holds on Ceph/RBD. - setUpClass now accepts RBD alongside NFS as the primary storage pool type, picking a pool that's actually Up rather than list()[0] -- environments that added Ceph/RBD after the zone's original NFS primary storage keep that old pool around in Disabled state, and it still sorts first, silently exercising its path as if it were the storage VMs actually deploy on. - The NAS backup repository's NFS export address is resolved independently of the primary storage: when the primary pool isn't NFS, reuse the nfs test data entry (services[nfs][url]) -- the same temporary NFS mount point test_primary_storage.py uses for its temporary NFS primary storage pool, and something every marvin environment already has configured. An explicit nas_backup_repository_address test data entry or NAS_BACKUP_REPO_ADDRESS environment variable, if set, takes precedence. - The external offering imported in setUpClass is matched to the repository just created by externalid (== the repository's own id for the nas provider) rather than blindly taking index 0 -- a stray repository left over from an earlier interrupted run, whose backups didn't get cleaned up so its own teardown couldn't remove it either, sorts alongside the new one with no guarantee of which comes first. - Incremental NAS backups require QEMU dirty bitmaps / libvirt checkpoints, which only exist on file-based qcow2 storage (NASBackupProvider.allVolumesOnCheckpointCapableStorage). The six incremental-chain tests now skip on RBD/Ceph, where the provider always falls back to full-only backups server-side, rather than failing on assertions that storage type can never satisfy. - Added test_restore_volume_and_attach_to_vm, which exercises restoreVolumeFromBackupAndAttachToVM end-to-end (restoring a backed-up ROOT and DATADISK volume onto a second, stopped Instance) -- the API that drives the restore-and-attach code fixed by the previous commit (#14007). The target Instance is stopped with forced=True: a graceful ACPI stop was observed to time out (~2 minutes) before falling back to a hard destroy anyway, and once forced to a hard destroy the domain drops out of libvirt entirely, so the periodic ping-based PowerState sync the restore call depends on falls back to a much slower heuristic well past any reasonable wait. A forced stop destroys the domain immediately and deterministically. * KVM: support incremental NAS backups of RBD volumes Incremental NAS backups so far relied on QEMU dirty bitmaps / libvirt checkpoints, which only exist on file-based qcow2 storage. RBD images are raw and have nowhere to persist a bitmap, so any VM with a volume on Ceph was forced onto the full-only path and re-uploaded the whole image on every cycle. Ceph provides the equivalent natively, and this adds a second chain format that uses it: an `rbd snap` per cycle as the anchor plus `rbd export-diff --from-snap`, which computes the changed extents inside Ceph from the image object-map. NASBackupProvider now selects the mechanism per VM via getIncrementalFlavor() - QCOW2 for checkpoint-capable pools, RBD for Ceph, UNSUPPORTED (legacy full-only) for mixed or other storage, since the two formats cannot be mixed inside one backup. Everything else - chain identity, the nas.backup.full.every cadence, delete/tombstone semantics and resource accounting - is shared unchanged. Restore differs because an export-diff stream carries no pointer to the diff before it, unlike a rebased qcow2. The provider therefore sends the whole chain from its full anchor up to the backup being restored, and the agent recreates the image and replays each diff with `rbd import-diff` in order. The image has to be recreated: a full diff only carries the extents that were allocated when it was taken, so any block still allocated in the target would otherwise show through as stale data. That also drops RBD snapshots the volume carried, which is inherent to rewinding a volume wholesale. Two behaviours follow from the anchor living in Ceph rather than in the QEMU process: a stopped VM keeps its incremental cadence (no live QEMU needed), and a chain survives a VM restart or host migration. Only the newest anchor is kept per image; a full additionally sweeps every older snapshot carrying the csbackup- prefix, so a deleted chain, an unassigned offering or a restore cannot leak snapshots. The feature stays behind the existing nas.backup.incremental.enabled zone setting, which still defaults to false. Note: the agent drives the `rbd` CLI, so KVM hosts backing up Ceph volumes need ceph-common installed. Verified on a Ceph Reef 18.2.8 cluster with KVM hosts on Ceph Quincy 17.2.7 clients: FULL 1.86 GB followed by incrementals of 71 KB - 2.6 MB, restores replaying 2- and 3-diff chains across two RBD pools including through a tombstoned ancestor. test_backup_recovery_nas.py: the blanket RBD skip is replaced by an _is_rbd_storage() predicate, so the five chain tests now run on Ceph. test_stopped_vm_falls_back_to_full keeps a targeted skip because RBD has the opposite behaviour by design, and a new test_stopped_rbd_vm_keeps_incremental_cadence asserts that other side. * test: run the NAS backup smoke test on a cloud-init template The suite registered the legacy CentOS 5.5 tiny template via get_template(). Its kernel/udev does not reliably enumerate hot-attached virtio disks and it ships no mkfs.ext4, so the chain tests needed guest-side workarounds to reach the data they back up and restore. Register the Ubuntu 24.04 cloud-init template instead, which enumerates hot-attached disks, carries the usual filesystem tools and grows its root filesystem on first boot by itself. The cloud image disables SSH password authentication outright (60-cloudimg-settings.conf), so guest access moves to an SSH keypair and the stock "ubuntu" user. That user lands unprivileged, so commands touching /root or a raw block device now go through a _sudo() helper which wraps the whole command in `sh -c` under sudo, keeping redirects and ';'-separated commands root-privileged rather than just the first word. Cleanup ordering changes with it: a template cannot be deleted while a VM still uses it, so it is appended to _cleanup after the account that owns the VM, since cleanup_resources() deletes in list order. The in-place multi-disk restore regression test that accompanied this change upstream is left out: it asserts the uuid-based volume mapping in LibvirtRestoreBackupCommandWrapper, which this branch does not carry. * test: validate a whole backup chain, including across a mid-chain delete The existing chain tests each check one property of one backup: the full/incremental cadence, a restore from the tip, a delete that repairs or defers. None of them walks the chain as a whole, and none asserts on backup size. Add a test that builds FULL + 3 INCREMENTALs with a marker file per backup, restores from every backup and creates a VM from every backup, then deletes the 2nd incremental and repeats both sweeps over what survives. The mid-chain delete is what earns the runtime on RBD. An `rbd export-diff` stream carries no pointer to the diff before it, so a restore replays the whole sequence from the full anchor, and a diff whose descendant still needs it cannot be dropped when it is deleted, only hidden. Restoring the tip across that gap is what breaks if the provider ever sends a chain with a hole in it, and nothing else covered it. Sizes are asserted throughout: an incremental must be a small fraction of the full. That is what distinguishes a real export-diff delta from the whole image being re-exported every cycle, and no other test in this file looks at size at all, so a provider that silently fell back to full-every-time still passed. Each restore also asserts that markers written after that backup are gone. Checking only that the expected markers are present would pass even if the restore had quietly done nothing. VMs built from backups are expunged as the test goes rather than through _cleanup: seven of them are created, and holding them all to the end risks exhausting the environment's capacity partway through a run. * test: verify the guest of a VM created from a backup, not just that it boots The chain test checked an Instance created from a backup only for reaching Running. That proves the image boots; it says nothing about whether the diff chain was replayed into the new volume correctly, so a create-from-backup that produced a stale or empty image would still have passed. Check the guest the same way an in-place restore is checked: the markers taken up to that backup must be present, and markers written after it must be absent. The absent half matters as much as the present half -- without it, a VM that somehow came up with the source Instance's current disk would pass. Access uses the pattern already proven by test_incremental_after_vm_restart: the backup carries the source Instance's authorized_keys, so the new VM accepts the same keypair and the stock cloud-image "ubuntu" user. * nasbackup: carry the backup method separately from the mode The RBD path overloaded ChainDecision.mode with rbd-full and rbd-incremental, the same way the content-based path upstream overloaded it with content-full and content-incremental. Split the two concerns as that path already did: mode stays full or incremental, and a new method field says how the backup is taken -- qcow2 (push mode with dirty bitmaps) or rbd (Ceph-native, anchored on an rbd snapshot and exported with rbd export-diff). TakeBackupCommand gets a method field and nasbackup.sh a --method option. Both default to qcow2 when absent, so a management server that does not send a method keeps working against an upgraded agent. legacy-full is unchanged: rewriting it as full plus a "none" method would break incremental-disabled backups on agents that have not been upgraded yet. CHAIN_FORMAT stays as it is. The method says how a backup is taken and lives only for the duration of the request; the chain format is persisted and says what is on the repository, which is what restore and delete read later. The two coincide for the rbd method today but answer different questions. This mirrors c144d09 from #14194, which introduced the method for the content path and named an RBD diff as the next one to adopt it. Kept as close to that commit as the branch allows so the two merge cleanly: this branch carries the RBD path but not the content one, so the METHOD_CONTENT token is defined without a user here. * utils: add RbdUtils for the Ceph monitors of an RBD pool Everything that talks to Ceph needs the pool's monitors as a list the client can parse, and the rules are the same wherever that list is built: give each monitor the pool's port unless it names one already, and put a bare IPv6 address in square brackets so its own colons stay distinguishable from the separator before the port. The mon_host option of a disk's rbd: string wants the same list again, with ':' and ';' escaped, because those two separate the options of that string and its monitors. None of it depends on a storage pool, so collect it in RbdUtils as static methods with their unit tests, rather than leaving each caller to grow a copy that is right in a different set of cases. * kvm: build the Ceph monitors of the restore backup command with RbdUtils The monitors with a port, and the IPv6 monitors, are not valid arguments of rbd -m when the brackets are removed and the port is added to each monitor. * backup: name the rbd method in the TakeBackupCommand comment The field listed qcow2 and content but not rbd, the method this branch adds, so the one method a reader of this command is most likely to be chasing was the one the comment left out. * Add package dependencies * Add ceph-common as dependencies * kvm: refuse an RBD restore that would destroy a snapshot we did not take A restore rewinds the volume wholesale: the image is removed and rebuilt from its diff chain, so every snapshot it carried goes with it. The chain anchors this path takes are its own to drop, but a CloudStack volume snapshot kept on primary storage, or anything else taken outside this path, is content someone asked to keep, and destroying it quietly is not a trade the operator was offered. Ask what the image carries before touching it. A snapshot that is not one of ours refuses the restore, naming the ones in the way so they can be deleted or the backup restored into a new volume. Anything else is purged as before, except that an image which carries nothing is no longer handed a purge with nothing to do; when the listing itself fails we cannot tell, so it is purged as it always was. The failure to remove the image goes back to saying only that. Explaining it by a snapshot with clones made sense while a restore purged whatever it found, but the snapshot those clones belong to is now refused earlier, so a removal that still fails is failing for some other reason. The test that replays a whole chain stubbed every piped rbd call with the output of `rbd info`, whose "name" field would now read as a snapshot; tell the two commands apart there, and cover the refusal. * kvm: drop the cephx key file from a trap in nasbackup.sh The key the script hands the rbd CLI lives in a temporary file for the length of a call. cleanup() removes it, but only the failure paths call cleanup, so an exit that does not reach it left the key behind. Leave its removal to the shell as well, which covers every exit it still gets to run code on. * utils: test the escaped colons of an IPv6 Ceph monitor without a port composeOptionForMonHosts escapes every ':' of a monitor, because the colons separate the options of the rbd: string. That includes the colons of an IPv6 address, also when the pool has no port to add. Test that case, and make addPortToRbdMonitor, which is only used by RbdUtils itself, protected. * kvm: remove the backup anchor once the chain it anchors is gone An RBD chain is exported from a snapshot of every volume, the anchor, named csbackup-<id>. Each backup drops the previous anchor once its delta has been exported, so one anchor per volume is kept: the one the next incremental reads from. Nothing removed the last one. When the last backup of a chain was deleted, or the Instance was taken out of its backup offering, the anchor stayed on the image for as long as the volume lived, and with it the data it references: the next backup is a full one either way, so nothing ever read it again. Remove the anchors of an Instance's volumes wherever the chain ends, next to where the Instance's active checkpoint is already cleared. nasbackup.sh takes a removeanchors operation, which sweeps every snapshot carrying the backup prefix off the volumes it is given: only the snapshots this tool creates carry it, so a user or volume snapshot is never touched. The removal is best effort. The chain is gone either way, and a host that cannot be reached must not fail the delete of a backup or the removal of an offering, so a failure is logged rather than thrown. An Instance with no volume on an RBD pool carries no anchor and is left alone. * nas: decide a chain from its flavour rather than from an rbd flag decideChain carried a boolean telling the RBD flavour apart from the QCOW2 one, and every branch that differs between the two read it: the prefix of the anchor it names, the on-NAS format it requires of the parent, the decision it returns, and whether a stopped Instance can continue the chain at all. A third flavour would have to be threaded through each of them separately. Ask the flavour instead. anchorPrefixOf, flavorToFormat and flavorSupportsIncrementalWhileStopped answer the three questions the branches were asking, incrementalDecision builds the next link of a chain as fullDecision already built the first one, and both take the flavour. The prefix of a QCOW2 anchor is named alongside the RBD one rather than written in place. Behaviour is unchanged: a stopped Instance only reaches the full it took before when its flavour cannot continue a chain while stopped, which is every flavour but RBD, so the decision it returns is the same one. Also rename applyBackupFormat to applyBackupFormatToRestoreCommand, which says what it applies the format to. * packaging: suggest ceph-common instead of requiring it The agent only needs the rbd command line tools for RBD backups and migrations; python3-rados and python3-rbd stay required. * nas: address review of the RBD incremental backups - restore: check every target volume (RBD storage, no foreign snapshots) before removing any image, so a later volume cannot fail after an earlier one was already rewound - restore: replay each rbd import-diff with the restore timeout instead of the one hour default - backup: pause a running multi-disk VM around the RBD snapshots when the filesystems were not frozen, so the set is crash consistent - drop em-dashes from log and exception messages * nas: run RBD backups on a host that has the rbd command ceph-common is only suggested by the agent package, so not every KVM host has the rbd command. The agent now reports whether it does (host.rbd.cli) and an RBD backup runs on a host that has it: the Instance's own host, or for a stopped Instance any other Up host of its cluster. When there is none, a plain full backup is taken instead of failing on the missing command. * nas: restore RBD backups on a host that has the rbd command Restoring an RBD chain recreates the image and replays the diffs with the rbd command, which a host may lack as ceph-common is only suggested. Restore on the Instance's host when it has the command, otherwise on another host of its cluster that has it. A volume restore that attaches to a running Instance has to stay on that Instance's host. When no usable host has the command, fail with a message that says so. * import com.cloud.utils.exception.CloudRuntimeException * nasbackup.sh: bring back the quiesce fixes of #14305 dropped by the merges The merges of main into this branch lost most of #14305 in nasbackup.sh: - --quiesce-timeout was no longer parsed, so a quiesced backup, for which the agent passes it by default, failed with an invalid option on every storage - abort_backup_job() was gone, though the pull mode path of the Linstor backup still calls it, so a failed pull job kept the scratch devices busy - the push mode path lost the freeze timeout, the thaw after every freeze attempt, the thaw retries, the abort of the job in cleanup() and the retry of the domjobinfo query The script is main's again, plus what the rbd method adds. The rbd path now freezes and thaws the guest with the same helpers, resuming a paused Instance before it thaws. * nas: tell the user why a restore of an Instance from a backup failed When the host refuses or fails the restore, the NAS provider returned only false and the backup manager answered with the generic error, so the reason the host gave, such as an RBD image carrying snapshots the backup path did not take, never reached the user. Throw a BackupProviderException with the details of the answer, which the backup manager hands to the user as it is. * nas: check for volume snapshots on RBD before restoring an Instance from a backup Restoring an RBD volume from a backup rewinds the image wholesale, which removes every snapshot it carries, so the host refuses it when the image carries a snapshot the backup path did not take. Check the volume snapshots kept on primary storage in the management server first, and refuse before anything is sent to the host with the names of the volume and of its snapshots. The host still checks the image, which also catches snapshots CloudStack does not know about. * nas: remove a duplicate import of DataStoreRole in the test NASBackupProviderTest imported com.cloud.storage.DataStoreRole twice, which the checkstyle check of the build refuses. * test: release the public IP of each Instance the NAS backup tests create Marvin gives every Instance created by VirtualMachine.create or Backup.createVMFromBackup its own public IP, with a port forwarding rule for SSH, and destroying the Instance does not release that IP. The class only got them back when its account was removed, so the tests which create Instances from backups ran out of the 13 free addresses of the public range and failed with "Insufficient address capacity", after which Marvin silently left ssh_ip unset. Add release_publicIP() to marvin.lib.common, which releases a public IP unless it is the source NAT address of the network, and call it for the Instances of each test in tearDown, for the target Instance of test_restore_volume_and_attach_to_vm, and for each Instance which test_full_chain_restore_and_create_vm_survive_mid_chain_delete destroys as it goes. The Instance shared by the class keeps its IP until the class ends. * kvm: build every Ceph monitor list with RbdUtils The agent assembled the monitor list in several places, each with its own idea of the rules. Opening a RADOS connection, or writing a ceph.conf for one, appended the pool's port to the host string as a whole, so with several monitors only the last was given it and a monitor that already named its port was handed a second. The rbd: option string of a disk escaped the colons of an IPv6 address only when it was bracketed already, which left a bare one reading as though it carried options of its own. Use the shared helpers for all of them. Two inputs therefore come out differently, both previously wrong: a monitor that names its port keeps just that one, and a bare IPv6 address is bracketed before anything is appended to it or escaped in it. The iscsiadm portals in IscsiAdmStorageAdaptor read the same way but are not monitor lists, so they keep their own formatting. * nas: address the second review of the RBD incremental backups - restore: fail closed when the snapshots of an RBD image can not be listed, so a restore never removes snapshots it could not see; a missing image (exit code 2) has none. - removing the offering sends the anchor cleanup to a host which has the rbd command, and sends none when no host has it. - build the Ceph monitor list of an RBD disk string with RbdUtils, so a bare IPv6 monitor is bracketed, carries its port and survives nasbackup.sh's parser. - RBD backup: bound the freeze, pause and snapshot steps with timeouts and keep a state file in /run/csbackup while the guest is held. The guest is released by a TERM/HUP/INT trap of the script, by the take-backup wrapper when the script failed or was killed, and by the agent for every state file left when it starts (RbdBackupGuestReleaser), which covers SIGKILL, a crash and a restart of the agent. - nasbackup.sh holds a per-VM flock during the RBD backup, so two backups of a VM can not freeze the guest and share the state file at once. A refused backup exits with 21 and the wrapper then leaves the guest to the backup which holds the lock.


Description
Fixes #14295, one commit per issue:
BackupManagerImplrecords the schedule id, name and description on it.nas.backup.quiesce.agent.timeout(default 30 seconds, 0 keeps libvirt's default of 5), passed tonasbackup.shas--quiesce-timeoutand on tovirsh --timeoutfor freeze and thaw. The per-VM override from the issue is left out.cleanup()now runsvirsh domjobabortand waits up to 60 seconds for the job to end. If it is still running, the files and mount are left in place and the backup goes to Error state. Also fixed theFailedbranch of the job polling loop, which calledcleanupwithout exiting.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
I've listed this as major as I'm having backups continuously fail. I've applied the timeout to nasbackup.sh by hand as a workaround and I'm waiting on the next scheduled run to confirm it. I'll add a comment tomorrow as to the result, or add some changes to fix it.
How Has This Been Tested?
BackupManagerTest,NASBackupProviderTestand a newLibvirtTakeBackupCommandWrapperTest. These and the NAS plugin suite pass.nasbackup.shagainst stubvirsh/mountcommands for each failure path, including an abort that never completes.--timeout 30on freeze and thaw completed. Separately, aborting a running push backup ended the job about 1.4 seconds afterdomjobabortreturned, after which the destination could be removed and unmounted.How did you try to break this feature and the system with this change?