From caf3a6c92895d43f698cd9a6913eedc2c52534af Mon Sep 17 00:00:00 2001 From: Rob Terhaar Date: Thu, 19 Jul 2012 01:38:02 -0400 Subject: [PATCH 1/3] speed up node cleanup for big clusters --- starcluster/clustersetup.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/starcluster/clustersetup.py b/starcluster/clustersetup.py index 8a3422b3e..f73a59fd9 100644 --- a/starcluster/clustersetup.py +++ b/starcluster/clustersetup.py @@ -353,17 +353,34 @@ def run(self, nodes, master, user, user_shell, volumes): def _remove_from_etc_hosts(self, node): nodes = filter(lambda x: x.id != node.id, self.running_nodes) + master = None + for n in nodes: - n.remove_from_etc_hosts([node]) + if n.is_master(): + master = n + + master.remove_from_etc_hosts([node]) + master.master.copy_remote_file_to_nodes('/etc/hosts', nodes) def _remove_nfs_exports(self, node): self._master.stop_exporting_fs_to_nodes([node]) def _remove_from_known_hosts(self, node): nodes = filter(lambda x: x.id != node.id, self.running_nodes) + master = None + for n in nodes: - n.remove_from_known_hosts('root', [node]) - n.remove_from_known_hosts(self._user, [node]) + if n.is_master(): + master = n + + master.remove_from_known_hosts('root', [node]) + master.remove_from_known_hosts(self._user, [node]) + + targets = [posixpath.join('/root', '.ssh','known_hosts'), + posixpath.join(self._user.pw_dir, '.ssh','known_hosts'),] + + for target in targets: + master.copy_remote_file_to_nodes(target, nodes) def on_remove_node(self, node, nodes, master, user, user_shell, volumes): self._nodes = nodes From eb06262602a373f0c687258a89a5314a145ccca5 Mon Sep 17 00:00:00 2001 From: Rob Terhaar Date: Thu, 19 Jul 2012 01:49:30 -0400 Subject: [PATCH 2/3] need to work a little harder to find the user's homedir --- starcluster/clustersetup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/starcluster/clustersetup.py b/starcluster/clustersetup.py index f73a59fd9..1cf65e856 100644 --- a/starcluster/clustersetup.py +++ b/starcluster/clustersetup.py @@ -1,6 +1,7 @@ """ clustersetup.py """ +import os import posixpath from starcluster import threadpool @@ -376,8 +377,9 @@ def _remove_from_known_hosts(self, node): master.remove_from_known_hosts('root', [node]) master.remove_from_known_hosts(self._user, [node]) + user_homedir = os.path.expanduser('~' + self._user) targets = [posixpath.join('/root', '.ssh','known_hosts'), - posixpath.join(self._user.pw_dir, '.ssh','known_hosts'),] + posixpath.join(user_homedir, '.ssh','known_hosts'),] for target in targets: master.copy_remote_file_to_nodes(target, nodes) From dbbe856a973ee5dd1ff7518a895ed522c1d7bb6e Mon Sep 17 00:00:00 2001 From: Rob Terhaar Date: Thu, 19 Jul 2012 02:20:12 -0400 Subject: [PATCH 3/3] typo --- starcluster/clustersetup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starcluster/clustersetup.py b/starcluster/clustersetup.py index 1cf65e856..e209c43bb 100644 --- a/starcluster/clustersetup.py +++ b/starcluster/clustersetup.py @@ -361,7 +361,7 @@ def _remove_from_etc_hosts(self, node): master = n master.remove_from_etc_hosts([node]) - master.master.copy_remote_file_to_nodes('/etc/hosts', nodes) + master.copy_remote_file_to_nodes('/etc/hosts', nodes) def _remove_nfs_exports(self, node): self._master.stop_exporting_fs_to_nodes([node])