diff --git a/daemons/ganeti-confd b/daemons/ganeti-confd index 734eb55d198a413359ce8571aeaab38c9f90a67b..88e454bcc5a9578601b9d94c7baef9025b433db4 100755 --- a/daemons/ganeti-confd +++ b/daemons/ganeti-confd @@ -322,6 +322,11 @@ def ExecConfd(options, args): # Asyncronous confd UDP server processor = ConfdProcessor() + try: + processor.Enable() + except errors.ConfigurationError: + # If enabling the processor has failed, we can still go on, but confd will be disabled + pass server = ConfdAsyncUDPServer(options.bind_address, options.port, processor) # Configuration reloader diff --git a/lib/confd/server.py b/lib/confd/server.py index 7937dfd0901fff607c03b476365426f3b7058a5f..601b95759972cc6bdbf0ed28c8bdbb09ddb5c294 100644 --- a/lib/confd/server.py +++ b/lib/confd/server.py @@ -43,6 +43,7 @@ class ConfdProcessor(object): """A processor for confd requests. @ivar reader: confd SimpleConfigReader + @ivar disabled: whether confd serving is disabled """ DISPATCH_TABLE = { @@ -56,12 +57,25 @@ class ConfdProcessor(object): """Constructor for ConfdProcessor """ - self.reader = ssconf.SimpleConfigReader() + self.disabled = True self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY) + self.reader = None assert \ not constants.CONFD_REQS.symmetric_difference(self.DISPATCH_TABLE), \ "DISPATCH_TABLE is unaligned with CONFD_REQS" + def Enable(self): + try: + self.reader = ssconf.SimpleConfigReader() + self.disabled = False + except errors.ConfigurationError: + self.disabled = True + raise + + def Disable(self): + self.disabled = True + self.reader = None + def ExecQuery(self, payload_in, ip, port): """Process a single UDP request from a client. @@ -73,6 +87,9 @@ class ConfdProcessor(object): @type port: source port """ + if self.disabled: + logging.debug('Confd is disabled. Ignoring query.') + return try: request = self.ExtractRequest(payload_in) reply, rsalt = self.ProcessRequest(request)