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
This commit is contained in:
Tobias Henkel 2017-10-17 13:08:18 +02:00
parent 38de87bf37
commit 055cda35c3
4 changed files with 52 additions and 1 deletions

View File

@ -522,6 +522,15 @@ The following sections of ``zuul.conf`` are used by the executor:
The executor will observe system load and determine whether The executor will observe system load and determine whether
to accept more jobs every 30 seconds. 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:: merger
.. attr:: git_user_email .. attr:: git_user_email

View File

@ -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

View File

@ -401,3 +401,12 @@ class TestAnsibleJob(ZuulTestCase):
node['ssh_port'] = 22022 node['ssh_port'] = 22022
keys = self.test_job.getHostList({'nodes': [node]})[0]['host_keys'] keys = self.test_job.getHostList({'nodes': [node]})[0]['host_keys']
self.assertEqual(keys[0], '[localhost]:22022 fake-host-key') 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)

View File

@ -1535,7 +1535,8 @@ class ExecutorServer(object):
self.jobdir_root = jobdir_root self.jobdir_root = jobdir_root
# TODOv3(mordred): make the executor name more unique -- # TODOv3(mordred): make the executor name more unique --
# perhaps hostname+pid. # 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.log_streaming_port = log_streaming_port
self.merger_lock = threading.Lock() self.merger_lock = threading.Lock()
self.run_lock = threading.Lock() self.run_lock = threading.Lock()