From 93b19295f58c5419d9cfcdbb4eb5ef8e7bd0b83a Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 20 Sep 2012 18:52:49 +0200
Subject: [PATCH] bootstrap.SetupNodeDaemon: Stop hardcoding bind address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit b43dcc5a11 added support for IPv6. To have the node daemon bind
to an IPv6 address on startup it changed the code to pass a static bind
address (0.0.0.0 or ::0). If a user had configured another bind address
using /etc/default/ganeti, that address would not be used until the
daemons were restarted.

By copying ssconf files before attempting to start the daemons we can
ensure that the built-in IP family detection in daemon.py works.

This fixes issue 267.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/bootstrap.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index 1c6c5f687..6470f6ede 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -656,14 +656,11 @@ def SetupNodeDaemon(cluster_name, node, ssh_key_check):
   @param ssh_key_check: whether to do a strict key check
 
   """
-  family = ssconf.SimpleStore().GetPrimaryIPFamily()
+  sstore = ssconf.SimpleStore()
+  family = sstore.GetPrimaryIPFamily()
   sshrunner = ssh.SshRunner(cluster_name,
                             ipv6=(family == netutils.IP6Address.family))
 
-  bind_address = constants.IP4_ADDRESS_ANY
-  if family == netutils.IP6Address.family:
-    bind_address = constants.IP6_ADDRESS_ANY
-
   # set up inter-node password and certificate and restarts the node daemon
   # and then connect with ssh to set password and start ganeti-noded
   # note that all the below variables are sanitized at this point,
@@ -673,9 +670,10 @@ def SetupNodeDaemon(cluster_name, node, ssh_key_check):
   sshrunner.CopyFileToNode(node, pathutils.SPICE_CERT_FILE)
   sshrunner.CopyFileToNode(node, pathutils.SPICE_CACERT_FILE)
   sshrunner.CopyFileToNode(node, pathutils.CONFD_HMAC_KEY)
-  mycommand = ("%s stop-all; %s start %s -b %s" %
-               (pathutils.DAEMON_UTIL, pathutils.DAEMON_UTIL, constants.NODED,
-                utils.ShellQuote(bind_address)))
+  for filename in sstore.GetFileList():
+    sshrunner.CopyFileToNode(node, filename)
+  mycommand = ("%s stop-all; %s start %s" %
+               (pathutils.DAEMON_UTIL, pathutils.DAEMON_UTIL, constants.NODED))
 
   result = sshrunner.Run(node, "root", mycommand, batch=False,
                          ask_key=ssh_key_check,
-- 
GitLab