From 9f1245869b3060453805a8b242be8ae2abc3a129 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 26 Feb 2014 10:02:22 -0800 Subject: [PATCH] Handle builds without gearman jobs Zuul creates fake Build objects for jobs that it skips due to merge conflicts and other such situations. If Zuul decides to cancel such a build, we should handle it gracefully instead of throwing an exception. Also log received gearman job handles to better correlate builds with gearman debug logs. Change-Id: I1cd14c8249ac4c68e797430b2b4941f2eeee2acf --- zuul/launcher/gearman.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zuul/launcher/gearman.py b/zuul/launcher/gearman.py index 3a690dc1a2..0e248af493 100644 --- a/zuul/launcher/gearman.py +++ b/zuul/launcher/gearman.py @@ -321,12 +321,21 @@ class Gearman(object): gearman_job) self.onBuildCompleted(gearman_job, 'NO_HANDLE') + self.log.debug("Received handle %s for %s" % (gearman_job.handle, + build)) + return build def cancel(self, build): self.log.info("Cancel build %s for job %s" % (build, build.job)) build.canceled = True + try: + job = build.__gearman_job # noqa + except AttributeError: + self.log.debug("Build %s has no associated gearman job" % build) + return + if build.number is not None: self.log.debug("Build %s has already started" % build) self.cancelRunningBuild(build)