Block backup deletion while create-VM-from-backup or restore jobs are in progress#12792
Block backup deletion while create-VM-from-backup or restore jobs are in progress#12792Damans227 wants to merge 5 commits intoapache:4.22from
Conversation
|
@blueorangutan package |
|
@Damans227 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12792 +/- ##
============================================
- Coverage 17.61% 17.61% -0.01%
Complexity 15664 15664
============================================
Files 5917 5917
Lines 531402 531426 +24
Branches 64971 64974 +3
============================================
+ Hits 93596 93599 +3
- Misses 427252 427271 +19
- Partials 10554 10556 +2
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 ✔️ debian ✖️ suse15. SL-JID 17097 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17104 |
There was a problem hiding this comment.
Pull request overview
This PR prevents VM backup deletion when there are in-progress async jobs that depend on the same backup (notably create-VM-from-backup and restore), avoiding failures caused by deleting a backup mid-operation.
Changes:
- Added a pending-async-job check to
BackupManagerImpl.deleteBackup()to block deletion when related jobs are in progress. - Added a unit test covering the “delete blocked by pending jobs” scenario.
- Updated existing test stubbing to include
backup.getUuid()where required by the new logic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java |
Adds checkForPendingBackupJobs and calls it from deleteBackup to prevent deletion while dependent jobs are in progress. |
server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java |
Introduces a new unit test ensuring deletion is blocked when countPendingJobs(...) reports pending work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Abhisar Sinha <63767682+abh1sar@users.noreply.github.com>
Description
Fixes: #11356
Adds a check in
deleteBackup()to block deletion when acreateVMFromBackuporrestoreBackupasync job is in progress for that backup.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
Screen.Recording.2026-03-12.at.10.00.41.AM.mp4
How Has This Been Tested?
createVMFromBackup, then attempteddeleteBackupon same backup, confirmed it now throwsCloudRuntimeExceptiontestDeleteBackupBlockedByPendingJobsHow did you try to break this feature and the system with this change?
deleteBackupstill succeeds when no pending jobs exist