From d4815fabbebaa2d51666ce3f4b99b1915f662ccb Mon Sep 17 00:00:00 2001 From: Feng Shengqin Date: Thu, 6 Apr 2017 09:39:26 +0800 Subject: [PATCH] Immediately validate the state of container after checking policy If the state of the container is not in conformity with the rules, it will raise exception earlier and needn't handle the parameters. Change-Id: I8251a1ef92342be8638b84b7aad1c876cacb0896 --- zun/api/controllers/v1/containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zun/api/controllers/v1/containers.py b/zun/api/controllers/v1/containers.py index a932dd509..06c648db9 100644 --- a/zun/api/controllers/v1/containers.py +++ b/zun/api/controllers/v1/containers.py @@ -414,13 +414,13 @@ class ContainersController(rest.RestController): def execute(self, container_id, run=True, interactive=False, **kw): container = _get_container(container_id) check_policy_on_container(container.as_dict(), "container:execute") + utils.validate_container_state(container, 'execute') try: run = strutils.bool_from_string(run, strict=True) interactive = strutils.bool_from_string(interactive, strict=True) except ValueError: msg = _('Valid run values are true, false, 0, 1, yes and no') raise exception.InvalidValue(msg) - utils.validate_container_state(container, 'execute') LOG.debug('Calling compute.container_exec with %s command %s' % (container.uuid, kw['command'])) context = pecan.request.context