Commit 9e6014b9 authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Improve error handling in netmask change



- check if the master IP with the old netmask is up before attempting to
  change the netmask (to avoid a failed change netmask resulting in an
  undesired activation of the master IP);
- improve error messages of the backend function;
- in case of error, report the problem but otherwise change the cluster
  master_netmask parameter;
- remove duplicate error feedback.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 0007f3ab
......@@ -428,19 +428,23 @@ def ChangeMasterNetmask(old_netmask, netmask, master_ip, master_netdev):
if old_netmask == netmask:
return
if not netutils.IPAddress.Own(master_ip):
_Fail("The master IP address is not up, not attempting to change its"
" netmask")
result = utils.RunCmd([constants.IP_COMMAND_PATH, "address", "add",
"%s/%s" % (master_ip, netmask),
"dev", master_netdev, "label",
"%s:0" % master_netdev])
if result.failed:
_Fail("Could not change the master IP netmask")
_Fail("Could not set the new netmask on the master IP address")
result = utils.RunCmd([constants.IP_COMMAND_PATH, "address", "del",
"%s/%s" % (master_ip, old_netmask),
"dev", master_netdev, "label",
"%s:0" % master_netdev])
if result.failed:
_Fail("Could not change the master IP netmask")
_Fail("Could not bring down the master IP address with the old netmask")
def EtcHostsModify(mode, host, ip):
......
......@@ -3727,10 +3727,9 @@ class LUClusterSetParams(LogicalUnit):
master_params.netdev)
if result.fail_msg:
msg = "Could not change the master IP netmask: %s" % result.fail_msg
self.LogWarning(msg)
feedback_fn(msg)
else:
self.cluster.master_netmask = self.op.master_netmask
self.cluster.master_netmask = self.op.master_netmask
self.cfg.Update(self.cluster, feedback_fn)
......
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