Commit 3b6b6129 authored by Michael Hanselmann's avatar Michael Hanselmann

Wait for master to become available on initialization

This is analogue to the existing check for a responsive node daemon.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 952d7515
......@@ -42,10 +42,15 @@ from ganeti import hypervisor
from ganeti import bdev
from ganeti import netutils
from ganeti import backend
from ganeti import luxi
# ec_id for InitConfig's temporary reservation manager
_INITCONF_ECID = "initconfig-ecid"
#: After how many seconds daemon must be responsive
_DAEMON_READY_TIMEOUT = 10.0
def _InitSSHSetup():
"""Setup the SSH configuration for the cluster.
......@@ -181,10 +186,30 @@ def _WaitForNodeDaemon(node_name):
raise utils.RetryAgain()
try:
utils.Retry(_CheckNodeDaemon, 1.0, 10.0)
utils.Retry(_CheckNodeDaemon, 1.0, _DAEMON_READY_TIMEOUT)
except utils.RetryTimeout:
raise errors.OpExecError("Node daemon on %s didn't answer queries within"
" 10 seconds" % node_name)
" %s seconds" % (node_name, _DAEMON_READY_TIMEOUT))
def _WaitForMasterDaemon():
"""Wait for master daemon to become responsive.
"""
def _CheckMasterDaemon():
try:
cl = luxi.Client()
(cluster_name, ) = cl.QueryConfigValues(["cluster_name"])
except Exception:
raise utils.RetryAgain()
logging.debug("Received cluster name %s from master", cluster_name)
try:
utils.Retry(_CheckMasterDaemon, 1.0, _DAEMON_READY_TIMEOUT)
except utils.RetryTimeout:
raise errors.OpExecError("Master daemon didn't answer queries within"
" %s seconds" % _DAEMON_READY_TIMEOUT)
def _InitFileStorage(file_storage_dir):
......@@ -418,6 +443,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
" had exitcode %s and error %s" %
(result.cmd, result.exit_code, result.output))
_WaitForMasterDaemon()
def InitConfig(version, cluster_config, master_node_config,
cfg_file=constants.CLUSTER_CONF_FILE):
......
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