Bug 1434917

Summary: Import of a VM with memory snapshot from storage domain fails
Product: [oVirt] ovirt-engine Reporter: Tal Nisan <tnisan>
Component: BLL.StorageAssignee: Tal Nisan <tnisan>
Status: CLOSED CURRENTRELEASE QA Contact: Kevin Alon Goldblatt <kgoldbla>
Severity: high Docs Contact:
Priority: urgent    
Version: 4.1.1.3CC: bugs, csiga, lveyde, ylavi
Target Milestone: ovirt-4.1.2Flags: rule-engine: ovirt-4.1+
ylavi: testing_plan_complete?
Target Release: 4.1.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-23 08:12:33 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:

Description Tal Nisan 2017-03-22 15:14:09 UTC
Description of problem:
When removing a storage domain containing a VM with memory snapshot and trying to import it back to the same setup the operation fails with unique constraint violation

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


How reproducible:
100%

Steps to Reproduce:
1. Create a VM and take a snapshot with memory
2. Detach the storage domain containing the VM disks and memory
3. Attach the storage domain to a data center
4. Import the VM

Actual results:
Operation fails

Expected results:
Operation should succeed

Additional info:
This occurs since the memory dump disk and the memory metadata disk are not deleted from the database on the detachment and when trying to import the VM the import command is trying to create new entry with the same identifier:

2017-03-22 16:03:38,576+02 ERROR [org.ovirt.engine.core.bll.exportimport.ImportVmFromConfigurationCommand] (org.ovirt.thread.pool-6-thread-6) [b8b971cf-bb56-48d0-a97c-f418a9a06908] Command 'org.ovirt.engine.core.bll.exportimport.ImportVmFromConfigurationCommand' failed: CallableStatementCallback; SQL [{call insertimage(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates unique constraint "pk_images"
  Detail: Key (image_guid)=(58b55584-a190-44fc-8903-1ee2c48783bd) already exists.
  Where: SQL statement "INSERT INTO images (
        creation_date,
        image_guid,
        it_guid,
        size,
        ParentId,
        imageStatus,
        lastModified,
        vm_snapshot_id,
        volume_type,
        image_group_id,
        volume_format,
        active,
        volume_classification
        )
    VALUES (
        v_creation_date,
        v_image_guid,
        v_it_guid,
        v_size,
        v_ParentId,
        v_imageStatus,
        v_lastModified,
        v_vm_snapshot_id,
        v_volume_type,
        v_image_group_id,
        v_volume_format,
        v_active,
        v_volume_classification
        )"

Comment 1 Tal Nisan 2017-04-02 08:55:39 UTC
*** Bug 1437516 has been marked as a duplicate of this bug. ***

Comment 2 Kevin Alon Goldblatt 2017-04-27 14:00:20 UTC
Verified with the following code:
---------------------------------------
ovirt-engine-4.1.2-0.1.el7.noarch
rhevm-4.1.2-0.1.el7.noarch
vdsm-4.19.11-1.el7ev.x86_64


Verified with the following scenario:
---------------------------------------
Steps to Reproduce:
1. Create a VM and take a snapshot with memory
2. Detach the storage domain containing the VM disks and memory
3. Attach the storage domain to a data center
4. Import the VM ->>> works fine



Moving to VERIFIED!