summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-03-22 21:51:50 +0000
committerGerrit Code Review <review@openstack.org>2023-03-22 21:51:50 +0000
commit420fa0a6a747f4c5a505782f7869b9e52e3f8289 (patch)
tree72cf30959f9548edced8350839e8196b3fc590a2
parent4886cf31d170d143d75b59699e7138aeeb534b55 (diff)
parent0c6059f073233d1cdaa40be67e8dadd1142ad45e (diff)
downloadzuul-420fa0a6a747f4c5a505782f7869b9e52e3f8289.tar.gz
Merge "Don't connect to MQTT broker in zuul-web"
-rw-r--r--zuul/driver/mqtt/mqttconnection.py15
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)