Description of problem: Currently, vdsm-tool dump-volume-chains will throw an error related to duplicate parent in the chain in case there is a snapshot in preview. See this image below. The chain is: 00000000 <- e6c7bec0 <- e0475853 <- deceff83 [previously active] <- 5eb2b29d [preview] image: dff0a0c0-b731-4e5b-9f32-d97310ca40de Error: more than one volume pointing to the same parent volume e.g: (_BLANK_UUID<-a), (a<-b), (a<-c) Unordered volumes and children: - e6c7bec0-53c6-4729-a4a0-a9b3ef2b8c38 <- 5eb2b29d-82d6-4337-8511-3c86705d566e status: OK, voltype: LEAF, format: COW, legality: LEGAL, type: SPARSE, capacity: 1073741824, truesize: 1073741824 - e0475853-4514-4464-99e7-b185cce9b67d <- deceff83-9d88-4f87-8304-d5bf74d119b1 status: OK, voltype: LEAF, format: COW, legality: LEGAL, type: SPARSE, capacity: 1073741824, truesize: 1073741824 - e6c7bec0-53c6-4729-a4a0-a9b3ef2b8c38 <- e0475853-4514-4464-99e7-b185cce9b67d status: OK, voltype: INTERNAL, format: COW, legality: LEGAL, type: SPARSE, capacity: 1073741824, truesize: 1073741824 - 00000000-0000-0000-0000-000000000000 <- e6c7bec0-53c6-4729-a4a0-a9b3ef2b8c38 status: OK, voltype: INTERNAL, format: RAW, legality: LEGAL, type: PREALLOCATED, capacity: 1073741824, truesize: 1073741824 Version-Release number of selected component (if applicable): vdsm-4.40.24-1.gitd177ff577.el8.x86_64 How reproducible: 100% Steps to Reproduce: 1. Preview snapshot 2. Run dump-volume-chains 3. Actual results: dump-volume-chains gives incorrect error Expected results: dump-volume-chains able to reliably detect snapshot previews Additional info: * there is nothing in the Storage Domain metadata that explicitly tell a snapshot is in preview
I came up with this, but its overly complicated as the only way is to try to guess if the problematic chain is in preview or not. def _is_chain_in_preview(volumes_children, volumes_type): # a duplicate parent in chain could mean a snapshot in preview # a snapshot in preview has the following properties: # - chain contains 2 leaves in total # - exactly 2 volumes pointing to the same unique parent # - at least 1 volume pointing to the duplicate parent is leaf voltype_count = Counter(volumes_type.values()) if voltype_count['LEAF'] != 2: return False parent_count = Counter(map(itemgetter(0), volumes_children)) parent_count = dict(filter(lambda count: count[1] > 1, parent_count.items())) if sum(count for count in parent_count.values()) > 2: return False parent = next(iter(parent_count)) children = [child for volume, child in volumes_children if volume == parent] if all(volumes_type[volume] != 'LEAF' for volume in children): return False return True
After discussions on ovirt devel list we found there is no reliable way to determine if the chain has a snapshot in preview based only on storage metadata. All the changes required to make this happen are not worth it and maybe even risky. I'll suggest a patch to change the text of DuplicateParentError to warn the user it could be a preview.
Re-opening after more discussions :) On ovirt-devel list: [storage] how to find if a snapshot is in preview based on storage domain metadata only?
We are past 4.5.0 feature freeze, please re-target.