Bug 1071912

Summary: Remove VM in preview should be blocked in the CDA phase
Product: Red Hat Enterprise Virtualization Manager Reporter: Maor <mlipchuk>
Component: ovirt-engineAssignee: Maor <mlipchuk>
Status: CLOSED CURRENTRELEASE QA Contact: Aharon Canan <acanan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.5.0CC: amureini, ebenahar, gklein, iheim, lpeer, rbalakri, Rhev-m-bugs, scohen, tnisan, yeylon
Target Milestone: ---   
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: ovirt-engine-3.5.0_alpha1.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-16 19:08:30 UTC 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: 1142923, 1156165    
Attachments:
Description Flags
engine log none

Description Maor 2014-03-03 12:53:38 UTC
Created attachment 869922 [details]
engine log

Description of problem:
Removing a VM in Preview, might leave garbage in the DB and in the Storage
if the VM had disks on the active volume but not in the snapshot.

Version-Release number of selected component (if applicable):


How reproducible:
100#

Steps to Reproduce:
1. Create a VM with Disk
2. Create a Snapshot
3. Create another Disk
4. Preview the snapshot (Now the second disk should not be present in the VM)
5. Remove the VM

Actual results:
The VM was removed but there was still a redundant data in the DB in images table and also in the Storage

Expected results:
We should block the user to remove a VM if it is in preview mode.

Additional info:
Until now there was a validation only if the user sent force flag as true.
The validation only occured in the Rest but not in the GUI

Comment 1 Maor 2014-03-03 12:57:50 UTC
DB (VM in preview):

engine=# SELECT vm_id,snapshot_id FROM snapshots where vm_id = 'e0c4b270-e445-44ef-a180-c901ad3b0d73';
                vm_id                 |             snapshot_id              
--------------------------------------+--------------------------------------
 e0c4b270-e445-44ef-a180-c901ad3b0d73 | ac2c611c-260e-4eb3-98ca-afbb719d4353
 e0c4b270-e445-44ef-a180-c901ad3b0d73 | 6e856426-1ed8-4af5-961b-3593082a49e5
 e0c4b270-e445-44ef-a180-c901ad3b0d73 | 5df9bb57-c19e-4533-97eb-8cb84afed4a4
(3 rows)


engine=# SELECT image_guid,vm_snapshot_id, image_group_id,active FROM images where vm_snapshot_id in ('ac2c611c-260e-4eb3-98ca-afbb719d4353','6e856426-1ed8-4af5-961b-3593082a49e5','5df9bb57-c19e-4533-97eb-8cb84afed4a4');
              image_guid              |            vm_snapshot_id            |            image_group_id 
           | active 
--------------------------------------+--------------------------------------+---------------------------
-----------+--------
 82807ec6-8a65-4126-a585-3223e09e2a99 | 6e856426-1ed8-4af5-961b-3593082a49e5 | 1db3d731-f22b-4bbe-9191-00
44132d18e6 | f
 77475ba5-eeb9-48cc-b809-48a02ed7a671 | 5df9bb57-c19e-4533-97eb-8cb84afed4a4 | 1db3d731-f22b-4bbe-9191-00
44132d18e6 | t
 e2074648-c8db-497d-abc2-c9a6d41519ad | ac2c611c-260e-4eb3-98ca-afbb719d4353 | 1db3d731-f22b-4bbe-9191-00
44132d18e6 | f
 c56bf091-d0d1-47c2-ac63-baccdaa21254 | 6e856426-1ed8-4af5-961b-3593082a49e5 | 0f101d32-ccd9-4b1f-aa69-e7
c10c1c9da1 | t
(4 rows)








DB (VM after remove):

engine=# SELECT image_guid,vm_snapshot_id, image_group_id,active FROM images where vm_snapshot_id in ('ac2c611c-260e-4eb3-98ca-afbb719d4353','6e856426-1ed8-4af5-961b-3593082a49e5','5df9bb57-c19e-4533-97eb-8cb84afed4a4');
              image_guid              |            vm_snapshot_id            |            image_group_id 
           | active 
--------------------------------------+--------------------------------------+---------------------------
-----------+--------
 c56bf091-d0d1-47c2-ac63-baccdaa21254 | 6e856426-1ed8-4af5-961b-3593082a49e5 | 0f101d32-ccd9-4b1f-aa69-e7
c10c1c9da1 | t
(1 row)

engine=# SELECT vm_id,snapshot_id FROM snapshots where vm_id = 'e0c4b270-e445-44ef-a180-c901ad3b0d73'; vm_id | snapshot_id 
-------+-------------
(0 rows)

Comment 2 Elad 2014-05-28 09:19:57 UTC
Remove VM is now blocked in case the a snapshot of the VM is previewed.

2014-05-28 12:16:41,127 WARN  [org.ovirt.engine.core.bll.RemoveVmCommand] (ajp--127.0.0.1-8702-9) [11d42f46] CanDoAction of action RemoveVm failed. Reasons:VAR__ACTION__REMOVE,VAR__TYPE__VM,ACTION_TYPE_FAILED_VM_IN_PREVIEW


Verified using  ovirt-engine-3.5.0_alpha1.1:
ovirt-engine-3.5.0-0.0.master.20140519181229.gitc6324d4.el6.noarch

Against RHEV-3.4-AV9.2

Comment 3 Allon Mureinik 2015-02-16 19:08:30 UTC
RHEV-M 3.5.0 has been released, closing this bug.