Handle failed jobs with no results.

If we get a WORK_FAIL or WORK_EXCEPTION with no preceding WORK_DATA
packet with a result, record the result as LOST.

This can happen if Jenkins encounters an exception while running
the job.

Change-Id: I159248e228af4e67ba6c88282346f366592e0d37
Reviewed-on: https://review.openstack.org/32814
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/zuul/launcher/gearman.py b/zuul/launcher/gearman.py
index 5651462..26dd316 100644
--- a/zuul/launcher/gearman.py
+++ b/zuul/launcher/gearman.py
@@ -72,6 +72,11 @@
         self.__zuul_gearman.onBuildCompleted(job)
         return job
 
+    def handleWorkException(self, packet):
+        job = super(ZuulGearmanClient, self).handleWorkException(packet)
+        self.__zuul_gearman.onBuildCompleted(job)
+        return job
+
     def handleWorkStatus(self, packet):
         job = super(ZuulGearmanClient, self).handleWorkStatus(packet)
         self.__zuul_gearman.onWorkStatus(job)
@@ -336,6 +341,8 @@
             if result is None:
                 data = getJobData(job)
                 result = data.get('result')
+            if result is None:
+                result = 'LOST'
             self.log.info("Build %s complete, result %s" %
                           (job, result))
             build.result = result