From 0c6059f073233d1cdaa40be67e8dadd1142ad45e Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Mon, 13 Mar 2023 12:47:10 +0100 Subject: Don't connect to MQTT broker in zuul-web Similar to zuul-web not starting the Github event connector, we also don't want it to connect to the configured MQTT broker as the web component won't be using it. Change-Id: If61da19ab0af39bc68d12c9b6613bf6c41d7efaa --- zuul/driver/mqtt/mqttconnection.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zuul/driver/mqtt/mqttconnection.py b/zuul/driver/mqtt/mqttconnection.py index 7f221282f..4a028ba23 100644 --- a/zuul/driver/mqtt/mqttconnection.py +++ b/zuul/driver/mqtt/mqttconnection.py @@ -64,6 +64,12 @@ class MQTTConnection(BaseConnection): def onLoad(self, zk_client, component_registry): self.log.debug("Starting MQTT Connection") + + # If the connection was not loaded by a scheduler, but by e.g. + # zuul-web, we want to stop here. + if not self.sched: + return + try: self.client.connect( self.connection_config.get('server', 'localhost'), @@ -76,10 +82,11 @@ class MQTTConnection(BaseConnection): self.client.loop_start() def onStop(self): - self.log.debug("Stopping MQTT Connection") - self.client.loop_stop() - self.client.disconnect() - self.connected = False + if self.connected: + self.log.debug("Stopping MQTT Connection") + self.client.loop_stop() + self.client.disconnect() + self.connected = False def publish(self, topic, message, qos, zuul_event_id): log = get_annotated_logger(self.log, zuul_event_id) -- cgit v1.2.1