Repository navigation
kvm: treat an RBD snapshot whose image is gone as deleted - #14932
bhouse-nexthop wants to merge 1 commit into
Conversation
Deleting a volume on RBD removes its snapshots with the image. When snapshots are kept only on primary storage, the management server then deletes each of the volume's snapshots, and the agent looked up the image through KVMStoragePoolManager.getPhysicalDisk, which retries a missing volume 100 times, 3 seconds apart. After about 5 minutes the delete failed, so the volume delete took 5 minutes and its snapshots stayed listed as BackedUp: they could not be used, and every later deleteSnapshot failed the same way. Look the snapshot's image up once. If librbd reports it as not found, the snapshot is gone with it and the delete succeeds. Fixes apache#14931 Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14932 +/- ##
=========================================
Coverage 18.34% 18.34%
- Complexity 16670 16672 +2
=========================================
Files 5939 5939
Lines 537814 537827 +13
Branches 65937 65940 +3
=========================================
+ Hits 98637 98661 +24
+ Misses 427953 427942 -11
Partials 11224 11224
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:
|
|
Tested on a nested lab: one management server, three KVM hosts, Ceph RBD primary storage, Control on the build without the change: a data volume with one RBD-only snapshot, detached, then With the change installed on all three agents:
In every case Ceph was left with no RBD snapshots beyond the baseline and nothing was written to secondary storage. The agent logs show the new path taken once per gone-image delete: Not tested: the 4.22 build itself on the lab (the unit tests pass on 4.22), and pools other than RBD, which this change does not touch. |
Description
On KVM with Ceph RBD and
snapshot.backup.to.secondary=false, deleting a volume that has snapshots takes about 5 minutes, and the snapshots stay listed asBackedUpafterwards. They can't be used, and everydeleteSnapshoton them fails after another 5 minutes with "Failed to delete snapshot chain". Expunging a VM goes through the same path for its ROOT volume.Deleting the volume removes its RBD snapshots together with the image. The management server then deletes each primary-only snapshot of the volume, and the agent's
KVMStorageProcessor.deleteSnapshotlooked the image up throughKVMStoragePoolManager.getPhysicalDisk. That call retries a missing volume 100 times, 3 seconds apart, to wait for volumes created on another host. The image never comes back, so the delete fails, anddeleteVolumeCallbackignores the failure without marking the snapshots destroyed.The agent now looks the snapshot's own image (the middle part of its
<pool>/<image>/<snapshot>path) up once before anything else. If librbd reports the image as not found, the snapshot went with it and the delete succeeds at once. Any other error, including librados reporting the pool as missing, falls through to the existing path unchanged. Snapshots already left behind this way become deletable with a plaindeleteSnapshotonce the agents run this code.Fixes: #14931
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests in
KVMStorageProcessorTest: the image lookup reports gone only for anRbdExceptionwith ENOENT in the cause chain (not for other RBD errors, and not for a librados ENOENT, which means the pool is missing);deleteSnapshotanswers success without the retrying lookup when the image is gone, and takes the existing path when it is not. 45 passed (of 45). With the early return disabled, the gone-image test fails.A lab test on a nested KVM + Ceph setup will follow in a comment.
How did you try to break this feature and the system with this change?