Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1497763

Summary: cannot import vm from data domain - ERROR: duplicate key value violates unique constraint "pk_images"
Product: [oVirt] ovirt-engine Reporter: Jiri Belka <jbelka>
Component: BLL.StorageAssignee: Eyal Shenitzky <eshenitz>
Status: CLOSED CURRENTRELEASE QA Contact: Raz Tamir <ratamir>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 4.1.1.6CC: amureini, bugs, danken, eshenitz, jbelka, ratamir, tnisan
Target Milestone: ovirt-4.1.7Flags: rule-engine: ovirt-4.1+
Target Release: ---   
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-11-13 12:28:48 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 Jiri Belka 2017-10-02 15:36:52 UTC
Description of problem:

I'm importing a VM from a data domain which was attached to DC clus41 into another DC cl01 on same engine env.

2017-10-02 17:24:02,313+02 INFO  [org.ovirt.engine.core.utils.transaction.TransactionSupport] (org.ovirt.thread.pool-6-thread-40) [d1a23b37-32c4-4
628-8a60-5f48af493a2c] transaction rolled back
2017-10-02 17:24:02,314+02 ERROR [org.ovirt.engine.core.bll.exportimport.ImportVmFromConfigurationCommand] (org.ovirt.thread.pool-6-thread-40) [d1a23b37-32c4-4628-8a60-5f48af493a2c] 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)=(8ff47c61-1089-4d82-9319-72ad65928a91) 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
        )
...


Version-Release number of selected component (if applicable):
ovirt-engine-4.1.6.2-0.1.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1. have a vm with snapshots on DC A
2. move disk to a new data domain, stop vm
3. detach the data domain
4. attach the data domain to DC B on same engine
5. try to import the VM

Actual results:
import fails with sql error inside engine.log

Expected results:
should work

Additional info:
please take into account this env exists since 3.0 so it has its history and it has had many bugs in the past so there are some issues which cannot be easy reproduced on clean env

Comment 2 Eyal Shenitzky 2017-10-03 08:16:28 UTC
Did you take live/cold snapshots?
Are the snapshots contain memory?

Comment 3 Jiri Belka 2017-10-03 08:44:04 UTC
(In reply to Eyal Shenitzky from comment #2)
> Did you take live/cold snapshots?
> Are the snapshots contain memory?

live snapshots with memory.

Comment 4 Allon Mureinik 2017-10-03 12:33:55 UTC
Eyal, isn't this a dup of bug 1497518?

Comment 5 Eyal Shenitzky 2017-10-15 11:59:30 UTC
No, this is a different scenario.

Manage to reproduce with the following steps:

1. Have a VM with disk
2. Run the VM
3. Create live snapshot with memory
4. Move disk to a different data storage domain
5. Stop the VM
3. Detach the data domain
4. Attach the data domain back to the environment
5. try to import the VM

Comment 6 Allon Mureinik 2017-10-22 14:06:10 UTC
Eyal - the attached patch is merged. Are we waiting for other patches? If not, please backport it to 4.1.

Comment 7 Raz Tamir 2017-11-01 16:06:05 UTC
I can't execute step #5 as the list of unregistered VMs is empty

rhevm-4.1.7.5-0.1.el7

Comment 8 Tal Nisan 2017-11-02 13:06:54 UTC
Moving to 4.1.8 till we get a clear idea of what's the issue here

Comment 9 Eyal Shenitzky 2017-11-02 13:20:02 UTC
Raz I re-checked and it works for me, I will rephrase the steps to reproduce so it will be clearer:

1. Have a VM with disk on storage domain [A]
2. Run the VM
3. Create live snapshot with memory
4. Stop the VM
5. Move the VM's disk to a different data storage domain [B]
6. Detach the data storage domain [B] which contains the VM disk
7. Attach the data storage domain [B] back to the environment
8. try to import the VM

VM import should succeed.

Comment 10 Raz Tamir 2017-11-02 13:27:57 UTC
(In reply to Eyal Shenitzky from comment #9)
> Raz I re-checked and it works for me, I will rephrase the steps to reproduce
> so it will be clearer:
> 
> 1. Have a VM with disk on storage domain [A]
> 2. Run the VM
> 3. Create live snapshot with memory
> 4. Stop the VM
> 5. Move the VM's disk to a different data storage domain [B]
> 6. Detach the data storage domain [B] which contains the VM disk
> 7. Attach the data storage domain [B] back to the environment
> 8. try to import the VM
> 
> VM import should succeed.

Done exactly that but when attaching SD B, the list of unregistered VMs is empty.

Will check again and update

Comment 11 Raz Tamir 2017-11-02 13:59:15 UTC
Run the steps again and I see the same issue.

the list of VM to import is empty

Comment 12 Raz Tamir 2017-11-02 14:33:17 UTC
Maybe the issue is related to https://bugzilla.redhat.com/show_bug.cgi?id=1508908

Comment 13 Allon Mureinik 2017-11-05 12:41:41 UTC
(In reply to Raz Tamir from comment #12)
> Maybe the issue is related to
> https://bugzilla.redhat.com/show_bug.cgi?id=1508908

This is already ON_QA.
Please retest.

Comment 14 Raz Tamir 2017-11-05 13:44:12 UTC
Verified on rhevm-4.1.7.6-0.1.el7