From bbb4875072804829e8b589af286c8638972a88ac Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 21 Feb 2017 10:56:40 -0500 Subject: [PATCH] Plumb zookeeper config settings into zuul-scheduler We need a way to configure zuul to connect to zookeeper. Add a new setting into the zuul section of zuul.conf. Multiple zookeeper hosts would be configured as: [zuul] zookeeper_hosts=nodepool.openstack.org:2181,foo.openstack.org:1337 Change-Id: I4640c4af5ba925e099978b64c59ed29d723b1230 Signed-off-by: Paul Belanger --- etc/zuul.conf-sample | 1 + zuul/cmd/scheduler.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/etc/zuul.conf-sample b/etc/zuul.conf-sample index d7b8eaeb55..3de145aff0 100644 --- a/etc/zuul.conf-sample +++ b/etc/zuul.conf-sample @@ -10,6 +10,7 @@ log_config=/etc/zuul/logging.conf pidfile=/var/run/zuul/zuul.pid state_dir=/var/lib/zuul status_url=https://jenkins.example.com/zuul/status +zookeeper_hosts=127.0.0.1:2181 [merger] git_dir=/var/lib/zuul/git diff --git a/zuul/cmd/scheduler.py b/zuul/cmd/scheduler.py index bb27a0fd86..109929c691 100755 --- a/zuul/cmd/scheduler.py +++ b/zuul/cmd/scheduler.py @@ -153,6 +153,7 @@ class Scheduler(zuul.cmd.ZuulApp): import zuul.lib.swift import zuul.webapp import zuul.rpclistener + import zuul.zk signal.signal(signal.SIGUSR2, zuul.cmd.stack_dump_handler) if (self.config.has_option('gearman_server', 'start') and @@ -171,6 +172,14 @@ class Scheduler(zuul.cmd.ZuulApp): merger = zuul.merger.client.MergeClient(self.config, self.sched) nodepool = zuul.nodepool.Nodepool(self.sched) + zookeeper = zuul.zk.ZooKeeper() + if self.config.has_option('zuul', 'zookeeper_hosts'): + zookeeper_hosts = self.config.get('zuul', 'zookeeper_hosts') + else: + zookeeper_hosts = '127.0.0.1:2181' + + zookeeper.connect(zookeeper_hosts) + if self.config.has_option('zuul', 'status_expiry'): cache_expiry = self.config.getint('zuul', 'status_expiry') else: @@ -195,6 +204,7 @@ class Scheduler(zuul.cmd.ZuulApp): self.sched.setLauncher(gearman) self.sched.setMerger(merger) self.sched.setNodepool(nodepool) + self.sched.setZooKeeper(zookeeper) self.log.info('Starting scheduler') try: