Always reset task state to None

Upon the completion of attaching/detaching network, always set the
task_state to none. This ensures the task_state is cleanup on
exception.

Change-Id: Ia664df05b13090b28be7dcfc44649954bb4c0f9d
Closes-Bug: #1812602
This commit is contained in:
Hongbin Lu 2019-01-21 03:47:28 +00:00
parent 9ee214bfed
commit 58218c1d0b
1 changed files with 8 additions and 4 deletions

View File

@ -1274,8 +1274,10 @@ class Manager(periodic_task.PeriodicTasks):
{'container': container, 'network': network})
self._update_task_state(context, container,
consts.NETWORK_DETACHING)
self.driver.network_detach(context, container, network)
self._update_task_state(context, container, None)
try:
self.driver.network_detach(context, container, network)
finally:
self._update_task_state(context, container, None)
def network_attach(self, context, container, requested_network):
@utils.synchronized(container.uuid)
@ -1291,8 +1293,10 @@ class Manager(periodic_task.PeriodicTasks):
{'container': container, 'network': requested_network})
self._update_task_state(context, container,
consts.NETWORK_ATTACHING)
self.driver.network_attach(context, container, requested_network)
self._update_task_state(context, container, None)
try:
self.driver.network_attach(context, container, requested_network)
finally:
self._update_task_state(context, container, None)
def network_create(self, context, neutron_net_id):
LOG.debug('Create network')