Bug 1265133 - [Per host CHAP] Updating CHAP credentials via storageconnectionextensions with a target that already exist in the DB fails with 'Internal Engine Error'
[Per host CHAP] Updating CHAP credentials via storageconnectionextensions wit...
Status: CLOSED CURRENTRELEASE
Product: ovirt-engine
Classification: oVirt
Component: Backend.Core (Show other bugs)
3.6.0
x86_64 Unspecified
unspecified Severity medium (vote)
: ovirt-3.6.1
: 3.6.1
Assigned To: Tal Nisan
Elad
storage
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-22 04:08 EDT by Elad
Modified: 2016-02-10 12:25 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-16 07:17:34 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Storage
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
amureini: ovirt‑3.6.z?
rule-engine: planning_ack?
amureini: devel_ack+
rule-engine: testing_ack+


Attachments (Terms of Use)
logs from engine (223.32 KB, application/x-gzip)
2015-09-22 04:08 EDT, Elad
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 46814 master MERGED core: Validate inexistance of connection extension upon update Never
oVirt gerrit 46816 master MERGED core: Add tests for storage server connection extension Never
oVirt gerrit 47174 ovirt-engine-3.6 MERGED core: Validate inexistance of connection extension upon update Never
oVirt gerrit 47175 ovirt-engine-3.6 MERGED core: Add tests for storage server connection extension Never

  None (edit)
Description Elad 2015-09-22 04:08:30 EDT
Created attachment 1075691 [details]
logs from engine

Description of problem:
Updating an existing per host storage connection via storageconnectionextensions with a target that exist in the DB under another per host storage connection for the same host fails with 'Internal Engine Error'


Version-Release number of selected component (if applicable):
rhevm-3.6.0-0.16.master.el6.noarch
rhevm-restapi-3.6.0-0.16.master.el6.noarch

How reproducible:
Always

Steps to Reproduce:
1. Add a storage connection per host via REST API. For example:
Under:
https://engine-add/api/hosts/%host_id%/storageconnectionextensions 

POST (Content-Type: application/xml):

<storage_connection_extension>
    <target>iqn1.leon.com</target>
    <username>bla</username>
    <password>bla</password>
</storage_connection_extension>


2. Add another storage connection per host for the same host with another target:

Under:
https://engine-add/api/hosts/%host_id%/storageconnectionextensions 

POST (Content-Type: application/xml):

<storage_connection_extension>
    <target>iqn2.leon.com</target>
    <username>bla</username>
    <password>bla</password>
</storage_connection_extension>

3. Update one of the connections with the same target as written in the other connection

Actual results:

<fault>
<reason>Operation Failed</reason>
<detail>[Internal Engine Error]</detail>
</fault>



2015-09-22 07:25:37,566 INFO  [org.ovirt.engine.core.bll.storage.UpdateStorageServerConnectionExtensionCommand] (ajp-/127.0.0.1:8702-3) [7f0e82c1] Running command: UpdateStorageServerCon
nectionExtensionCommand internal: false. Entities affected :  ID: aaa00000-0000-0000-0000-123456789aaa Type: SystemAction group CREATE_STORAGE_DOMAIN with role type ADMIN
2015-09-22 07:25:37,588 ERROR [org.ovirt.engine.core.bll.storage.UpdateStorageServerConnectionExtensionCommand] (ajp-/127.0.0.1:8702-3) [7f0e82c1] Command 'org.ovirt.engine.core.bll.stor
age.UpdateStorageServerConnectionExtensionCommand' failed: CallableStatementCallback; SQL [{call updatestorageserverconnectionextension(?, ?, ?, ?, ?)}]; ERROR: duplicate key value viola
tes unique constraint "storage_server_connection_extension_vds_id_iqn"
  Where: SQL statement "UPDATE storage_server_connection_extension SET vds_id =  $1 , iqn =  $2 , user_name =  $3 , password =  $4  WHERE id =  $5 "
