You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/07/23 06:51:42 UTC

[6/7] git commit: Fixed Jenkins to not launch slaves when the scheduler is not running.

Fixed Jenkins to not launch slaves when the scheduler is not running.

Review: https://reviews.apache.org/r/12800


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c1ede593
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c1ede593
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c1ede593

Branch: refs/heads/master
Commit: c1ede5934849fb06c3c8e22a5b329b3414f3930f
Parents: 14283f1
Author: Vinod Kone <vi...@twitter.com>
Authored: Sun Jul 21 01:36:53 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Mon Jul 22 21:50:45 2013 -0700

----------------------------------------------------------------------
 .../jenkinsci/plugins/mesos/MesosComputerLauncher.java   | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c1ede593/jenkins/src/main/java/org/jenkinsci/plugins/mesos/MesosComputerLauncher.java
----------------------------------------------------------------------
diff --git a/jenkins/src/main/java/org/jenkinsci/plugins/mesos/MesosComputerLauncher.java b/jenkins/src/main/java/org/jenkinsci/plugins/mesos/MesosComputerLauncher.java
index dc3bf8e..ca66ab8 100644
--- a/jenkins/src/main/java/org/jenkinsci/plugins/mesos/MesosComputerLauncher.java
+++ b/jenkins/src/main/java/org/jenkinsci/plugins/mesos/MesosComputerLauncher.java
@@ -43,6 +43,17 @@ public class MesosComputerLauncher extends ComputerLauncher {
     // Get a handle to mesos.
     Mesos mesos = Mesos.getInstance();
 
+    // If Jenkins scheduler is not running, terminate the node.
+    // This might happen if the computer was offline when Jenkins was shutdown.
+    // Since Jenkins persists its state, it tries to launch offline slaves when
+    // it restarts.
+    if (!mesos.isSchedulerRunning()) {
+      LOGGER.warning("Not launching " + name +
+                     " because the Mesos Jenkins scheduler is not running");
+      computer.getNode().terminate();
+      return;
+    }
+
     // Create the request.
     int numExecutors = computer.getNode().getNumExecutors();
     Mesos.SlaveRequest request = new Mesos.SlaveRequest(new JenkinsSlave(name), numExecutors);