Initialize coordination during driver init

At the moment, the "init_host" method initializes the distributed
lock mechanism, yet the driver may try to use distributed locks
before that.

For example, the method that reclaims failed over instances is
called by the driver init method, before init_host. While we
can fix this particular call, it's safer that we initialize the
lock mechanism as early as possible.

Change-Id: If361c0f754d3680726762e3126286227bea6f3f3
Related-Bug: #1841777
This commit is contained in:
Lucian Petrut 2019-09-03 11:22:14 +03:00
parent e8e2bedd76
commit 20c1b2083f
2 changed files with 7 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import uuid
import decorator
from nova import exception
from nova import utils
from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
@ -49,6 +50,7 @@ class Coordinator(object):
self.started = False
self.prefix = prefix
@utils.synchronized(name="coordinator_start")
def start(self):
if self.started:
return

View File

@ -120,6 +120,11 @@ class HyperVDriver(driver.ComputeDriver):
# further driver initialisation.
self._check_minimum_windows_version()
# We'll initialize coordination as early as possible, avoiding
# the risk of using locks before the mechanism is enabled.
if self.use_coordination:
coordination.COORDINATOR.start()
super(HyperVDriver, self).__init__(virtapi)
self._hostops = hostops.HostOps()
@ -158,9 +163,6 @@ class HyperVDriver(driver.ComputeDriver):
return False
def init_host(self, host):
if self.use_coordination:
coordination.COORDINATOR.start()
self._serialconsoleops.start_console_handlers()
self._set_event_handler_callbacks()