Use worker_name for job cancellation and remove manager

The word "manager" in zuul primarily means "PipelineManager" and is
confusing here. We also send back "worker_name" which is intended to be
the unique name for the worker.

For now, send back hostname for the worker_name. In the future, we can
update this to be overridable per-executor in the config.

While we're at it, remove no-longer valid references to other worker
data from the docs.

Change-Id: Ibe5cf7295f133c9dc48162b40ae1f625a19643dc
This commit is contained in:
Monty Taylor 2017-06-14 11:56:54 -05:00 committed by David Shrewsbury
parent a6f7162b34
commit eea6bb9b7b
4 changed files with 15 additions and 25 deletions

View File

@ -273,26 +273,11 @@ To help with debugging builds a worker may send back some optional
metadata:
**worker_name** (optional)
The name of the worker.
The unique name of the worker.
**worker_hostname** (optional)
The hostname of the worker.
**worker_ips** (optional)
A list of IPs for the worker.
**worker_fqdn** (optional)
The FQDN of the worker.
**worker_program** (optional)
The program name of the worker. For example Jenkins or turbo-hipster.
**worker_version** (optional)
The version of the software running the job.
**worker_extra** (optional)
A dictionary of any extra metadata you may want to pass along.
It should then immediately send a WORK_STATUS packet with a value of 0
percent complete. It may then optionally send subsequent WORK_STATUS
packets with updated completion values.

View File

@ -3380,13 +3380,13 @@ class TestScheduler(ZuulTestCase):
raise Exception("Timeout waiting for gearman server to report "
+ "back to the client")
build = list(self.executor_client.builds.values())[0]
if build.worker.name == "My Worker":
if build.worker.name == self.executor_server.hostname:
break
else:
time.sleep(0)
self.log.debug(build)
self.assertEqual("My Worker", build.worker.name)
self.assertEqual(self.executor_server.hostname, build.worker.name)
self.executor_server.hold_jobs_in_build = False
self.executor_server.release()
@ -3553,7 +3553,7 @@ For CI problems and help debugging, contact ci@example.org"""
raise Exception("Timeout waiting for gearman server to report "
+ "back to the client")
build = list(self.executor_client.builds.values())[0]
if build.worker.name == "My Worker":
if build.worker.name == self.executor_server.hostname:
break
else:
time.sleep(0)

View File

@ -337,7 +337,7 @@ class ExecutorClient(object):
gearman_job = gear.TextJob('executor:execute', json.dumps(params),
unique=uuid)
build.__gearman_job = gearman_job
build.__gearman_manager = None
build.__gearman_worker = None
self.builds[uuid] = build
# NOTE(pabelanger): Rather then looping forever, check to see if job
@ -444,7 +444,7 @@ class ExecutorClient(object):
if not started:
self.log.info("Build %s started" % job)
build.__gearman_manager = data.get('manager')
build.__gearman_worker = data.get('worker_name')
self.sched.onBuildStarted(build)
else:
self.log.error("Unable to find build %s" % job.unique)
@ -473,12 +473,12 @@ class ExecutorClient(object):
return False
def cancelRunningBuild(self, build):
if not build.__gearman_manager:
if not build.__gearman_worker:
self.log.error("Build %s has no manager while canceling" %
(build,))
stop_uuid = str(uuid4().hex)
data = dict(uuid=build.__gearman_job.unique)
stop_job = gear.TextJob("executor:stop:%s" % build.__gearman_manager,
stop_job = gear.TextJob("executor:stop:%s" % build.__gearman_worker,
json.dumps(data), unique=stop_uuid)
self.meta_jobs[stop_uuid] = stop_job
self.log.debug("Submitting stop job: %s", stop_job)

View File

@ -808,11 +808,16 @@ class AnsibleJob(object):
self.prepareAnsibleFiles(args)
data = {
'manager': self.executor_server.hostname,
'url': 'finger://{server}/{unique}'.format(
unique=self.job.unique,
server=self.executor_server.hostname),
'worker_name': 'My Worker',
# TODO(mordred) worker_name is needed as a unique name for the
# client to use for cancelling jobs on an executor. It's defaulting
# to the hostname for now, but in the future we should allow
# setting a per-executor override so that one can run more than
# one executor on a host.
'worker_name': self.executor_server.hostname,
'worker_hostname': self.executor_server.hostname,
}
self.job.sendWorkData(json.dumps(data))