Bug 1014966

Summary: RHEVM Backend: error code 409 (Conflict: Cannot add Storage Connection. Storage connection already exists.) retuned when trying to add storage domain
Product: Red Hat Enterprise Virtualization Manager Reporter: Ilia Meerovich <iliam>
Component: ovirt-engineAssignee: Daniel Erez <derez>
Status: CLOSED CURRENTRELEASE QA Contact: Gadi Ickowicz <gickowic>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.3.0CC: acanan, acathrow, amureini, anil.dhingra, bazulay, derez, iheim, iliam, lpeer, mbourvin, mlipchuk, nlevinki, oramraz, Rhev-m-bugs, scohen, srevivo, yeylon
Target Milestone: ---Flags: amureini: Triaged+
Target Release: 3.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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:
Attachments:
Description Flags
Comment none

Description Ilia Meerovich 2013-10-03 08:48:59 UTC
import org.ovirt.engine.sdk.Api;
import org.ovirt.engine.sdk.decorators.Host;
import org.ovirt.engine.sdk.entities.PowerManagement;
import org.ovirt.engine.sdk.entities.Slaves;
import org.ovirt.engine.sdk.entities.Storage;
import org.ovirt.engine.sdk.entities.StorageDomain;


public class debugRemove {
        private static final String URL = "https://ilia-rhevm.qa.lab.tlv.redhat.com:443/api";

    public static void main(String[] args) throws Exception {
        Api api = new Api(URL, "admin@internal", "123456", true);
        StorageDomain st = new StorageDomain();
        st.setType("data");
        st.setHost((org.ovirt.engine.sdk.entities.Host) api.getHosts().list().get(0));
        Storage storage = new Storage();
        storage.setPath("/data/images2");
        storage.setType("localfs");
		st.setStorage(storage);
		api.getStorageDomains().add(st);
        api.close();
    }
}

causes to:
Exception in thread "main" 
code  : 409
reason: Conflict
detail: Cannot add Storage Connection. Storage connection already exists.
	at org.ovirt.engine.sdk.web.HttpProxy.execute(HttpProxy.java:118)
	at org.ovirt.engine.sdk.web.HttpProxyBroker.add(HttpProxyBroker.java:209)
	at org.ovirt.engine.sdk.decorators.StorageDomains.add(StorageDomains.java:230)
	at debugRemove.main(debugRemove.java:21)

