Merge "Get logs of creating container should return 409"
This commit is contained in:
commit
257890f3bc
@ -396,6 +396,7 @@ class ContainersController(rest.RestController):
|
||||
timestamps=False, tail='all', since=None):
|
||||
container = _get_container(container_id)
|
||||
check_policy_on_container(container.as_dict(), "container:logs")
|
||||
utils.validate_container_state(container, 'logs')
|
||||
try:
|
||||
stdout = strutils.bool_from_string(stdout, strict=True)
|
||||
stderr = strutils.bool_from_string(stderr, strict=True)
|
||||
|
@ -52,6 +52,7 @@ VALID_STATES = {
|
||||
'top': ['Running'],
|
||||
'get_archive': ['Running', 'Stopped', 'Paused', 'Created'],
|
||||
'put_archive': ['Running', 'Stopped', 'Paused', 'Created'],
|
||||
'logs': ['Running', 'Stopped', 'Paused', 'Created', 'Error', 'Unknown'],
|
||||
}
|
||||
|
||||
|
||||
|
@ -791,6 +791,15 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
container_uuid, params)
|
||||
self.assertFalse(mock_container_logs.called)
|
||||
|
||||
def test_get_logs_with_invalid_state(self):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
test_object = utils.create_test_container(context=self.context,
|
||||
uuid=uuid, status='Creating')
|
||||
with self.assertRaisesRegexp(
|
||||
AppError,
|
||||
"Cannot logs container %s in Creating state" % uuid):
|
||||
self.app.get('/v1/containers/%s/logs/' % test_object.uuid)
|
||||
|
||||
@patch('zun.common.utils.validate_container_state')
|
||||
@patch('zun.compute.api.API.container_exec')
|
||||
@patch('zun.objects.Container.get_by_uuid')
|
||||
|
Loading…
Reference in New Issue
Block a user