Restrict job propagation to master candidates only
authorIustin Pop <iustin@google.com>
Tue, 2 Dec 2008 05:05:25 +0000 (05:05 +0000)
committerIustin Pop <iustin@google.com>
Tue, 2 Dec 2008 05:05:25 +0000 (05:05 +0000)
This patch restricts the job propagation to master candidates only, by
not registering non-candidates in the job queue node lists.

Note that we do intentionally purge the job queue if a node is toggled
to non-master status.

Reviewed-by: imsnah

lib/jqueue.py

index 9fb6f78..b3c7dbb 100644 (file)
@@ -522,7 +522,8 @@ class JobQueue(object):
 
     # Get initial list of nodes
     self._nodes = dict((n.name, n.primary_ip)
-                       for n in self.context.cfg.GetAllNodesInfo().values())
+                       for n in self.context.cfg.GetAllNodesInfo().values()
+                       if n.master_candidate)
 
     # Remove master node
     try:
@@ -596,6 +597,12 @@ class JobQueue(object):
     # Clean queue directory on added node
     rpc.RpcRunner.call_jobqueue_purge(node_name)
 
+    if not node.master_candidate:
+      # remove if existing, ignoring errors
+      self._nodes.pop(node_name, None)
+      # and skip the replication of the job ids
+      return
+
     # Upload the whole queue excluding archived jobs
     files = [self._GetJobPath(job_id) for job_id in self._GetJobIDsUnlocked()]