Comment 1 Michael Pasternak 2013-10-03 09:08:34 UTC
(In reply to Ilia Meerovich from comment #0)
> import org.ovirt.engine.sdk.Api;
> import org.ovirt.engine.sdk.decorators.Host;
> import org.ovirt.engine.sdk.entities.PowerManagement;
> import org.ovirt.engine.sdk.entities.Slaves;
> import org.ovirt.engine.sdk.entities.Storage;
> import org.ovirt.engine.sdk.entities.StorageDomain;
> 
> 
> public class debugRemove {
>         private static final String URL =
> "https://ilia-rhevm.qa.lab.tlv.redhat.com:443/api";
> 
>     public static void main(String[] args) throws Exception {
>         Api api = new Api(URL, "admin@internal", "123456", true);
>         StorageDomain st = new StorageDomain();
>         st.setType("data");
>         st.setHost((org.ovirt.engine.sdk.entities.Host)
> api.getHosts().list().get(0));
>         Storage storage = new Storage();
>         storage.setPath("/data/images2");
>         storage.setType("localfs");
> 		st.setStorage(storage);
> 		api.getStorageDomains().add(st);
>         api.close();
>     }
> }
> 
> causes to:
> Exception in thread "main" 
> code  : 409
> reason: Conflict
> detail: Cannot add Storage Connection. Storage connection already exists.
> 	at org.ovirt.engine.sdk.web.HttpProxy.execute(HttpProxy.java:118)
> 	at org.ovirt.engine.sdk.web.HttpProxyBroker.add(HttpProxyBroker.java:209)
> 	at
> org.ovirt.engine.sdk.decorators.StorageDomains.add(StorageDomains.java:230)
> 	at debugRemove.main(debugRemove.java:21)

ilia,

can you reproduce this using native api?

Comment 2 anil 2013-10-06 07:54:13 UTC
I am also getting the same error while adding iso domain 
"Cannot add Storage Connection. Storage connection already exists."

Comment 3 Maor 2013-10-07 11:13:03 UTC
anil, can u please also query the DB, and add the output of the following query:
SELECT id,connection,iqn,port,portal,storage_type,mount_options,vfs_type FROM storage_server_connections;

Comment 4 Ilia Meerovich 2013-10-08 11:14:51 UTC
Created attachment 915776 [details]
Comment

(This comment was longer than 65,535 characters and has been moved to an attachment by Red Hat Bugzilla).

Comment 5 Daniel Erez 2013-10-09 07:42:45 UTC
Hi Ilia,

You may hit bug 991470 which has been closed; the proposed alternative is to reuse the storage connection. The means to do it was introduced as part of edit connections feature [1].

* Can you please verify that the proposed solution [1] resolves the issue?
* Have you encountered the described issue after invoking any operation through the rest-api (creating the domain/etc.)?

[1]
http://www.ovirt.org/Features/Manage_Storage_Connections#Add_new_file_.28nfs.2Fposix.2Flocal.29_storage_domain_with_existing_storage_connection_.28POST.29

Comment 6 Michael Pasternak 2013-10-09 09:36:53 UTC
Hi Daniel,

If this workaround breaks/change the flow was used before storage-connections feature/3.3, - it's unacceptable ...

(In reply to Daniel Erez from comment #5)
> Hi Ilia,
> 
> You may hit bug 991470 which has been closed; the proposed alternative is to
> reuse the storage connection. The means to do it was introduced as part of
> edit connections feature [1].
> 
> * Can you please verify that the proposed solution [1] resolves the issue?
> * Have you encountered the described issue after invoking any operation
> through the rest-api (creating the domain/etc.)?
> 
> [1]
> http://www.ovirt.org/Features/Manage_Storage_Connections#Add_new_file_.28nfs.
> 2Fposix.2Flocal.29_storage_domain_with_existing_storage_connection_.28POST.29

Comment 7 Daniel Erez 2013-10-09 11:18:56 UTC
(In reply to Michael Pasternak from comment #6)
> Hi Daniel,
> 
> If this workaround breaks/change the flow was used before
> storage-connections feature/3.3, - it's unacceptable ...

afaik, the workaround has been introduced instead of a fallback logic in the rest-api: http://gerrit.ovirt.org/#/c/17658/

> 
> (In reply to Daniel Erez from comment #5)
> > Hi Ilia,
> > 
> > You may hit bug 991470 which has been closed; the proposed alternative is to
> > reuse the storage connection. The means to do it was introduced as part of
> > edit connections feature [1].
> > 
> > * Can you please verify that the proposed solution [1] resolves the issue?
> > * Have you encountered the described issue after invoking any operation
> > through the rest-api (creating the domain/etc.)?
> > 
> > [1]
> > http://www.ovirt.org/Features/Manage_Storage_Connections#Add_new_file_.28nfs.
> > 2Fposix.2Flocal.29_storage_domain_with_existing_storage_connection_.28POST.29

Comment 8 Michael Pasternak 2013-10-09 11:41:52 UTC
(In reply to Daniel Erez from comment #7)
> (In reply to Michael Pasternak from comment #6)
> > Hi Daniel,
> > 
> > If this workaround breaks/change the flow was used before
> > storage-connections feature/3.3, - it's unacceptable ...
> 
> afaik, the workaround has been introduced instead of a fallback logic in the
> rest-api: http://gerrit.ovirt.org/#/c/17658/
> 

this patch was "abandoned", also i'm not sure it related to the mention issue.

Comment 9 Ilia Meerovich 2013-10-09 12:30:02 UTC
Daniel,

I cannot use this workaround since ART backend is just providing needed api to tests so it is doing what tests are telling to it to do.
I just wrote simple programm in java sdk in order to reproduce this issue easily.
Actually it can be reproduced also via UI so customer may/will face this issue.

Comment 10 Daniel Erez 2013-10-09 12:44:01 UTC
(In reply to Ilia Meerovich from comment #9)
> Daniel,
> 
> I cannot use this workaround since ART backend is just providing needed api
> to tests so it is doing what tests are telling to it to do.
> I just wrote simple programm in java sdk in order to reproduce this issue
> easily.
> Actually it can be reproduced also via UI so customer may/will face this
> issue.

* Can you please provide reproduce steps for the issue solely through the UI?
(I need to know this for determining whether this issue is related to bug 991470)

* Can you please attach the relevant logs and preferably DB dump as well?

Comment 13 Ayal Baron 2013-10-09 16:41:43 UTC
This is a dup of bug 991470 which was closed.
Keeping this to track the future fix.

Comment 15 Allon Mureinik 2014-04-23 13:00:23 UTC
This was solved as part of bug 991470, please verify.

Comment 16 Gadi Ickowicz 2014-04-27 13:49:20 UTC
verified using the same steps described in bug 994170 (comment 14) on av7:

POST:
<storage_domain>
    <name>data1 bla</name>
    <type>data</type>
    <host id="66864669-9940-4482-8232-a83a8d01a77e"/>
    <storage>
        <type>nfs</type>
        <address>10.35.160.108</address>
        <path>/RHEV/gickowic/nfs2</path>
    </storage>
</storage_domain>
response:
<fault>
<reason>Operation Failed</reason>
<detail>
[Storage Domain name must be formed of "a-z0-9A-Z" or "-_"]
</detail>
</fault>

POST:
<storage_domain>
    <name>data1_bla</name>
    <type>data</type>
    <host id="66864669-9940-4482-8232-a83a8d01a77e"/>
    <storage>
        <type>nfs</type>
        <address>10.35.160.108</address>
        <path>/RHEV/gickowic/nfs2</path>
    </storage>
</storage_domain>

Response:
    Status Code: 201 Created
    Connection: close
    Content-Encoding: gzip
    Content-Length: 384
    Content-Type: application/xml
    Date: Sun, 27 Apr 2014 13:45:54 GMT
    Location: https://gadi-rhevm.scl.lab.tlv.redhat.com/api/api/storagedomains/c291c3ba-187d-428c-833b-e0463dbff95a
    Vary: Accept-Encoding

Comment 17 Itamar Heim 2014-06-12 14:08:28 UTC
Closing as part of 3.4.0