From 6a5b8b4be62fce6794889c36f3b1af5bfa05bd54 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 2 Dec 2008 05:05:12 +0000 Subject: [PATCH] Restrict config replication to master candidates This patch restricts the config data replication to master candidates only. Reviewed-by: imsnah --- lib/config.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/config.py b/lib/config.py index 0f4749d35..f82b5247c 100644 --- a/lib/config.py +++ b/lib/config.py @@ -813,23 +813,26 @@ class ConfigWriter: if self._offline: return True bad = False - nodelist = self._UnlockedGetNodeList() - myhostname = self._my_hostname - try: - nodelist.remove(myhostname) - except ValueError: - pass + node_list = [] + addr_list = [] + myhostname = self._my_hostname # we can skip checking whether _UnlockedGetNodeInfo returns None # since the node list comes from _UnlocketGetNodeList, and we are # called with the lock held, so no modifications should take place # in between - address_list = [self._UnlockedGetNodeInfo(name).primary_ip - for name in nodelist] + for node_name in self._UnlockedGetNodeList(): + if node_name == myhostname: + continue + node_info = self._UnlockedGetNodeInfo(node_name) + if not node_info.master_candidate: + continue + node_list.append(node_info.name) + addr_list.append(node_info.primary_ip) - result = rpc.RpcRunner.call_upload_file(nodelist, self._cfg_file, - address_list=address_list) - for node in nodelist: + result = rpc.RpcRunner.call_upload_file(node_list, self._cfg_file, + address_list=addr_list) + for node in node_list: if not result[node]: logging.error("copy of file %s to node %s failed", self._cfg_file, node) -- GitLab