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
This commit is contained in:
Tristan Cacqueray 2017-05-21 03:07:08 +00:00
parent 9e958254bb
commit bad3b1276c
4 changed files with 13 additions and 5 deletions

4
zuul/cmd/__init__.py Normal file → Executable file
View File

@ -98,6 +98,6 @@ class ZuulApp(object):
else: else:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
def configure_connections(self): def configure_connections(self, source_only=False):
self.connections = zuul.lib.connections.ConnectionRegistry() self.connections = zuul.lib.connections.ConnectionRegistry()
self.connections.configure(self.config) self.connections.configure(self.config, source_only)

2
zuul/cmd/executor.py Normal file → Executable file
View File

@ -106,7 +106,7 @@ def main():
server.send_command(server.args.command) server.send_command(server.args.command)
sys.exit(0) sys.exit(0)
server.configure_connections() server.configure_connections(source_only=True)
if server.config.has_option('executor', 'pidfile'): if server.config.has_option('executor', 'pidfile'):
pid_fn = os.path.expanduser(server.config.get('executor', 'pidfile')) pid_fn = os.path.expanduser(server.config.get('executor', 'pidfile'))

2
zuul/cmd/merger.py Normal file → Executable file
View File

@ -77,7 +77,7 @@ def main():
server.parse_arguments() server.parse_arguments()
server.read_config() server.read_config()
server.configure_connections() server.configure_connections(source_only=True)
if server.config.has_option('zuul', 'state_dir'): if server.config.has_option('zuul', 'state_dir'):
state_dir = os.path.expanduser(server.config.get('zuul', 'state_dir')) state_dir = os.path.expanduser(server.config.get('zuul', 'state_dir'))

View File

@ -23,6 +23,7 @@ import zuul.driver.smtp
import zuul.driver.timer import zuul.driver.timer
import zuul.driver.sql import zuul.driver.sql
from zuul.connection import BaseConnection from zuul.connection import BaseConnection
from zuul.driver import SourceInterface
class DefaultConnection(BaseConnection): class DefaultConnection(BaseConnection):
@ -78,7 +79,7 @@ class ConnectionRegistry(object):
for driver in self.drivers.values(): for driver in self.drivers.values():
driver.stop() driver.stop()
def configure(self, config): def configure(self, config, source_only=False):
# Register connections from the config # Register connections from the config
connections = {} connections = {}
@ -100,6 +101,13 @@ class ConnectionRegistry(object):
% (con_config['driver'], con_name)) % (con_config['driver'], con_name))
driver = self.drivers[con_driver] 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) connection = driver.getConnection(con_name, con_config)
connections[con_name] = connection connections[con_name] = connection