Browse Source

Make executor hostname configurable

The executor needs to know its hostname as it embeds it into the
finger url. In some environments it cannot correctly determine its own
hostname so the finger url (and thus live log streaming) would not
work. Making the hostname configurable can solve this easily in such
environments.

Change-Id: Ifeb639b4499d737e9045508c4f66aefa950effa6
changes/29/512629/1
Tobias Henkel 4 years ago
parent
commit
055cda35c3
  1. 9
      doc/source/admin/components.rst
  2. 32
      tests/fixtures/zuul-executor-hostname.conf
  3. 9
      tests/unit/test_executor.py
  4. 3
      zuul/executor/server.py

9
doc/source/admin/components.rst

@ -522,6 +522,15 @@ The following sections of ``zuul.conf`` are used by the executor:
The executor will observe system load and determine whether
to accept more jobs every 30 seconds.
.. attr:: hostname
:default: hostname of the server
The executor needs to know its hostname under which it is reachable by
zuul-web. Otherwise live console log streaming doesn't work. In most cases
This is automatically detected correctly. But when running in environments
where it cannot determine its hostname correctly this can be overridden
here.
.. attr:: merger
.. attr:: git_user_email

32
tests/fixtures/zuul-executor-hostname.conf

@ -0,0 +1,32 @@
[gearman]
server=127.0.0.1
[statsd]
# note, use 127.0.0.1 rather than localhost to avoid getting ipv6
# see: https://github.com/jsocol/pystatsd/issues/61
server=127.0.0.1
[scheduler]
tenant_config=main.yaml
[merger]
git_dir=/tmp/zuul-test/merger-git
git_user_email=zuul@example.com
git_user_name=zuul
[executor]
git_dir=/tmp/zuul-test/executor-git
hostname=test-executor-hostname.openstack.org
[connection gerrit]
driver=gerrit
server=review.example.com
user=jenkins
sshkey=fake_id_rsa_path
[connection smtp]
driver=smtp
server=localhost
port=25
default_from=zuul@example.com
default_to=you@example.com

9
tests/unit/test_executor.py

@ -401,3 +401,12 @@ class TestAnsibleJob(ZuulTestCase):
node['ssh_port'] = 22022
keys = self.test_job.getHostList({'nodes': [node]})[0]['host_keys']
self.assertEqual(keys[0], '[localhost]:22022 fake-host-key')
class TestExecutorHostname(ZuulTestCase):
config_file = 'zuul-executor-hostname.conf'
tenant_config_file = 'config/single-tenant/main.yaml'
def test_executor_hostname(self):
self.assertEqual('test-executor-hostname.openstack.org',
self.executor_server.hostname)

3
zuul/executor/server.py

@ -1535,7 +1535,8 @@ class ExecutorServer(object):
self.jobdir_root = jobdir_root
# TODOv3(mordred): make the executor name more unique --
# perhaps hostname+pid.
self.hostname = socket.gethostname()
self.hostname = get_default(self.config, 'executor', 'hostname',
socket.gethostname())
self.log_streaming_port = log_streaming_port
self.merger_lock = threading.Lock()
self.run_lock = threading.Lock()

Loading…
Cancel
Save