Bug 1015170

Summary: [engine] Unable to remove snapshot after detaching disk from vm
Product: Red Hat Enterprise Virtualization Manager Reporter: Gadi Ickowicz <gickowic>
Component: ovirt-engineAssignee: Daniel Erez <derez>
Status: CLOSED CURRENTRELEASE QA Contact: Elad <ebenahar>
Severity: high Docs Contact:
Priority: high    
Version: 3.3.0CC: abaron, acathrow, amureini, derez, ebenahar, iheim, lpeer, nlevinki, Rhev-m-bugs, scohen, srevivo, yeylon
Target Milestone: ---Flags: amureini: Triaged+
Target Release: 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: is19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1026487    
Attachments:
Description Flags
engine logs none

Description Gadi Ickowicz 2013-10-03 14:43:32 UTC
Created attachment 807111 [details]
engine logs

Description of problem:
After detaching the bootable disk from a vm and then creating a new one, the first snapshot that is created cannot be removed as it fails with CanDoAction Failure:

2013-10-03 17:38:48,435 INFO  [org.ovirt.engine.core.bll.RemoveSnapshotCommand] (ajp-/127.0.0.1:8702-4) Lock Acquired to object EngineLock [exclusiveLocks= key: c7c37f0b-e884-4737-accc-8960a4ebfa15 value: VM
, sharedLocks= ]
2013-10-03 17:38:48,466 WARN  [org.ovirt.engine.core.bll.RemoveSnapshotCommand] (ajp-/127.0.0.1:8702-4) CanDoAction of action RemoveSnapshot failed. Reasons:VAR__TYPE__SNAPSHOT,VAR__ACTION__REMOVE,ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_IMAGE
2013-10-03 17:38:48,466 INFO  [org.ovirt.engine.core.bll.RemoveSnapshotCommand] (ajp-/127.0.0.1:8702-4) Lock freed to object EngineLock [exclusiveLocks= key: c7c37f0b-e884-4737-accc-8960a4ebfa15 value: VM
, sharedLocks= ]


Version-Release number of selected component (if applicable):
rhevm-3.3.0-0.24.master.el6ev.noarch

How reproducible:
100%

Steps to Reproduce:
1. Create vm with thin provision disk
2. Deactivate and detach disk (Remove but not permanently remove)
3. Add new disk to vm
4. Create snapshot of vm
5. Remove snapshot

Actual results:
Remove snapshot fails

Expected results:
Snapshot should be removed

Additional info:
Snapshot does not appear to be active in the DB, trying to remove snapshot 'snapshot' according to webadmin portal:


bash-4.1$ psql -d engine -c "select * from snapshots;"
             snapshot_id              |                vm_id                 | snapshot_type | status | description |       creation_date        | app_list |                                                        
--------------------------------------+--------------------------------------+---------------+--------+-------------+----------------------------+----------+--------------------------------------------------------
 b8861c23-c1cc-4a5a-9979-f8e994bbb886 | c7c37f0b-e884-4737-accc-8960a4ebfa15 | ACTIVE        | OK     | Active VM   | 2013-10-03 17:33:20.017+03 |          |                                                        
 f506babf-4a1f-4340-831b-2531572e47ce | c7c37f0b-e884-4737-accc-8960a4ebfa15 | REGULAR       | OK     | snapshot    | 2013-10-03 17:38:13.586+03 |          | <?xml version='1.0' encoding='UTF-8'?><ovf:Envelope xml
(2 rows)

Comment 1 Daniel Erez 2013-10-06 14:23:33 UTC
The issue relies in the manner we verify that the image is not active (in RemoveSnapshotCommand). The method is based on fetching all images by snapshot ID, however, as the snapshot ID isn't cleared when detaching a disk; also floating disk images may be examined. Since floating disk images aren't relevant with regards to snapshots, they shouldn't be taken into account. Therefore, the suggested solution covers the underlying problem, i.e. clearing snapshot ID when detaching a disk.

Comment 2 Ayal Baron 2013-10-08 08:21:22 UTC
Looking at the 2 patches, shouldn't we also have an upgrade script that removes snapshot_id from floating disks?

Comment 3 Elad 2013-10-27 14:34:21 UTC
Snapshot removal finishes successfully after detaching vm's bootable disk.
Checked according to steps.

Verified on is20:
rhevm-3.3.0-0.28.beta1.el6ev.noarch
vdsm-4.13.0-0.5.beta1.el6ev.x86_64

Comment 4 Itamar Heim 2014-01-21 22:21:23 UTC
Closing - RHEV 3.3 Released

Comment 5 Itamar Heim 2014-01-21 22:26:46 UTC
Closing - RHEV 3.3 Released