Bug 1468313

Summary: Creating a new Pool fails if 'Auto select target' check box is enabled and the created Pool is based on a Template with at least two disks from the same Data Domain
Product: [oVirt] ovirt-engine Reporter: Sharon Gratch <sgratch>
Component: BLL.VirtAssignee: Sharon Gratch <sgratch>
Status: CLOSED CURRENTRELEASE QA Contact: Nisim Simsolo <nsimsolo>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.2.0CC: bugs, lveyde, nsimsolo, tjelinek
Target Milestone: ovirt-4.1.5Flags: rule-engine: ovirt-4.1+
Target Release: 4.1.5.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-08-23 08:07:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sharon Gratch 2017-07-06 16:17:39 UTC
Description of problem:
Trying to create new Pool based on a Template with at least two disks from the same Data Domain (same Target) and checking the 'Auto select target' check box (in 'Resource Allocation' side tab), causes the whole pool creation to fail with the following error:
ERROR [org.ovirt.engine.core.bll.AddVmPoolCommand] (default task-61) [2cc7a883-e071-4198-98af-868344152e44] Error during ValidateFailure.: java.lang.IllegalStateException: Duplicate key StorageDomain


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

How reproducible:
100%

Steps to Reproduce:
1.Open a new Pool dialog
2.Select a Template with at least two disks from the same Data Domain (Target).
3. Go to 'Resource Allocation' side tab and check the 'Auto select target' check box.

Actual results:
The Pool creation fails.

Expected results:
Pool creation should succeed. 


Additional info:
This bug is because of invalid using of Java Streams in ImagesHandler (done as part of a re-factoring patch in 6/6/17):
stream().collect(Collectors.toMap(<non unique/distinct keys list>, values)) - it was assumed it will take the last key in the stream, but instead it fails the whole state with "Duplicate key" error.

Comment 1 Sharon Gratch 2017-07-06 16:18:37 UTC
I have a patch ready for master branch for fixing this bug

Comment 2 Tomas Jelinek 2017-07-12 06:38:43 UTC
patch seems to be trivial - targeting 4.1.6

Comment 3 Sharon Gratch 2017-07-16 10:34:49 UTC
Tomas, 
can we set Target Milestone to 4.1.5 (since a patch for master was merged already)?

Comment 4 Sharon Gratch 2017-07-19 12:04:20 UTC
This bug was caused due to a re-factoring patch - commit number: a6d29adf20b905.
Since this re-factoring patch was not back-ported to 4.1, the problem is not reproduced on 4.1.z and therefor this bug can me marked as MODIFIED without the need to back-port.
So changing status to MODIFIED.

Comment 5 rhev-integ 2017-07-28 12:16:10 UTC
INFO: Bug status wasn't changed from MODIFIED to ON_QA due to the following reason:

[No relevant external trackers attached]

For more info please contact: infra

Comment 6 Nisim Simsolo 2017-08-17 13:07:43 UTC
Verification builds:
ovirt-engine-4.1.5.2-0.1.el7
libvirt-client-3.2.0-14.el7_4.2.x86_64
vdsm-4.19.28-1.el7ev.x86_64
qemu-kvm-rhev-2.9.0-16.el7_4.3.x86_64
sanlock-3.5.0-1.el7.x86_64