Show container failed if container host is none

The rpc message is synchronous call, so the client will wait the
return value until time out. If the host parameter the PRC call
used is none, RPC call will not get the return value.
If the container host is none, return the container information
directly.

Closes-Bug: #1771578
Change-Id: I16a6e49223f1184d63f4ff6f2eb0211e8ae9e84f
This commit is contained in:
weikeyou 2018-05-16 21:57:58 +08:00
parent c714b11fdd
commit a5186183a1
1 changed files with 6 additions and 5 deletions

View File

@ -251,11 +251,12 @@ class ContainersController(base.Controller):
context.all_projects = True
container = utils.get_container(container_ident)
check_policy_on_container(container.as_dict(), "container:get_one")
compute_api = pecan.request.compute_api
try:
container = compute_api.container_show(context, container)
except exception.ContainerHostNotUp:
raise exception.ServerNotUsable
if container.host:
compute_api = pecan.request.compute_api
try:
container = compute_api.container_show(context, container)
except exception.ContainerHostNotUp:
raise exception.ServerNotUsable
if not context.is_admin:
del container.host