LGTM, thanks On Thu, 2 Apr 2015 at 12:30 'Klaus Aehlig' via ganeti-devel < [email protected]> wrote:
> 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: Klaus Aehlig <[email protected]> > --- > lib/bootstrap.py | 22 +++++++++++++++------- > lib/client/gnt_cluster.py | 5 ++++- > 2 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/lib/bootstrap.py b/lib/bootstrap.py > index 04ee58f..e556521 100644 > --- a/lib/bootstrap.py > +++ b/lib/bootstrap.py > @@ -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(): > diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py > index 4d5af83..84cd0f8 100644 > --- a/lib/client/gnt_cluster.py > +++ b/lib/client/gnt_cluster.py > @@ -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): > -- > 2.2.0.rc0.207.ga3a616c > >
