From bad3b1276cf24110fa6ac056b466fd6cf84cd7d2 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Sun, 21 May 2017 03:07:08 +0000 Subject: [PATCH] merger/executor: configure source connections only. The sql reporter doesn't not need to be enabled on the merger or the executor since it will fail if only the zuul scheduler host is authorized to connect to the sql database. Change-Id: I453754052b75de3d4fac266dc73921c7ce9c075f --- zuul/cmd/__init__.py | 4 ++-- zuul/cmd/executor.py | 2 +- zuul/cmd/merger.py | 2 +- zuul/lib/connections.py | 10 +++++++++- 4 files changed, 13 insertions(+), 5 deletions(-) mode change 100644 => 100755 zuul/cmd/__init__.py mode change 100644 => 100755 zuul/cmd/executor.py mode change 100644 => 100755 zuul/cmd/merger.py diff --git a/zuul/cmd/__init__.py b/zuul/cmd/__init__.py old mode 100644 new mode 100755 index f2a2612acd..d31c5b8700 --- a/zuul/cmd/__init__.py +++ b/zuul/cmd/__init__.py @@ -98,6 +98,6 @@ class ZuulApp(object): else: logging.basicConfig(level=logging.DEBUG) - def configure_connections(self): + def configure_connections(self, source_only=False): self.connections = zuul.lib.connections.ConnectionRegistry() - self.connections.configure(self.config) + self.connections.configure(self.config, source_only) diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py old mode 100644 new mode 100755 index 96ba4b3d52..1893f5af17 --- a/zuul/cmd/executor.py +++ b/zuul/cmd/executor.py @@ -106,7 +106,7 @@ def main(): server.send_command(server.args.command) sys.exit(0) - server.configure_connections() + server.configure_connections(source_only=True) if server.config.has_option('executor', 'pidfile'): pid_fn = os.path.expanduser(server.config.get('executor', 'pidfile')) diff --git a/zuul/cmd/merger.py b/zuul/cmd/merger.py old mode 100644 new mode 100755 index 797a990b01..686f34a12c --- a/zuul/cmd/merger.py +++ b/zuul/cmd/merger.py @@ -77,7 +77,7 @@ def main(): server.parse_arguments() server.read_config() - server.configure_connections() + server.configure_connections(source_only=True) if server.config.has_option('zuul', 'state_dir'): state_dir = os.path.expanduser(server.config.get('zuul', 'state_dir')) diff --git a/zuul/lib/connections.py b/zuul/lib/connections.py index f5cce7bce6..720299a0ca 100644 --- a/zuul/lib/connections.py +++ b/zuul/lib/connections.py @@ -23,6 +23,7 @@ import zuul.driver.smtp import zuul.driver.timer import zuul.driver.sql from zuul.connection import BaseConnection +from zuul.driver import SourceInterface class DefaultConnection(BaseConnection): @@ -78,7 +79,7 @@ class ConnectionRegistry(object): for driver in self.drivers.values(): driver.stop() - def configure(self, config): + def configure(self, config, source_only=False): # Register connections from the config connections = {} @@ -100,6 +101,13 @@ class ConnectionRegistry(object): % (con_config['driver'], con_name)) driver = self.drivers[con_driver] + + # The merger and the reporter only needs source driver. + # This makes sure Reporter like the SQLDriver are only created by + # the scheduler process + if source_only and not issubclass(driver, SourceInterface): + continue + connection = driver.getConnection(con_name, con_config) connections[con_name] = connection