From ee513a666c9c2c5fa6c2e72fb62c9416a95022f3 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 8 Dec 2008 17:45:56 +0000
Subject: [PATCH] Fix _AdjustCandidatePool

Currently the ConfigWriter.MaintainCandidatePool returns node names, and
_AdjustCandidatePool uses them as such, but then it passes these to
context.ReaddNode which in turn passes them to jqueue.JobQueue.AddNode which
uses them as objects.Node instances.

Since this is currently the only usage, we change return type from
ConfigWriter.MaintainCandidatePool to be objects and adjust the logging of
their names, so that the auto-adjusement works.

Reviewed-by: ultrotter
---
 lib/cmdlib.py | 2 +-
 lib/config.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 0d119b97b..8c62c2510 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -533,7 +533,7 @@ def _AdjustCandidatePool(lu):
   mod_list = lu.cfg.MaintainCandidatePool()
   if mod_list:
     lu.LogInfo("Promoted nodes to master candidate role: %s",
-               ", ".join(mod_list))
+               ", ".join(node.name for node in mod_list))
     for name in mod_list:
       lu.context.ReaddNode(name)
   mc_now, mc_max = lu.cfg.GetMasterCandidateStats()
diff --git a/lib/config.py b/lib/config.py
index 0263824a7..b74d68d64 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -809,7 +809,7 @@ class ConfigWriter:
     """Try to grow the candidate pool to the desired size.
 
     @rtype: list
-    @return: list with the adjusted node names
+    @return: list with the adjusted nodes (L{objects.Node} instances)
 
     """
     mc_now, mc_max = self._UnlockedGetMasterCandidateStats()
@@ -823,7 +823,7 @@ class ConfigWriter:
         node = self._config_data.nodes[name]
         if node.master_candidate or node.offline:
           continue
-        mod_list.append(node.name)
+        mod_list.append(node)
         node.master_candidate = True
         node.serial_no += 1
         mc_now += 1
-- 
GitLab