From 6819dc4990bb4b072a1ca0a16cba684c5279de37 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 9 Mar 2010 13:39:29 +0100 Subject: [PATCH] Fix redistribute config and offline nodes We need to manually filter out offline nodes before using rpc.call_upload_file and rpc.call_write_ssconf_files, since these method are static (they work without a ConfigWriter instance) and thus do not know which nodes are offline and which are not). Note that we add a new ConfigWriter._UnlockedGetOnlineNodeList() method rather than hardcoding the filtering of online nodes in _WriteConfig. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/cmdlib.py | 2 +- lib/config.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index da13bd50b..87cbf86a4 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2155,7 +2155,7 @@ def _RedistributeAncillaryFiles(lu, additional_nodes=None): """ # 1. Gather target nodes myself = lu.cfg.GetNodeInfo(lu.cfg.GetMasterNode()) - dist_nodes = lu.cfg.GetNodeList() + dist_nodes = lu.cfg.GetOnlineNodeList() if additional_nodes is not None: dist_nodes.extend(additional_nodes) if myself.name in dist_nodes: diff --git a/lib/config.py b/lib/config.py index d61f8a57d..3382907f6 100644 --- a/lib/config.py +++ b/lib/config.py @@ -1056,8 +1056,7 @@ class ConfigWriter: """ return self._UnlockedGetNodeList() - @locking.ssynchronized(_config_lock, shared=1) - def GetOnlineNodeList(self): + def _UnlockedGetOnlineNodeList(self): """Return the list of nodes which are online. """ @@ -1065,6 +1064,13 @@ class ConfigWriter: for node in self._UnlockedGetNodeList()] return [node.name for node in all_nodes if not node.offline] + @locking.ssynchronized(_config_lock, shared=1) + def GetOnlineNodeList(self): + """Return the list of nodes which are online. + + """ + return self._UnlockedGetOnlineNodeList() + @locking.ssynchronized(_config_lock, shared=1) def GetAllNodesInfo(self): """Get the configuration of all nodes. @@ -1293,7 +1299,7 @@ class ConfigWriter: if self._last_cluster_serial < self._config_data.cluster.serial_no: if not self._offline: result = rpc.RpcRunner.call_write_ssconf_files( - self._UnlockedGetNodeList(), + self._UnlockedGetOnlineNodeList(), self._UnlockedGetSsconfValues()) for nname, nresu in result.items(): -- GitLab