Bug 1400519

Summary: Detaching the storage connection from a domain on maintenance throws a Internal Server Error (but succeeds)
Product: [oVirt] ovirt-engine Reporter: Carlos Mestre González <cmestreg>
Component: BLL.StorageAssignee: Daniel Erez <derez>
Status: CLOSED NOTABUG QA Contact: Raz Tamir <ratamir>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.0.6CC: bugs, cmestreg, derez, gklein
Target Milestone: ovirt-4.1.0-rcKeywords: Automation, Regression
Target Release: ---Flags: rule-engine: ovirt-4.1+
rule-engine: blocker+
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: 2016-12-28 11:17:17 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:
Attachments:
Description Flags
engine.log none

Description Carlos Mestre González 2016-12-01 12:24:02 UTC
Created attachment 1226809 [details]
engine.log

Description of problem:
Trying to detach the storage connection of a domain in maintenance that is shared with other domain succeeds but throws a Internal Server Error response.

Version-Release number of selected component (if applicable):
rhevm-4.0.6-0.1.el7ev.noarch

How reproducible:
100%

Steps to Reproduce:
1. Create a DC, Cluster add a Host
2. Add a NFS domain as master
3. Create two iscsi domains, iscsi_0 and iscsi_1 that share the same storage connection
5. Put the iscsi_0 in maintenance
6. Try to detach the connection from iscsi_0:

DELETE  /ovirt-engine/api/storagedomains/4463f228-a199-4940-82cb-0ca0aa2b7db8/storageconnections/c3ed9176-d2fe-43c4-b431-b3d28739ba76


Actual results:
Operation succeeds (connection isdetached) but the response is a 500
2016-12-01 12:09:28,440 - MainThread - core_api - DEBUG - Request DELETE response time: 0.370
2016-12-01 12:09:28,441 - MainThread - storagedomains - DEBUG - Cleaning Correlation-Id: stora
gedomains_delete_a0142669-6a8b-4356
2016-12-01 12:09:28,443 - MainThread - storagedomains - ERROR - Details was not found on body
2016-12-01 12:09:28,443 - MainThread - api_utils - ERROR - Failed to delete element NOT as expected:
        Status: 500
        Reason: Internal Server Error


Expected results:
There's a response body.


Additional info:

Comment 1 Red Hat Bugzilla Rules Engine 2016-12-27 16:39:47 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 2 Daniel Erez 2016-12-28 08:23:29 UTC
Hi Carlos,

Detaching a storage domain is done by sending DELETE on the domain.
E.g. DELETE /api/datacenters/123/storagedomains/456

Deleting a shared storage server connection should indeed fail as mentioned in the description.

What's blocking the automation tests?

Comment 3 Carlos Mestre González 2016-12-28 10:59:01 UTC
Nothing is blocking our tests (was it mark as automation blocker?)

AFA I se in our test plans when you put in maintenance the iscsi_0, and THEN detach the storage CONNECTION from that domain with:

DELETE  /ovirt-engine/api/storagedomains/4463f228-a199-4940-82cb-0ca0aa2b7db8/storageconnections/c3ed9176-d2fe-43c4-b431-b3d28739ba76

it should work (and it does in our tests), but it throws a 500 Internal Server Error.

So either:

1) Operation should fail and it should be changed, also the response body should not return "Internal Server Error" but a proper message why the operation failed/is not allowed.
2) Operation should succeed and return code should change to 200.

Comment 4 Daniel Erez 2016-12-28 11:17:17 UTC
(In reply to Carlos Mestre González from comment #3)
> Nothing is blocking our tests (was it mark as automation blocker?)
> 
> AFA I se in our test plans when you put in maintenance the iscsi_0, and THEN
> detach the storage CONNECTION from that domain with:
> 
> DELETE 
> /ovirt-engine/api/storagedomains/4463f228-a199-4940-82cb-0ca0aa2b7db8/
> storageconnections/c3ed9176-d2fe-43c4-b431-b3d28739ba76
> 
> it should work (and it does in our tests), but it throws a 500 Internal
> Server Error.
> 
> So either:
> 
> 1) Operation should fail and it should be changed, also the response body
> should not return "Internal Server Error" but a proper message why the
> operation failed/is not allowed.
> 2) Operation should succeed and return code should change to 200.

In order to detach a domain you should DELETE the storage domain. DELETE on a connection should be used only when cleanup is needed and the connection is not used by any other storage domain (or DirectLUN disk). The tests plans should be changed accordingly.

Comment 5 Carlos Mestre González 2017-01-09 13:37:55 UTC
Hi Daniel,
So I'm still a bit confused, I'm not trying to detach a domain, I'm trying to remove the storage connection from that domain while is in maintenance, this scenario:

1) Two storage domains with the same storage connectaion (iscsi_0 and iscsi_1)
2) Put iscsi_0 on maintenance
3) Try to detach that STORAGE CONNECTION (not domain) from the domain iscsi_0 [So maybe it can be attached to other storage connectin later)
DELETE  /ovirt-engine/api/storagedomains/4463f228-a199-4940-82cb-0ca0aa2b7db8/storageconnections/c3ed9176-d2fe-43c4-b431-b3d28739ba76


does this scenario makes sence?

1) if it does, in the test fails and should be fixed.

2) if it doesn't, then still the engine returns:

	Status: 500
	Reason: Internal Server Error

and should actually return a proper message like:

"Is not possible to remove the storage conecction from a storage domain while it's in maintenance" or something on those lines.

Comment 6 Daniel Erez 2017-01-09 17:24:26 UTC
(In reply to Carlos Mestre González from comment #5)
> Hi Daniel,
> So I'm still a bit confused, I'm not trying to detach a domain, I'm trying
> to remove the storage connection from that domain while is in maintenance,
> this scenario:
> 
> 1) Two storage domains with the same storage connectaion (iscsi_0 and
> iscsi_1)
> 2) Put iscsi_0 on maintenance
> 3) Try to detach that STORAGE CONNECTION (not domain) from the domain
> iscsi_0 [So maybe it can be attached to other storage connectin later)
> DELETE 
> /ovirt-engine/api/storagedomains/4463f228-a199-4940-82cb-0ca0aa2b7db8/
> storageconnections/c3ed9176-d2fe-43c4-b431-b3d28739ba76
> 
> 
> does this scenario makes sence?
> 
> 1) if it does, in the test fails and should be fixed.
> 
> 2) if it doesn't, then still the engine returns:
> 
> 	Status: 500
> 	Reason: Internal Server Error
> 
> and should actually return a proper message like:
> 
> "Is not possible to remove the storage conecction from a storage domain
> while it's in maintenance" or something on those lines.

It isn't possible to remove a storage connection that is used by a storage domain. A storage connection can only be deleted not detached, no need to delete for reusing it (it's relevant just for cleanup).

I've checked the described scenario on latest 4.1 and got an appropriate message: "Cannot remove Storage Connection. Storage connection parameters are used by the following storage domains : scsi2,scsi1."

Do you get a similar message on latest 4.1 build?