Resolve statsd client once at startup
We currently create a new statsd client each time we replace a provider manager. This means that if we are unable to resolve DNS at that time, the new provider may crash due to unhandled exceptions. To resolve this, let's adopt the same behavior we have in Zuul which is to set up the statsd client once at startup and continue to use the same client object for the life of the process. This means that operators will still see errors at startup during a misconfiguration, but any external changes after that will not affect nodepool. Change-Id: I65967c71e859fddbea15aee89f6ddae44344c87b
This commit is contained in:
parent
b2c6017d34
commit
21b8451947
@ -69,7 +69,8 @@ class StateMachineNodeLauncher(stats.StatsReporter):
|
||||
"""
|
||||
|
||||
def __init__(self, handler, node, provider_config):
|
||||
super().__init__()
|
||||
launcher = handler.pw.nodepool
|
||||
super().__init__(launcher.statsd)
|
||||
# Based on utils.NodeLauncher
|
||||
logger = logging.getLogger(
|
||||
f"nodepool.StateMachineNodeLauncher.{provider_config.name}")
|
||||
|
@ -51,7 +51,8 @@ class NodeLauncher(threading.Thread,
|
||||
describing the provider launching this node.
|
||||
'''
|
||||
threading.Thread.__init__(self, name="NodeLauncher-%s" % node.id)
|
||||
stats.StatsReporter.__init__(self)
|
||||
launcher = handler.pw.nodepool
|
||||
stats.StatsReporter.__init__(self, launcher.statsd)
|
||||
logger = logging.getLogger("nodepool.NodeLauncher")
|
||||
request = handler.request
|
||||
self.log = get_annotated_logger(logger,
|
||||
|
@ -79,7 +79,7 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
|
||||
self.launcher_id = "%s-%s-%s" % (socket.getfqdn(),
|
||||
self.name,
|
||||
uuid.uuid4().hex)
|
||||
stats.StatsReporter.__init__(self)
|
||||
stats.StatsReporter.__init__(self, nodepool.statsd)
|
||||
|
||||
def getPriority(self):
|
||||
pool = self.getPoolConfig()
|
||||
@ -966,6 +966,7 @@ class StatsWorker(BaseCleanupWorker, stats.StatsReporter):
|
||||
self.log = logging.getLogger('nodepool.StatsWorker')
|
||||
self.stats_event = threading.Event()
|
||||
self.election = None
|
||||
stats.StatsReporter.__init__(self, nodepool.statsd)
|
||||
|
||||
def stop(self):
|
||||
self._running = False
|
||||
@ -977,8 +978,6 @@ class StatsWorker(BaseCleanupWorker, stats.StatsReporter):
|
||||
|
||||
def _run(self):
|
||||
try:
|
||||
stats.StatsReporter.__init__(self)
|
||||
|
||||
if not self._statsd:
|
||||
return
|
||||
|
||||
|
@ -50,9 +50,9 @@ class StatsReporter(object):
|
||||
'''
|
||||
Class adding statsd reporting functionality.
|
||||
'''
|
||||
def __init__(self):
|
||||
def __init__(self, statsd_client):
|
||||
super(StatsReporter, self).__init__()
|
||||
self._statsd = get_client()
|
||||
self._statsd = statsd_client
|
||||
|
||||
def recordLaunchStats(self, subkey, dt):
|
||||
'''
|
||||
|
Loading…
x
Reference in New Issue
Block a user