diff --git a/compute_hyperv/nova/coordination.py b/compute_hyperv/nova/coordination.py index 9473ee67..591220ea 100644 --- a/compute_hyperv/nova/coordination.py +++ b/compute_hyperv/nova/coordination.py @@ -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 diff --git a/compute_hyperv/nova/driver.py b/compute_hyperv/nova/driver.py index 8eca11f8..f0c075e2 100644 --- a/compute_hyperv/nova/driver.py +++ b/compute_hyperv/nova/driver.py @@ -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()