PL/pgSQL function "updatestorageserverconnectionextension" line 2 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique cons
traint "storage_server_connection_extension_vds_id_iqn"
  Where: SQL statement "UPDATE storage_server_connection_extension SET vds_id =  $1 , iqn =  $2 , user_name =  $3 , password =  $4  WHERE id =  $5 "
PL/pgSQL function "updatestorageserverconnectionextension" line 2 at SQL statement
2015-09-22 07:25:37,588 ERROR [org.ovirt.engine.core.bll.storage.UpdateStorageServerConnectionExtensionCommand] (ajp-/127.0.0.1:8702-3) [7f0e82c1] Exception: org.springframework.dao.Dupl
icateKeyException: CallableStatementCallback; SQL [{call updatestorageserverconnectionextension(?, ?, ?, ?, ?)}]; ERROR: duplicate key value violates unique constraint "storage_server_co
nnection_extension_vds_id_iqn"
  Where: SQL statement "UPDATE storage_server_connection_extension SET vds_id =  $1 , iqn =  $2 , user_name =  $3 , password =  $4  WHERE id =  $5 "
PL/pgSQL function "updatestorageserverconnectionextension" line 2 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique cons
traint "storage_server_connection_extension_vds_id_iqn"
  Where: SQL statement "UPDATE storage_server_connection_extension SET vds_id =  $1 , iqn =  $2 , user_name =  $3 , password =  $4  WHERE id =  $5 "
PL/pgSQL function "updatestorageserverconnectionextension" line 2 at SQL statement
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:241) [spring-jdbc.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) [spring-jdbc.jar:3.1.1.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1030) [spring-jdbc.jar:3.1.1.RELEASE]


Expected results:
The operation should fail nicely

Additional info:
logs from engine
Comment 1 Allon Mureinik 2015-09-22 06:01:33 EDT
A connection extension is identified by the combination of host and iqn. Updating either of them doesn't make sense, and should be blocked by a CDA (regardless of whether there's already such a definition or not).
Comment 2 Yaniv Lavi 2015-10-29 08:35:42 EDT
In oVirt testing is done on single release by default. Therefore I'm removing the 4.0 flag. If you think this bug must be tested in 4.0 as well, please re-add the flag. Please note we might not have testing resources to handle the 4.0 clone.
Comment 3 Elad 2015-12-02 05:00:12 EST
Updating an existing storage connection under storageconnectionextensions, with a target name which already exists under another connection is blocked on CDA with a correct message:


Body:

<storage_connection_extension>
    <target>iqn.2008-05.com.xtremio:xio00153500071-514f0c50023f6c01</target>
    <username>elad</username>
    <password>123123123123</password>
</storage_connection_extension>


Response:

<fault>
<reason>Operation Failed</reason>
<detail>
[Cannot edit Storage Connection Extension. Connection extension already exists for the host green-vdsb and the target iqn.2008-05.com.xtremio:xio00153500071-514f0c50023f6c01.]
</detail>
</fault>



Engine.log:

2015-12-02 09:57:01,959 WARN  [org.ovirt.engine.core.bll.storage.UpdateStorageServerConnectionExtensionCommand] (ajp-/127.0.0.1:8702-12) [700dd14f] CanDoAction of action 'UpdateStorageServerConnectionExtension' failed for user admin@internal. Reasons: VAR__TYPE__STORAGE__CONNECTION__EXTENSION,VAR__ACTION__UPDATE,ACTION_TYPE_FAILED_STORAGE_CONNECTION_EXTENSION_ALREADY_EXISTS,$target iqn.2008-05.com.xtremio:xio00153500071-514f0c50023f6c01,$vdsName green-vdsb
Comment 4 Elad 2015-12-02 05:02:09 EST
Following comment #3, verified using:
rhevm-3.6.1-0.2.el6.noarch
rhevm-restapi-3.6.1-0.2.el6.noarch
Comment 5 Sandro Bonazzola 2015-12-16 07:17:34 EST
According to verification status and target milestone this issue should be fixed in oVirt 3.6.1. Closing current release.

Note You need to log in before you can comment on or make changes to this bug.