Make isJobRegistered for gearman optional

With openstack-infra we actually validate our jobs exist before
merging them into our zuul configuration. As a result, the
registration check in zuul is redundant.  So provide a way for the
check to be enable / disabled.

Change-Id: I06f2221770e04f958ce7ac4cfe8d5d92d7164cac
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-06-08 16:43:55 -04:00
parent 3e205c2164
commit 9208dc1c0a
No known key found for this signature in database
GPG Key ID: 611A80832067AF38
2 changed files with 13 additions and 2 deletions

View File

@ -49,6 +49,11 @@ gearman
Port on which the Gearman server is listening.
``port=4730``
**check_job_registration**
Check to see if job is registered with Gearman or not. When True
a build result of NOT_REGISTERED will be return if job is not found.
``check_job_registration=True``
gearman_server
""""""""""""""

View File

@ -164,6 +164,11 @@ class Gearman(object):
port = config.get('gearman', 'port')
else:
port = 4730
if config.has_option('gearman', 'check_job_registration'):
self.job_registration = config.getboolean(
'gearman', 'check_job_registration')
else:
self.job_registration = True
self.gearman = ZuulGearmanClient(self)
self.gearman.addServer(server, port)
@ -351,7 +356,8 @@ class Gearman(object):
build.__gearman_job = gearman_job
self.builds[uuid] = build
if not self.isJobRegistered(gearman_job.name):
if self.job_registration and not self.isJobRegistered(
gearman_job.name):
self.log.error("Job %s is not registered with Gearman" %
gearman_job)
self.onBuildCompleted(gearman_job, 'NOT_REGISTERED')
@ -502,7 +508,7 @@ class Gearman(object):
# us where the job is running.
return False
if not self.isJobRegistered(name):
if self.job_registration and not self.isJobRegistered(name):
return False
desc_uuid = str(uuid4().hex)