Bug 1265133

Summary: [Per host CHAP] Updating CHAP credentials via storageconnectionextensions with a target that already exist in the DB fails with 'Internal Engine Error'
Product: [oVirt] ovirt-engine Reporter: Elad <ebenahar>
Component: Backend.CoreAssignee: Tal Nisan <tnisan>
Status: CLOSED CURRENTRELEASE QA Contact: Elad <ebenahar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.6.0CC: amureini, bugs
Target Milestone: ovirt-3.6.1Flags: amureini: ovirt-3.6.z?
rule-engine: planning_ack?
amureini: devel_ack+
rule-engine: testing_ack+
Target Release: 3.6.1   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-16 12:17:34 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:
Attachments:
Description Flags
logs from engine none

Description Elad 2015-09-22 08:08:30 UTC
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 10:01:33 UTC
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 12:35:42 UTC
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 10:00:12 UTC
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 10:02:09 UTC
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 12:17:34 UTC
According to verification status and target milestone this issue should be fixed in oVirt 3.6.1. Closing current release.