diff --git a/nova/__init__.py b/nova/__init__.py index 21403ab570ac..228c89d33dce 100644 --- a/nova/__init__.py +++ b/nova/__init__.py @@ -27,4 +27,9 @@ import os os.environ['EVENTLET_NO_GREENDNS'] = 'yes' +# NOTE(rpodolyaka): import oslo_service first, so that it makes eventlet hub +# use a monotonic clock to avoid issues with drifts of system time (see +# LP 1510234 for details) +import oslo_service # noqa + import eventlet # noqa diff --git a/nova/service.py b/nova/service.py index 0621aeab3a45..a04a2e96d559 100644 --- a/nova/service.py +++ b/nova/service.py @@ -95,6 +95,17 @@ def setup_profiler(binary, host): LOG.info(_LI("OSProfiler is enabled.")) +def assert_eventlet_uses_monotonic_clock(): + import eventlet.hubs as hubs + import monotonic + + hub = hubs.get_hub() + if hub.clock is not monotonic.monotonic: + raise RuntimeError( + 'eventlet hub is not using a monotonic clock - ' + 'periodic tasks will be affected by drifts of system time.') + + class Service(service.Service): """Service object for binaries running on hosts. @@ -141,6 +152,8 @@ class Service(service.Service): This includes starting an RPC service, initializing periodic tasks, etc. """ + assert_eventlet_uses_monotonic_clock() + verstr = version.version_string_with_package() LOG.info(_LI('Starting %(topic)s node (version %(version)s)'), {'topic': self.topic, 'version': verstr})