Commit 96e0d5cc authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Explicitly pass params to deactivate_master_ip



Make the master explicitly pass the parameters to the
deactivate_master_ip RPC, and change all the call flow to use the new
interface.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 7c74bbe0
......@@ -375,16 +375,17 @@ def StartMasterDaemons(no_voting):
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown",
_BuildMasterIpHookEnv)
def DeactivateMasterIp():
def DeactivateMasterIp(master_ip, master_netmask, master_netdev):
"""Deactivate the master IP on this node.
@param master_ip: the master IP
@param master_netmask: the master IP netmask
@param master_netdev: the master network device
"""
# TODO: log and report back to the caller the error failures; we
# need to decide in which case we fail the RPC for this
# GetMasterInfo will raise an exception if not able to return data
master_netdev, master_ip, _, _, master_netmask = GetMasterInfo()
result = utils.RunCmd([constants.IP_COMMAND_PATH, "address", "del",
"%s/%s" % (master_ip, master_netmask),
"dev", master_netdev])
......
......@@ -567,7 +567,8 @@ def FinalizeClusterDestroy(master):
modify_ssh_setup = cfg.GetClusterInfo().modify_ssh_setup
runner = rpc.BootstrapRunner()
result = runner.call_node_deactivate_master_ip(master)
(_, ip, netdev, netmask, _) = cfg.GetMasterNetworkParameters()
result = runner.call_node_deactivate_master_ip(master, ip, netmask, netdev)
msg = result.fail_msg
if msg:
logging.warning("Could not disable the master IP: %s", msg)
......@@ -706,7 +707,9 @@ def MasterFailover(no_voting=False):
logging.info("Stopping the master daemon on node %s", old_master)
runner = rpc.BootstrapRunner()
result = runner.call_node_deactivate_master_ip(old_master)
(_, ip, netdev, netmask, _) = cfg.GetMasterNetworkParameters()
result = runner.call_node_deactivate_master_ip(old_master, ip, netmask,
netdev)
msg = result.fail_msg
if msg:
logging.warning("Could not disable the master IP: %s", msg)
......
......@@ -1355,12 +1355,12 @@ class LUClusterDestroy(LogicalUnit):
"""Destroys the cluster.
"""
master = self.cfg.GetMasterNode()
(master, ip, dev, netmask, _) = self.cfg.GetMasterNetworkParameters()
# Run post hooks on master node before it's removed
_RunPostHook(self, master)
result = self.rpc.call_node_deactivate_master_ip(master)
result = self.rpc.call_node_deactivate_master_ip(master, ip, netmask, dev)
result.Raise("Could not disable the master role")
return master
......@@ -3326,8 +3326,8 @@ class LUClusterRename(LogicalUnit):
new_ip = self.ip
# shutdown the master IP
(master, _, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
result = self.rpc.call_node_deactivate_master_ip(master)
(master, ip, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
result = self.rpc.call_node_deactivate_master_ip(master, ip, netmask, dev)
result.Raise("Could not disable the master role")
try:
......@@ -3700,13 +3700,13 @@ class LUClusterSetParams(LogicalUnit):
helper_os("blacklisted_os", self.op.blacklisted_os, "blacklisted")
if self.op.master_netdev:
master = self.cfg.GetMasterNode()
(master, ip, dev, netmask, _) = self.cfg.GetMasterNetworkParameters()
feedback_fn("Shutting down master ip on the current netdev (%s)" %
self.cluster.master_netdev)
result = self.rpc.call_node_deactivate_master_ip(master)
result = self.rpc.call_node_deactivate_master_ip(master, ip, netmask, dev)
result.Raise("Could not disable the master ip")
feedback_fn("Changing master_netdev from %s to %s" %
(self.cluster.master_netdev, self.op.master_netdev))
(dev, self.op.master_netdev))
self.cluster.master_netdev = self.op.master_netdev
if self.op.master_netmask:
......@@ -3902,8 +3902,8 @@ class LUClusterDeactivateMasterIp(NoHooksLU):
"""Deactivate the master IP.
"""
master = self.cfg.GetMasterNode()
self.rpc.call_node_deactivate_master_ip(master)
(master, ip, dev, netmask, _) = self.cfg.GetMasterNetworkParameters()
self.rpc.call_node_deactivate_master_ip(master, ip, netmask, dev)
def _WaitForSync(lu, instance, disks=None, oneshot=False):
......
......@@ -407,7 +407,11 @@ CALLS = {
"Activates master IP on a node"),
("node_stop_master", SINGLE, TMO_FAST, [], None,
"Deactivates master IP and stops master daemons on a node"),
("node_deactivate_master_ip", SINGLE, TMO_FAST, [], None,
("node_deactivate_master_ip", SINGLE, TMO_FAST, [
("master_ip", None, "The master IP"),
("master_netmask", None, "The master IP netmask"),
("master_netdev", None, "The master network device"),
], None,
"Deactivates master IP on a node"),
("node_change_master_netmask", SINGLE, TMO_FAST, [
("netmask", None, None),
......
......@@ -704,7 +704,7 @@ class NodeHttpServer(http.server.HttpServer):
"""Deactivate the master IP on this node.
"""
return backend.DeactivateMasterIp()
return backend.DeactivateMasterIp(params[0], params[1], params[2])
@staticmethod
def perspective_node_stop_master(params):
......
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