Update to new zuul-gearman protocol.
* Use non-Jenkins terminology "manager" rather than "master".
* Use name+number as the identifier for both stopping builds and
descriptions.
* Expect 'url' parameter instead of 'full_url'.
Change-Id: I1fe9851556618fc6d6deb8906e3f2ee41725c3ad
Reviewed-on: https://review.openstack.org/31726
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
diff --git a/doc/source/launchers.rst b/doc/source/launchers.rst
index a219936..27c8c01 100644
--- a/doc/source/launchers.rst
+++ b/doc/source/launchers.rst
@@ -170,17 +170,20 @@
immediately send a WORK_DATA packet with the following information
encoded in JSON format:
-**full_url**
- The URL with the status or results of the build. Will be used in
- the status page and the final report.
+**name**
+ The name of the job.
**number**
The build number (unique to this job).
-**master**
+**manager**
A unique identifier associated with the Gearman worker that can
abort this build. See `Stopping Builds`_ for more information.
+**url** (optional)
+ The URL with the status or results of the build. Will be used in
+ the status page and the final report.
+
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.
@@ -202,13 +205,19 @@
If Zuul needs to abort a build already in progress, it will invoke the
following function through Gearman:
- stop:MASTER_NAME
+ stop:MANAGER_NAME
-Where **MASTER_NAME** is the name of the master node supplied in the
-initial WORK_DATA packet when the job started. This is used to direct
-the stop: function invocation to the correct Gearman worker that is
-capable of stopping that particular job. The argument to the function
-will be the unique ID of the job that should be stopped.
+Where **MANAGER_NAME** is the name of the manager worker supplied in
+the initial WORK_DATA packet when the job started. This is used to
+direct the stop: function invocation to the correct Gearman worker
+that is capable of stopping that particular job. The argument to the
+function should be the following encoded in JSON format:
+
+**name**
+ The job name of the build to stop.
+
+**number**
+ The build number of the build to stop.
The original job is expected to complete with a WORK_DATA and
WORK_FAIL packet as described in `Starting Builds`_.
@@ -220,14 +229,16 @@
current state of all related builds, the job runner may optionally
implement the following Gearman function:
- set_description:MASTER_NAME
+ set_description:MANAGER_NAME
-Where **MASTER_NAME** is used as described in `Stopping Builds`_. The
-argument to the function is the following encoded in JSON format:
+Where **MANAGER_NAME** is used as described in `Stopping Builds`_.
+The argument to the function is the following encoded in JSON format:
-**unique_id**
- The unique identifier of the build whose description should be
- updated.
+**name**
+ The job name of the build to describe.
+
+**number**
+ The build number of the build to describe.
**html_description**
The description of the build in HTML format.
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 6babdc0..9a4819a 100644
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -515,9 +515,10 @@
def run(self):
data = {
- 'full_url': 'https://server/job/%s/%s/' % (self.name, self.number),
+ 'url': 'https://server/job/%s/%s/' % (self.name, self.number),
+ 'name': self.name,
'number': self.number,
- 'master': self.worker.worker_id,
+ 'manager': self.worker.worker_id,
}
self.job.sendWorkData(json.dumps(data))
@@ -594,9 +595,11 @@
def handleStop(self, job, name):
self.log.debug("handle stop")
- unique = job.arguments
+ parameters = json.loads(job.arguments)
+ name = parameters['name']
+ number = parameters['number']
for build in self.running_builds:
- if build.unique == unique:
+ if build.name == name and build.number == number:
build.aborted = True
build.release()
job.sendWorkComplete()
@@ -606,15 +609,16 @@
def handleSetDescription(self, job, name):
self.log.debug("handle set description")
parameters = json.loads(job.arguments)
- unique = parameters['unique_id']
+ name = parameters['name']
+ number = parameters['number']
descr = parameters['html_description']
for build in self.running_builds:
- if build.unique == unique:
+ if build.name == name and build.number == number:
build.description = descr
job.sendWorkComplete()
return
for build in self.build_history:
- if build.uuid == unique:
+ if build.name == name and build.number == number:
build.description = descr
job.sendWorkComplete()
return
diff --git a/zuul/launcher/gearman.py b/zuul/launcher/gearman.py
index 5471efb..35dc081 100644
--- a/zuul/launcher/gearman.py
+++ b/zuul/launcher/gearman.py
@@ -308,9 +308,9 @@
self.log.debug("Found build %s" % build)
if not build.number:
self.log.info("Build %s started" % job)
- build.url = data.get('full_url')
+ build.url = data.get('url')
build.number = data.get('number')
- build.__gearman_master = data.get('master')
+ build.__gearman_manager = data.get('manager')
self.sched.onBuildStarted(build)
build.fraction_complete = job.fraction_complete
else:
@@ -341,9 +341,10 @@
def cancelRunningBuild(self, build):
stop_uuid = str(uuid4().hex)
- stop_job = gear.Job("stop:%s" % build.__gearman_master,
- build.uuid,
- unique=stop_uuid)
+ data = dict(name=build.job.name,
+ number=build.number)
+ stop_job = gear.Job("stop:%s" % build.__gearman_manager,
+ json.dumps(data), unique=stop_uuid)
self.meta_jobs[stop_uuid] = stop_job
self.log.debug("Submitting stop job: %s", stop_job)
self.gearman.submitJob(stop_job)
@@ -351,7 +352,7 @@
def setBuildDescription(self, build, desc):
try:
- name = "set_description:%s" % build.__gearman_master
+ name = "set_description:%s" % build.__gearman_manager
except AttributeError:
# We haven't yet received the first data packet that tells
# us where the job is running.
@@ -361,7 +362,8 @@
return False
desc_uuid = str(uuid4().hex)
- data = dict(unique_id=build.uuid,
+ data = dict(name=build.job.name,
+ number=build.number,
html_description=desc)
desc_job = gear.Job(name, json.dumps(data), unique=desc_uuid)
self.meta_jobs[desc_uuid] = desc_job