Commit fc4bfcca authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Expose warnings during master-failover



During master failover, there are some situations where problems
occur but the best thing to do is to carry on. These problems
are logged using the usual mechanism. However, a user usually
does not look into the log file unless the command executed
returns some hints that something might have gone wrong.
So also return the warnings as an additional return value,
allowing the CLI to report properly.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent db0d8a82
......@@ -945,6 +945,7 @@ def MasterFailover(no_voting=False):
@param no_voting: force the operation without remote nodes agreement
(dangerous)
@returns: the pair of an exit code and warnings to display
"""
sstore = ssconf.SimpleStore()
......@@ -985,6 +986,7 @@ def MasterFailover(no_voting=False):
# end checks
rcode = 0
warnings = []
logging.info("Setting master to %s, old master: %s", new_master, old_master)
......@@ -1031,13 +1033,17 @@ def MasterFailover(no_voting=False):
msg = result.fail_msg
if msg:
logging.warning("Could not disable the master IP: %s", msg)
warning = "Could not disable the master IP: %s" % (msg,)
logging.warning("%s", warning)
warnings.append(warning)
result = runner.call_node_stop_master(old_master)
msg = result.fail_msg
if msg:
logging.error("Could not disable the master role on the old master"
" %s, please disable manually: %s", old_master, msg)
warning = ("Could not disable the master role on the old master"
" %s, please disable manually: %s" % (old_master, msg))
logging.error("%s", warning)
warnings.append(warning)
logging.info("Checking master IP non-reachability...")
......@@ -1052,9 +1058,11 @@ def MasterFailover(no_voting=False):
try:
utils.Retry(_check_ip, (1, 1.5, 5), total_timeout)
except utils.RetryTimeout:
logging.warning("The master IP is still reachable after %s seconds,"
" continuing but activating the master on the current"
" node will probably fail", total_timeout)
warning = ("The master IP is still reachable after %s seconds,"
" continuing but activating the master on the current"
" node will probably fail" % total_timeout)
logging.warning("%s", warning)
warnings.append(warning)
if jstore.CheckDrainFlag():
logging.info("Undraining job queue")
......@@ -1071,7 +1079,7 @@ def MasterFailover(no_voting=False):
rcode = 1
logging.info("Master failed over from %s to %s", old_master, new_master)
return rcode
return rcode, warnings
def GetMaster():
......
......@@ -821,7 +821,10 @@ def MasterFailover(opts, args):
if not AskUser(usertext):
return 1
return bootstrap.MasterFailover(no_voting=opts.no_voting)
rvlaue, msgs = bootstrap.MasterFailover(no_voting=opts.no_voting)
for msg in msgs:
ToStderr(msg)
return rvlaue
def MasterPing(opts, args):
......
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