From 20920915411431322f8d852a795e4243f6359454 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 28 Nov 2017 11:22:30 -0500 Subject: [PATCH] Add command_socket setting to executor section Like the merger, add support for setting command_socket path via zuul.conf. Change-Id: I88aa47870d98b0906dfb733f68af663c2dc00993 Signed-off-by: Paul Belanger --- doc/source/admin/components.rst | 5 +++++ tests/base.py | 3 +++ zuul/cmd/executor.py | 8 ++++---- zuul/executor/server.py | 7 +++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/source/admin/components.rst b/doc/source/admin/components.rst index d9883517ad..126e4e2e0a 100644 --- a/doc/source/admin/components.rst +++ b/doc/source/admin/components.rst @@ -397,6 +397,11 @@ The following sections of ``zuul.conf`` are used by the executor: .. attr:: executor + .. attr:: command_socket + :default: /var/lib/zuul/executor.socket + + Path to command socket file for the executor process. + .. attr:: finger_port :default: 79 diff --git a/tests/base.py b/tests/base.py index 210f03b280..2c55f30078 100755 --- a/tests/base.py +++ b/tests/base.py @@ -2070,6 +2070,9 @@ class ZuulTestCase(BaseTestCase): self.config.set('executor', 'git_dir', self.executor_src_root) self.config.set('executor', 'private_key_file', self.private_key_file) self.config.set('executor', 'state_dir', self.executor_state_root) + self.config.set( + 'executor', 'command_socket', + os.path.join(self.test_root, 'executor.socket')) self.statsd = FakeStatsd() if self.config.has_section('statsd'): diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py index aef8c957b3..24bda93292 100755 --- a/zuul/cmd/executor.py +++ b/zuul/cmd/executor.py @@ -53,11 +53,11 @@ class Executor(zuul.cmd.ZuulDaemonApp): self.args.nodaemon = True def send_command(self, cmd): - state_dir = get_default(self.config, 'executor', 'state_dir', - '/var/lib/zuul', expand_user=True) - path = os.path.join(state_dir, 'executor.socket') + command_socket = get_default( + self.config, 'executor', 'command_socket', + '/var/lib/zuul/executor.socket') s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(path) + s.connect(command_socket) cmd = '%s\n' % cmd s.sendall(cmd.encode('utf8')) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 83fdc3ce0a..5f0f2b7a06 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -1608,10 +1608,13 @@ class ExecutorServer(object): self.merger = self._getMerger(self.merge_root) self.update_queue = DeduplicateQueue() + command_socket = get_default( + self.config, 'executor', 'command_socket', + '/var/lib/zuul/executor.socket') + self.command_socket = commandsocket.CommandSocket(command_socket) + state_dir = get_default(self.config, 'executor', 'state_dir', '/var/lib/zuul', expand_user=True) - path = os.path.join(state_dir, 'executor.socket') - self.command_socket = commandsocket.CommandSocket(path) ansible_dir = os.path.join(state_dir, 'ansible') self.ansible_dir = ansible_dir if os.path.exists(ansible_dir):