From fa5f0834ff991e13a85cea6624a144432a328fea Mon Sep 17 00:00:00 2001 From: Khai Do Date: Tue, 21 Oct 2014 12:47:29 -0700 Subject: [PATCH] Fix job result not being sent back to gearman client This fixes a bug that causes the result object to be left off of the returned data packet after a job finishes executing. This only occurs when the job request sets the node to temporary offline (i.e. "OFFLINE_NODE_WHEN_COMPLETE":"true"). The problem is that the ComputerListener.onTemporaryOffline event was stopping the gearman worker which causes a disconnect to the gearman client thus not being able to send back the results for the job. The worker should not stop on a temporary offline, only on disconnect and delete of a node. The fix is to only re-register the gearman functions instead of stopping the workers on a temporary online/offline of a node. Change-Id: Icf672acf059d6cb0e16a6685d637824c678ea5be --- .../plugins/gearman/ComputerListenerImpl.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java b/src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java index 08e07a9..e117bac 100644 --- a/src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java +++ b/src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java @@ -109,8 +109,8 @@ public class ComputerListenerImpl extends ComputerListener { return; } - // stop worker when jenkins slave is set to offline - GearmanProxy.getInstance().stop(c); + // re-register gearman functions on node status change, + GearmanProxy.getInstance().registerJobs(); } @Override @@ -123,16 +123,8 @@ public class ComputerListenerImpl extends ComputerListener { return; } - GearmanProxy gp = GearmanProxy.getInstance(); - /* - * Spawn management executor worker if one doesn't exist yet. - * This worker does not need any executors. It only needs - * to work with gearman. - */ - gp.createManagementWorker(); - - // on brining a slave back online - gp.createExecutorWorkersOnNode(c); + // re-register gearman functions on node status change, + GearmanProxy.getInstance().registerJobs(); } }