Commit 8864d152 authored by Guido Trotter's avatar Guido Trotter
Browse files

Revert "Only merge nodes that are known to not be offline"

This reverts commit 288f240f

.

That commit was buggy at various levels:
  - broke ssh access to the second cluster, making cluster-merge
    unusable (unless ssh key were previously setup?)
  - filtered away offline nodes from being added to the cluster config
    (wrong, they should be kept, as offline)
  - broke commit-check

The previous commit makes the code work again with what this commit
tried to achieve.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 8697f0fa
......@@ -164,8 +164,8 @@ class Merger(object):
self.merger_data.append(MergerData(cluster, key_path, nodes, instances))
def _PrepareAuthorizedKeys(self, merge_data, node):
"""Prepare the authorized_keys on merging nodes.
def _PrepareAuthorizedKeys(self):
"""Prepare the authorized_keys on every merging node.
This method add our public key to remotes authorized_key for further
communication.
......@@ -174,15 +174,17 @@ class Merger(object):
(_, pub_key_file, auth_keys) = ssh.GetUserFiles("root")
pub_key = utils.ReadFile(pub_key_file)
result = self._RunCmd(node, ("cat >> %s << '!EOF.'\n%s!EOF.\n" %
(auth_keys, pub_key)),
private_key=merge_data.key_path)
for data in self.merger_data:
for node in data.nodes:
result = self._RunCmd(node, ("cat >> %s << '!EOF.'\n%s!EOF.\n" %
(auth_keys, pub_key)),
private_key=data.key_path)
if result.failed:
raise errors.RemoteError("Unable to add our public key to %s in %s."
" Fail reason: %s; output: %s" %
(node, data.cluster, result.fail_reason,
result.output))
if result.failed:
raise errors.RemoteError("Unable to add our public key to %s in %s."
" Fail reason: %s; output: %s" %
(node, data.cluster, result.fail_reason,
result.output))
def _RunCmd(self, hostname, command, user="root", use_cluster_key=False,
strict_host_check=False, private_key=None, batch=True,
......@@ -284,9 +286,7 @@ class Merger(object):
for node in other_config.GetNodeList():
node_info = other_config.GetNodeInfo(node)
if not node_info.offline:
self._PrepareAuthorizedKeys(data, node_info.name)
my_config.AddNode(node_info, _CLUSTERMERGE_ECID + str(fake_ec_id))
my_config.AddNode(node_info, _CLUSTERMERGE_ECID + str(fake_ec_id))
fake_ec_id += 1
for instance in other_config.GetInstanceList():
......@@ -452,6 +452,11 @@ class Merger(object):
logging.info("Pre cluster verification")
self._VerifyCluster()
logging.info("Prepare authorized_keys")
rbsteps.append("Remove our key from authorized_keys on nodes:"
" %(nodes)s")
self._PrepareAuthorizedKeys()
rbsteps.append("Start all instances again on the merging"
" clusters: %(clusters)s")
logging.info("Stopping merging instances (takes a while)")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment