Fix incorrect process on init_container

When zun-compute is restarted, it calls init_container to
continue previous tasks. However, not all tasks can be resume
properly. If container's tasks are unrecoverable (i.e.
NETWORK_ATTACHING, NETWORK_DETACHING, SG_ADDING and SG_REMOVING),
set the container to "Error" state instead.

Change-Id: If7711ef9c6e3f1b90635a2e5bdd28bc702ed3b66
Closes-Bug: #1812590
This commit is contained in:
Hongbin Lu 2019-01-20 21:57:45 +00:00
parent 32adf119b0
commit 9ee214bfed
1 changed files with 5 additions and 17 deletions

View File

@ -87,7 +87,11 @@ class Manager(periodic_task.PeriodicTasks):
if (container.status == consts.CREATING or
container.task_state in [consts.CONTAINER_CREATING,
consts.IMAGE_PULLING,
consts.SANDBOX_CREATING]):
consts.SANDBOX_CREATING,
consts.NETWORK_ATTACHING,
consts.NETWORK_DETACHING,
consts.SG_ADDING,
consts.SG_REMOVING]):
LOG.debug("Container %s failed to create correctly, "
"setting to ERROR state", container.uuid)
container.task_state = None
@ -139,22 +143,6 @@ class Manager(periodic_task.PeriodicTasks):
self.container_kill(context, container)
return
if container.task_state == consts.NETWORK_ATTACHING:
self.network_attach(context, container)
return
if container.task_state == consts.NETWORK_DETACHING:
self.network_detach(context, container)
return
if container.task_state == consts.SG_ADDING:
self.add_security_group(context, container)
return
if container.task_state == consts.SG_REMOVING:
self.remove_security_group(context, container)
return
def _fail_container(self, context, container, error, unset_host=False):
try:
self._detach_volumes(context, container)