From 9948f79b5a056b8c7bcb71ce1a92d19c2468224f Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Jul 13 2022 14:55:41 +0000 Subject: Allow partial use of signers Not all users of robosignatory make use of all possible signers. This change will allow initialization of a signer (because of missing/incorrect configuration) to fail, but the process as a whole to continue with the signers that did initialize. Messages that arrive for a disabled signer will create log messages on the debug level. Signed-off-by: Ralf Ertzinger --- diff --git a/robosignatory/consumer.py b/robosignatory/consumer.py index e8ff2fd..4edfdfe 100644 --- a/robosignatory/consumer.py +++ b/robosignatory/consumer.py @@ -19,10 +19,26 @@ class Consumer(object): def __init__(self): log.info('Initializing Robosignatory consumer') self.config = fedora_messaging.config.conf["consumer_config"] - self.tag_handler = TagSigner(self.config) - self.atomic_handler = AtomicSigner(self.config) - self.coreos_handler = CoreOSSigner(self.config) - self.xml_handler = XMLSigner(self.config) + try: + self.tag_handler = TagSigner(self.config) + except: + log.exception("Error initializing Tag handler, ignoring") + self.tag_handler = None + try: + self.atomic_handler = AtomicSigner(self.config) + except: + log.exception("Error initializing Atomic handler, ignoring") + self.atomic_handler = None + try: + self.coreos_handler = CoreOSSigner(self.config) + except: + log.exception("Error initializing CoreOS handler, ignoring") + self.coreos_handler = None + try: + self.xml_handler = XMLSigner(self.config) + except: + log.exception("Error initializing XML handler, ignoring") + self.xml_handler = None def __call__(self, msg): """ @@ -42,18 +58,30 @@ class Consumer(object): try: if msg.topic.endswith('.buildsys.tag'): - log.debug('Passing message to the Tag handler') - self.tag_handler.consume(msg) + if self.tag_handler: + log.debug('Passing message to the Tag handler') + self.tag_handler.consume(msg) + else: + log.debug('Received message for disabled Tag handler') elif msg.topic.endswith('.pungi.compose.ostree'): - log.debug('Passing message to the Atomic handler') - self.atomic_handler.consume(msg) + if self.atomic_handler: + log.debug('Passing message to the Atomic handler') + self.atomic_handler.consume(msg) + else: + log.debug('Received message for disabled Atomic handler') elif (msg.topic.endswith('.coreos.build.request.artifacts-sign') or msg.topic.endswith('.coreos.build.request.ostree-sign')): - log.debug('Passing message to the CoreOS handler') - self.coreos_handler.consume(msg) + if self.coreos_handler: + log.debug('Passing message to the CoreOS handler') + self.coreos_handler.consume(msg) + else: + log.debug('Received message for disabled CoreOS handler') elif msg.topic.endswith('.robosignatory.xml-sign'): - log.debug('Passing message to the Text handler') - self.xml_handler.consume(msg) + if self.xml_handler: + log.debug('Passing message to the Text handler') + self.xml_handler.consume(msg) + else: + log.debug('Received message for disabled XML handler') except Exception as e: error_msg = '{e}: Unable to handle message: {msg}'.format(e=e, msg=msg) log.exception(error_msg)