From eea6bb9b7bb50af07a9d2db5dc84c7cf5d5e3823 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 14 Jun 2017 11:56:54 -0500 Subject: [PATCH] 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 --- doc/source/executors.rst | 17 +---------------- tests/unit/test_scheduler.py | 6 +++--- zuul/executor/client.py | 8 ++++---- zuul/executor/server.py | 9 +++++++-- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/doc/source/executors.rst b/doc/source/executors.rst index 5f85f5828c..f309a9c464 100644 --- a/doc/source/executors.rst +++ b/doc/source/executors.rst @@ -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. diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index eb1796663d..e402342b4a 100755 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -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) diff --git a/zuul/executor/client.py b/zuul/executor/client.py index 2e17b3eec3..aaef34e389 100644 --- a/zuul/executor/client.py +++ b/zuul/executor/client.py @@ -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) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 35bb268f2a..a4b48dbdfd 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -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))