Change exception type while deattaching root device
By default it is not possible to deattach volume that is configured as root device for an instance. Previous HTTP 403 reponse pointed that caller don't have permission to deattach the volume instead he's not able to do it. Response 400 suits more for that case. Change-Id: Ife59900448719f78c0505f1b681cb26674fa0306
This commit is contained in:
1 parent
e4a2ebafe1
commit
d2e40a3e49
2 files changed
+2
-2
No files matched your search
@@ -433,7 +433,7 @@ class VolumeAttachmentController(wsgi.Controller):
|
||||
|
||||
if bdm.is_root:
|
||||
msg = _("Cannot detach a root device volume")
|
||||
raise exc.HTTPForbidden(explanation=msg)
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
try:
|
||||
self.compute_api.detach_volume(context, instance, volume)
|
||||
|
||||
@@ -541,7 +541,7 @@ class VolumeAttachTestsV21(test.NoDBTestCase):
|
||||
new_callable=mock.PropertyMock)
|
||||
def test_detach_vol_root(self, mock_isroot):
|
||||
mock_isroot.return_value = True
|
||||
self.assertRaises(exc.HTTPForbidden,
|
||||
self.assertRaises(exc.HTTPBadRequest,
|
||||
self.attachments.delete,
|
||||
self.req,
|
||||
FAKE_UUID,
|
||||
|
||||
Reference in new issue
Block a user