Fix race condition when syncing bay status across conductors

In order to run several magnum-conductor, we should make periodic
tasks can run simultaneously. We should not destroy a bay twice.

Change-Id: Ie3c66442839197196f532734e67d810749ec5052
Partial-Implements: blueprint horizontal-scale
This commit is contained in:
Hua Wang 2015-08-03 04:26:40 +08:00
parent d5d1d88286
commit e495f81b39
1 changed files with 6 additions and 1 deletions

View File

@ -22,6 +22,7 @@ from oslo_service import threadgroup
from magnum.common import clients
from magnum.common import context
from magnum.common import exception
from magnum.i18n import _LI
from magnum.i18n import _LW
from magnum import objects
@ -82,7 +83,11 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
six.viewkeys(sid_to_stack_mapping)):
bay = sid_to_bay_mapping[sid]
if bay.status == bay_status.DELETE_IN_PROGRESS:
bay.destroy()
try:
bay.destroy()
except exception.BayNotFound:
LOG.info(_LI('The bay %s has been deleted by others.')
% bay.uuid)
LOG.info(_LI("Bay with id %(id)s has been deleted due "
"to stack with id %(sid)s not found in "
"Heat."),