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

Bug 1418758

Summary: [ovirt-ansible-modules] adding disk to VM as bootable fail when there is already disk with the same name
Product: [oVirt] ovirt-distribution Reporter: Petr Kubica <pkubica>
Component: GeneralAssignee: Ondra Machacek <omachace>
Status: CLOSED UPSTREAM QA Contact: Petr Kubica <pkubica>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, oourfali
Target Milestone: ---   
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-02-10 10:46:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1405975    
Attachments:
Description Flags
ansible playbook none

Description Petr Kubica 2017-02-02 16:26:15 UTC
Created attachment 1247153 [details]
ansible playbook

Description of problem:
adding disk to VM as bootable fail when there is already disk with the same name

There is unclear what should happen:

 - name: Create disk 1
     ovirt_disks:
       name: myvm_disk1
       vm_name: myvm
       size: 20GiB
       format: cow
       interface: virtio
       bootable: True
       storage_domain: s1
       auth: "{{ovirt_auth}}"

first case: 
- there isn't any disk of name myvm_disk1 in storage s1
- so create it and attach it to vm myvm

second case:
- in storage s1 is already disk myvm_disk1 (as template or as disk of another VM) but not a disk with that name which is attached to VM myvm
- so create a new disk and attach it to VM myvm?
!!OR!!
- try to add any? all? disk of that name to VM?

third case:
- in storage s1 is already disk myvm_disk1 (as template or as disk of another VM) and other disk with that name is attached to VM myvm
- so based on declarative models of ansible, it should check that disk with that name is already attached to VM myvm?
!!OR!!
- try to add any? all? disk of that name to VM which isn't attached to VM myvm?

- This case is described in attached playbook.yml - run twice

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

How reproducible:
always with provided playbook

Steps to Reproduce:
1. Run attached playbook twice

Actual results:
Failed with "msg": "Fault reason is \"Operation Failed\". Fault detail is \"[Cannot attach Virtual Disk. Disk myvm_disk1 in VM myvm is already marked as boot.]\". HTTP response code is 409."

Additional info:
Attached playbook will fail in second run, but it should pass with all ok

Comment 1 Petr Kubica 2017-02-02 16:41:04 UTC
Maybe in third case, there is missing a parametr "force" to force create another disk for that VM

Comment 2 Oved Ourfali 2017-02-03 07:37:44 UTC
Ansible is declarative, so I guess that it doesn't create the disk as it exists already, which is normal.

But, I'll let Ondra reply. 
Anyhow I don't see any high severity here.

Comment 3 Yaniv Kaul 2017-02-03 11:54:05 UTC
Why not open the bug upstream, btw?

Comment 4 Ondra Machacek 2017-02-03 18:12:33 UTC
I think we should implement force parameter. That's in my opinion all we can do,
as user must implement his playbook properly and work with IDs to reliably work
with disks.

Comment 5 Ondra Machacek 2017-02-10 10:46:09 UTC
As agreed please open this issue at github.