Skip to content

kvm: delete primary-only RBD snapshots before the volume - #14132

Open
weizhouapache wants to merge 1 commit into
apache:4.22from
weizhouapache:4.22-remove-volume-snapshot-before-remove-rbd-volume
Open

kvm: delete primary-only RBD snapshots before the volume#14132
weizhouapache wants to merge 1 commit into
apache:4.22from
weizhouapache:4.22-remove-volume-snapshot-before-remove-rbd-volume

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes #12002

On Ceph/RBD primary storage, deleting a volume also destroys any of its remaining snapshots: LibvirtStorageAdaptor#deleteVol passes VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS for RBD pools, so libvirt unprotects and removes them along with the image.

Run that same snapshots cleanup earlier: for a KVM + RBD volume, delete its primary-only snapshots before sending the volume delete command, while they can still be found and removed cleanly. This is the choke point shared by both the standalone DeleteVolume API and VM destroy/expunge, so it covers both affected flows. The existing post-delete cleanup in deleteVolumeCallback stays in place as a no-op safety net for anything this pass didn't find.

Verified live on a KVM + Ceph environment (RBD primary storage, snapshot.backup.to.secondary=false): destroying a VM with a primary-only snapshot now deletes it cleanly.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.93%. Comparing base (9018034) to head (f720421).

Files with missing lines Patch % Lines
...e/cloudstack/storage/volume/VolumeServiceImpl.java 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14132   +/-   ##
=========================================
  Coverage     17.93%   17.93%           
- Complexity    16140    16149    +9     
=========================================
  Files          5928     5928           
  Lines        535174   535194   +20     
  Branches      65494    65497    +3     
=========================================
+ Hits          95968    96007   +39     
+ Misses       428280   428256   -24     
- Partials      10926    10931    +5     
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 19.00% <90.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Damans227

Copy link
Copy Markdown
Collaborator

@weizhouapache I see.. so your changes only run this for KVM + Ceph volumes, and it sits in the volume delete path instead of the storage cleanup loop. That fills the gap I had. Mine was running on every volume expunge no matter the storage type. I guess I will go ahead and close mine: #12813

Fixes apache#12002.

On Ceph/RBD primary storage, deleting a volume also destroys any of its
remaining snapshots: LibvirtStorageAdaptor#deleteVol passes
VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS for RBD pools, so libvirt
unprotects and removes them along with the image.

Run that same snapshots cleanup earlier: for a KVM + RBD volume, delete
its primary-only snapshots before sending the volume delete command,
while they can still be found and removed cleanly. This is the choke
point shared by both the standalone DeleteVolume API and VM
destroy/expunge, so it covers both affected flows. The existing
post-delete cleanup in deleteVolumeCallback stays in place as a no-op
safety net for anything this pass didn't find.

Verified live on a KVM + Ceph environment (RBD primary storage,
snapshot.backup.to.secondary=false): destroying a VM with a
primary-only snapshot now deletes it cleanly.
@weizhouapache
weizhouapache force-pushed the 4.22-remove-volume-snapshot-before-remove-rbd-volume branch from 19944a4 to f720421 Compare September 11, 2026 12:42
@weizhouapache
weizhouapache marked this pull request as ready for review September 11, 2026 12:42
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache 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.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19222

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16978)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 48513 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14132-t16978-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snapshot as Abnormal residue on rbd

3 participants