Merge "Force delete a paused container return 500"
This commit is contained in:
commit
40543cd49c
@ -314,6 +314,8 @@ class ContainersController(rest.RestController):
|
||||
raise exception.InvalidValue(msg)
|
||||
if not force:
|
||||
utils.validate_container_state(container, 'delete')
|
||||
else:
|
||||
utils.validate_container_state(container, 'delete_force')
|
||||
context = pecan.request.context
|
||||
compute_api = pecan.request.compute_api
|
||||
compute_api.container_delete(context, container, force)
|
||||
|
@ -36,6 +36,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
VALID_STATES = {
|
||||
'delete': ['Stopped', 'Error', 'Created'],
|
||||
'delete_force': ['Running', 'Stopped', 'Error', 'Created',
|
||||
'Unknown', 'Creating'],
|
||||
'start': ['Stopped', 'Created'],
|
||||
'stop': ['Running'],
|
||||
'reboot': ['Running', 'Stopped', 'Created'],
|
||||
|
@ -847,6 +847,15 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
"Cannot delete container %s in Running state" % uuid):
|
||||
self.app.delete('/v1/containers/%s' % (test_object.uuid))
|
||||
|
||||
def test_delete_force_by_uuid_invalid_state(self):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
test_object = utils.create_test_container(context=self.context,
|
||||
uuid=uuid, status='Paused')
|
||||
with self.assertRaisesRegexp(
|
||||
AppError,
|
||||
"Cannot delete_force container %s in Paused state" % uuid):
|
||||
self.app.delete('/v1/containers/%s?force=True' % test_object.uuid)
|
||||
|
||||
@patch('zun.compute.api.API.container_delete')
|
||||
def test_delete_by_uuid_invalid_state_force_true(self, mock_delete):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
|
Loading…
x
Reference in New Issue
Block a user