Use Cotyledon oslo config glue
Oslo.service was providing some oslo config configuration. mainly to print all cfg options on startup and a timeout option in case of service doesn't stop gracefully in an timely fashion. It also reload the configuration file on sighup. This change uses the optional cotyledon helper to do that stuffs. Change-Id: I6227fab55b2f4d33611ca3c4bcf01239ff585748
This commit is contained in:
parent
5186bcc6ba
commit
510d799d05
@ -6,4 +6,5 @@ namespace = oslo.db
|
||||
namespace = oslo.log
|
||||
namespace = oslo.middleware
|
||||
namespace = oslo.policy
|
||||
namespace = cotyledon
|
||||
namespace = keystonemiddleware.auth_token
|
||||
|
@ -19,6 +19,7 @@ import time
|
||||
import uuid
|
||||
|
||||
import cotyledon
|
||||
from cotyledon import oslo_config_glue
|
||||
from futurist import periodics
|
||||
import msgpack
|
||||
from oslo_config import cfg
|
||||
@ -286,15 +287,29 @@ class MetricProcessor(MetricProcessBase):
|
||||
class MetricdServiceManager(cotyledon.ServiceManager):
|
||||
def __init__(self, conf):
|
||||
super(MetricdServiceManager, self).__init__()
|
||||
oslo_config_glue.setup(self, conf)
|
||||
|
||||
self.conf = conf
|
||||
self.queue = multiprocessing.Manager().Queue()
|
||||
|
||||
self.add(MetricScheduler, args=(self.conf, self.queue))
|
||||
self.add(MetricProcessor, args=(self.conf, self.queue),
|
||||
workers=conf.metricd.workers)
|
||||
self.metric_processor_id = self.add(
|
||||
MetricProcessor, args=(self.conf, self.queue),
|
||||
workers=conf.metricd.workers)
|
||||
self.add(MetricReporting, args=(self.conf,))
|
||||
self.add(MetricJanitor, args=(self.conf,))
|
||||
|
||||
self.register_hooks(on_reload=self.on_reload)
|
||||
|
||||
def on_reload(self):
|
||||
# NOTE(sileht): We do not implement reload() in Workers so all workers
|
||||
# will received SIGHUP and exit gracefully, then their will be
|
||||
# restarted with the new number of workers. This is important because
|
||||
# we use the number of worker to declare the capability in tooz and
|
||||
# to select the block of metrics to proceed.
|
||||
self.reconfigure(self.metric_processor_id,
|
||||
workers=self.conf.metricd.workers)
|
||||
|
||||
def run(self):
|
||||
super(MetricdServiceManager, self).run()
|
||||
self.queue.close()
|
||||
|
6
releasenotes/notes/reloading-734a639a667c93ee.yaml
Normal file
6
releasenotes/notes/reloading-734a639a667c93ee.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- gnocchi-metricd now uses the cotyledon/oslo.config helper to handle
|
||||
configuration file reloading. You can dynamically change the number
|
||||
of workers by changing the configuration file and sending SIGHUP to the
|
||||
metricd master process.
|
@ -12,7 +12,7 @@ pecan>=0.9
|
||||
pytimeparse>=1.1.5
|
||||
futures
|
||||
jsonpatch
|
||||
cotyledon>=1.2.2
|
||||
cotyledon>=1.5.0
|
||||
requests
|
||||
six
|
||||
stevedore
|
||||
|
Loading…
Reference in New Issue
Block a user