Fix container status on create
Closes-Bug: #1838715 Change-Id: Ia166d7d23e058810831dd05da65d812565833124
This commit is contained in:
parent
36d5246c34
commit
e205780bb5
@ -330,7 +330,7 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
container.addresses = addresses
|
container.addresses = addresses
|
||||||
|
|
||||||
response = docker.inspect_container(container.container_id)
|
response = docker.inspect_container(container.container_id)
|
||||||
self._populate_container(container, response)
|
self._populate_container(container, response, force=True)
|
||||||
container.save(context)
|
container.save(context)
|
||||||
return container
|
return container
|
||||||
|
|
||||||
@ -649,9 +649,9 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
return '{} seconds'.format(time_dict['seconds'])
|
return '{} seconds'.format(time_dict['seconds'])
|
||||||
return
|
return
|
||||||
|
|
||||||
def _populate_container(self, container, response):
|
def _populate_container(self, container, response, force=False):
|
||||||
state = response.get('State')
|
state = response.get('State')
|
||||||
self._populate_container_state(container, state)
|
self._populate_container_state(container, state, force)
|
||||||
|
|
||||||
config = response.get('Config')
|
config = response.get('Config')
|
||||||
if config:
|
if config:
|
||||||
@ -662,10 +662,17 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
if hostconfig:
|
if hostconfig:
|
||||||
container.runtime = hostconfig.get('Runtime')
|
container.runtime = hostconfig.get('Runtime')
|
||||||
|
|
||||||
def _populate_container_state(self, container, state):
|
def _populate_container_state(self, container, state, force):
|
||||||
if container.task_state:
|
if container.task_state and not force:
|
||||||
# NOTE(hongbin): we don't want to populate container state
|
# NOTE(hongbin): we don't want to populate container state
|
||||||
# if another thread is doing task on this container.
|
# if another thread is performing task on this container.
|
||||||
|
# In this case, task_state will be assigned (which means there is a
|
||||||
|
# task performing on this container) and 'force' will be set to
|
||||||
|
# False. For example, if this method is called by create,
|
||||||
|
# 'force' will be set to True to force refreshing the state.
|
||||||
|
# If this method is called by list or show,
|
||||||
|
# 'force' will be set to False, in which case we skip
|
||||||
|
# refreshing the state if there is a task on this container.
|
||||||
return
|
return
|
||||||
|
|
||||||
if not state:
|
if not state:
|
||||||
@ -1301,7 +1308,7 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
docker.start(container.container_id)
|
docker.start(container.container_id)
|
||||||
|
|
||||||
response = docker.inspect_container(container.container_id)
|
response = docker.inspect_container(container.container_id)
|
||||||
self._populate_container(container, response)
|
self._populate_container(container, response, force=True)
|
||||||
container.save(context)
|
container.save(context)
|
||||||
|
|
||||||
def _wait_for_init_container(self, context, container, timeout=3600):
|
def _wait_for_init_container(self, context, container, timeout=3600):
|
||||||
|
Loading…
Reference in New Issue
Block a user