Commit 05f1ebf3 authored by Guido Trotter's avatar Guido Trotter
Browse files

Move SimpleConfigReader creation to ConfdProcessor



This will be useful to make ConfdProcessor aware of a config failure,
without quitting confd.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 176d3122
......@@ -192,16 +192,16 @@ class ConfdConfigurationReloader(object):
check, to verify that the reload hasn't failed.
"""
def __init__(self, reader, mainloop):
def __init__(self, processor, mainloop):
"""Constructor for ConfdConfigurationReloader
@type reader: L{ssconf.SimpleConfigReader}
@param reader: ganeti-confd SimpleConfigReader
@type processor: L{confd.server.ConfdProcessor}
@param processor: ganeti-confd ConfdProcessor
@type mainloop: L{daemon.Mainloop}
@param mainloop: ganeti-confd mainloop
"""
self.reader = reader
self.processor = processor
self.mainloop = mainloop
self.polling = False
......@@ -239,7 +239,7 @@ class ConfdConfigurationReloader(object):
raise errors.ConfdFatalError(err)
try:
reloaded = self.reader.Reload()
reloaded = self.processor.reader.Reload()
if reloaded:
logging.info("Reloaded ganeti config")
else:
......@@ -275,7 +275,7 @@ class ConfdConfigurationReloader(object):
"""
self.timer_handle = None
try:
reloaded = self.reader.Reload()
reloaded = self.processor.reader.Reload()
except errors.ConfigurationError:
# transform a ConfigurationError in a fatal error, that will cause confd
# to quit.
......@@ -320,15 +320,12 @@ def ExecConfd(options, args):
"""
mainloop = daemon.Mainloop()
# confd-level SimpleConfigReader
reader = ssconf.SimpleConfigReader()
# Asyncronous confd UDP server
processor = ConfdProcessor(reader)
processor = ConfdProcessor()
server = ConfdAsyncUDPServer(options.bind_address, options.port, processor)
# Configuration reloader
reloader = ConfdConfigurationReloader(reader, mainloop)
reloader = ConfdConfigurationReloader(processor, mainloop)
mainloop.Run()
......
......@@ -34,6 +34,7 @@ from ganeti import objects
from ganeti import errors
from ganeti import utils
from ganeti import serializer
from ganeti import ssconf
from ganeti.confd import querylib
......@@ -41,6 +42,8 @@ from ganeti.confd import querylib
class ConfdProcessor(object):
"""A processor for confd requests.
@ivar reader: confd SimpleConfigReader
"""
DISPATCH_TABLE = {
constants.CONFD_REQ_PING: querylib.PingQuery,
......@@ -49,14 +52,11 @@ class ConfdProcessor(object):
querylib.InstanceIpToNodePrimaryIpQuery,
}
def __init__(self, reader):
def __init__(self):
"""Constructor for ConfdProcessor
@type reader: L{ssconf.SimpleConfigReader}
@param reader: ConfigReader to use to access the config
"""
self.reader = reader
self.reader = ssconf.SimpleConfigReader()
self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY)
assert \
not constants.CONFD_REQS.symmetric_difference(self.DISPATCH_TABLE), \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment