Repository navigation
Fix instance snapshots with KvmFileBasedStorageVmSnapshotStrategy - #14515
sureshanaparti wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
The new metadata-only deletion path is selected solely based on the absence of… · New The new metadata-only deletion path is selected solely based on the absence of… · New Given the new branching around ‘volume snapshot details’ vs ‘strategy marker’, it would be valuable… · New The tests introduced several string literals for snapshot detail keys… · New The tests introduced several string literals for snapshot detail keys… · New The tests introduced several string literals for snapshot detail keys… · New
What changed in this PR
Fixes KVM file-based VM snapshot lifecycle issues where failed snapshot creates could leave unclaimed Error rows and block instance deletion, by tagging snapshots early and adjusting handling/deletion behavior.
Changes:
- Persist a strategy marker detail early during snapshot creation so later
Errorrows are still recognized by this strategy. - Relax
canHandle()logic to claim snapshots based on either volume-snapshot details or the new strategy marker, with an eligibility fallback for legacyErrorrows. - Add a “metadata-only” deletion path for snapshots that never recorded volume snapshot details.
| File | Description |
|---|---|
| engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/KvmFileBasedStorageVmSnapshotStrategy.java | Adds strategy marker persistence, updates canHandle(), and introduces metadata-only deletion for detail-less snapshots. |
| engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/KvmFileBasedStorageVmSnapshotStrategyTest.java | Adds unit tests for strategy marker persistence, updated canHandle() behavior, and metadata-only deletion behavior. |
Review effort: Lite
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14515 +/- ##
============================================
+ Coverage 18.31% 18.35% +0.04%
- Complexity 16633 16689 +56
============================================
Files 5939 5939
Lines 537748 537847 +99
Branches 65924 65944 +20
============================================
+ Hits 98472 98728 +256
+ Misses 428070 427893 -177
- Partials 11206 11226 +20
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:
|
|
@blueorangutan package |
|
@sureshanaparti 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 19803 |
|
@blueorangutan package |
|
@sureshanaparti 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 19852 |
JoaoJandre
left a comment
There was a problem hiding this comment.
CLGTM. I might test it later
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-17483)
|
|
@blueorangutan test |
|
@RosiKyu a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
I tested this on a KVM lab (2 hosts, NFS primary storage) with the settings from #14481:
@sureshanaparti One case is still failing: an Error row created on 4.22.1.1, before the upgrade to the PR packages. After the upgrade, |
|
[SF] Trillian test result (tid-17622)
|
|
@blueorangutan package |
|
@sureshanaparti 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. |
@RosiKyu updated changes, please check. thanks. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20186 |



Description
This PR fixes the instance snapshots with KvmFileBasedStorageVmSnapshotStrategy.
KvmFileBasedStorageVmSnapshotStrategy.canHandle() rejected any snapshot past Allocated that lacked the kvmFileBasedStorageSnapshot detail, but that detail is only persisted after a successful create. A failed create (e.g. quiescevm=true on a guest without a running agent) therefore left an Error row no strategy would claim once DefaultVMSnapshotStrategy was excluded. deleteVMSnapshot then failed, and deleteAllVMSnapshots made destroyVirtualMachine fail too, leaving the instance undeletable.
The strategy now tags every snapshot it starts creating with a kvmFileBasedStorageSnapshotStrategy detail, so it recognises its own rows in any later state regardless of whether the VM is still eligible for disk-only snapshots. Error rows that predate the marker carry no detail at all. When another strategy (typically DefaultVMSnapshotStrategy) is available it handles them as before; when none can, the manager removes the row's metadata directly, the same way it already removes Allocated rows, so deleteVMSnapshot and destroyVirtualMachine succeed after an upgrade..
Deleting a row that never recorded volume snapshots only removes its metadata: nothing reached primary storage and no create usage events were published, so no host command or delete usage events are issued.
Fixes #14481
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?