Fix rollback disk snapshots on instance snapshot failure#12949
Fix rollback disk snapshots on instance snapshot failure#12949sureshanaparti wants to merge 2 commits intoapache:4.22from
Conversation
|
@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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12949 +/- ##
============================================
- Coverage 17.60% 17.60% -0.01%
+ Complexity 15677 15676 -1
============================================
Files 5918 5918
Lines 531681 531685 +4
Branches 65005 65006 +1
============================================
- Hits 93623 93616 -7
- Misses 427498 427509 +11
Partials 10560 10560
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17339 |
There was a problem hiding this comment.
Pull request overview
Fixes cleanup/rollback of per-volume disk snapshots when an instance (VM) snapshot operation fails, preventing orphaned snapshots and incorrect snapshot resource counts (issue #12927).
Changes:
- Track created disk snapshots for rollback using a
Map<volumeId, SnapshotInfo>to ensure snapshots are rolled back even if creation fails mid-way. - Harden rollback logic with null checks and improve rollback logging.
- Update the KVM VM snapshot strategy unit test to match the new
createDiskSnapshotmethod signature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java | Track snapshots for rollback via volume-id map; ensure rollback attempts occur on failures; add null-safety/logging improvements. |
| engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java | Adjust unit test to pass the new rollback map parameter to createDiskSnapshot. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...apshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java
Outdated
Show resolved
Hide resolved
...apshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java
Outdated
Show resolved
Hide resolved
DaanHoogland
left a comment
There was a problem hiding this comment.
I may be missing some context, hence my questions?!?
...apshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java
Outdated
Show resolved
Hide resolved
...apshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java
Outdated
Show resolved
Hide resolved
|
@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 17383 |
JoaoJandre
left a comment
There was a problem hiding this comment.
CLGTM, did not test it
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| FreezeThawVMCommand thawCmd = null; | ||
| FreezeThawVMAnswer thawAnswer = null; | ||
| List<SnapshotInfo> forRollback = new ArrayList<>(); | ||
| List<SnapshotInfo> snapshotInfoListForRollback = new ArrayList<>(); |
There was a problem hiding this comment.
snapshotInfoListForRollback is very verbose and repeats the generic type (SnapshotInfo) already conveyed by List<SnapshotInfo>. Consider renaming to something shorter and intention-revealing like rollbackSnapshots / snapshotsForRollback to improve readability (optional).
There was a problem hiding this comment.
snapshotsForRollback seems appropriate, @sureshanaparti ? (or close/ignore)
| vol.addPayload(setPayload(vol, snapshot, quiescevm)); | ||
| SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshot.getId(), vol.getDataStore()); | ||
| snapshotInfo.addPayload(vol.getpayload()); | ||
| snapshotInfoListForRollback.add(snapshotInfo); | ||
| SnapshotStrategy snapshotStrategy = storageStrategyFactory.getSnapshotStrategy(snapshotInfo, SnapshotOperation.TAKE); |
There was a problem hiding this comment.
This change alters rollback semantics by adding the snapshot to the rollback list before strategy lookup and takeSnapshot(). Please add/extend a unit test to assert that when snapshot creation fails (e.g., getSnapshotStrategy() returns null or takeSnapshot() throws/returns null), the created snapshot is still included in the rollback list and rollback cleanup is triggered as expected.
Description
This PR fixes rollback disk snapshots on instance snapshot failure.
Fixes #12927
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?