diff options
author | Simon Westphahl <simon.westphahl@bmw.de> | 2023-03-13 12:47:10 +0100 |
---|---|---|
committer | Simon Westphahl <simon.westphahl@bmw.de> | 2023-03-13 12:47:10 +0100 |
commit | 0c6059f073233d1cdaa40be67e8dadd1142ad45e (patch) | |
tree | 229926f2b5f48f230ada30f359e2d272b0ae22d0 | |
parent | 0d35927e2c0a010aae92b8f08997b036c318d55a (diff) | |
download | zuul-0c6059f073233d1cdaa40be67e8dadd1142ad45e.tar.gz |
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
-rw-r--r-- | zuul/driver/mqtt/mqttconnection.py | 15 |
1 files 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) |