summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-11-14 07:49:18 +0000
committerGerrit Code Review <review@openstack.org>2017-11-14 07:49:18 +0000
commitabf1ec6c8cfea40d5a1bce329a81ed68fd73991a (patch)
tree2a72478c390edac6128f6c99f16f2cc721648ec3
parentbcb7a6b5fefc84aa0c41d5043f372a30c9c929c6 (diff)
parent2c4574bfdcf9bd08efcb3c82becb26787a635338 (diff)
Merge "Make eventlet hub use a monotonic clock"
-rw-r--r--masakari/__init__.py5
-rw-r--r--masakari/service.py12
2 files changed, 17 insertions, 0 deletions
diff --git a/masakari/__init__.py b/masakari/__init__.py
index 28f1042..4073dc9 100644
--- a/masakari/__init__.py
+++ b/masakari/__init__.py
@@ -26,4 +26,9 @@ import os
26 26
27os.environ['EVENTLET_NO_GREENDNS'] = 'yes' 27os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
28 28
29# NOTE(rpodolyaka): import oslo_service first, so that it makes eventlet hub
30# use a monotonic clock to avoid issues with drifts of system time (see
31# LP 1510234 for details)
32import oslo_service # noqa
33
29import eventlet # noqa 34import eventlet # noqa
diff --git a/masakari/service.py b/masakari/service.py
index ba5168f..949a105 100644
--- a/masakari/service.py
+++ b/masakari/service.py
@@ -41,6 +41,17 @@ LOG = logging.getLogger(__name__)
41CONF = masakari.conf.CONF 41CONF = masakari.conf.CONF
42 42
43 43
44def assert_eventlet_uses_monotonic_clock():
45 import eventlet.hubs as hubs
46 import monotonic
47
48 hub = hubs.get_hub()
49 if hub.clock is not monotonic.monotonic:
50 raise RuntimeError(
51 'eventlet hub is not using a monotonic clock - '
52 'periodic tasks will be affected by drifts of system time.')
53
54
44class Service(service.Service): 55class Service(service.Service):
45 """Service object for binaries running on hosts. 56 """Service object for binaries running on hosts.
46 57
@@ -78,6 +89,7 @@ class Service(service.Service):
78 } 89 }
79 90
80 def start(self): 91 def start(self):
92 assert_eventlet_uses_monotonic_clock()
81 verstr = version.version_string_with_package() 93 verstr = version.version_string_with_package()
82 LOG.info('Starting %(topic)s (version %(version)s)', { 94 LOG.info('Starting %(topic)s (version %(version)s)', {
83 'topic': self.topic, 95 'topic': self.topic,