Commit cb6a0296 authored by Iustin Pop's avatar Iustin Pop
Browse files

RPC call_node_info: change protocol



Currently, the call_node_info RPC does always check both the VG free
space and the hypervisor information. However, in ⅔ of the uses, we only
care about one or the other. Therefore, we change it so that if any of
the passed parameters is None, we don't perform the respective check. We
also modify its callers to only pass in what they need.

This also helps if the "default" hypervisor is broken and we want to
create an instance for another hypervisor.

With this patch, the duration of this rpc changes from 500ms to 90ms for
a normal LVM+Xen PVM node, when we only require the LVM data; when we
only require the hypervisor data, it doesn't change (as the “xm list”
time is dominant).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 84ce674e
......@@ -440,19 +440,20 @@ def GetNodeInfo(vgname, hypervisor_type):
"""
outputarray = {}
vginfo = bdev.LogicalVolume.GetVGInfo([vgname])
vg_free = vg_size = None
if vginfo:
vg_free = int(round(vginfo[0][0], 0))
vg_size = int(round(vginfo[0][1], 0))
outputarray['vg_size'] = vg_size
outputarray['vg_free'] = vg_free
hyper = hypervisor.GetHypervisor(hypervisor_type)
hyp_info = hyper.GetNodeInfo()
if hyp_info is not None:
outputarray.update(hyp_info)
if vgname is not None:
vginfo = bdev.LogicalVolume.GetVGInfo([vgname])
vg_free = vg_size = None
if vginfo:
vg_free = int(round(vginfo[0][0], 0))
vg_size = int(round(vginfo[0][1], 0))
outputarray['vg_size'] = vg_size
outputarray['vg_free'] = vg_free
if hypervisor_type is not None:
hyper = hypervisor.GetHypervisor(hypervisor_type)
hyp_info = hyper.GetNodeInfo()
if hyp_info is not None:
outputarray.update(hyp_info)
outputarray["bootid"] = utils.ReadFile(_BOOT_ID_PATH, size=128).rstrip("\n")
......
......@@ -4690,7 +4690,7 @@ def _CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name):
we cannot check the node
"""
nodeinfo = lu.rpc.call_node_info([node], lu.cfg.GetVGName(), hypervisor_name)
nodeinfo = lu.rpc.call_node_info([node], None, hypervisor_name)
nodeinfo[node].Raise("Can't get data from node %s" % node,
prereq=True, ecode=errors.ECODE_ENVIRON)
free_mem = nodeinfo[node].payload.get('memory_free', None)
......@@ -4749,8 +4749,7 @@ def _CheckNodesFreeDiskOnVG(lu, nodenames, vg, requested):
or we cannot check the node
"""
nodeinfo = lu.rpc.call_node_info(nodenames, vg,
lu.cfg.GetHypervisorType())
nodeinfo = lu.rpc.call_node_info(nodenames, vg, None)
for node in nodenames:
info = nodeinfo[node]
info.Raise("Cannot get current information from node %s" % node,
......@@ -9314,7 +9313,7 @@ class LUSetInstanceParams(LogicalUnit):
mem_check_list.extend(instance.secondary_nodes)
instance_info = self.rpc.call_instance_info(pnode, instance.name,
instance.hypervisor)
nodeinfo = self.rpc.call_node_info(mem_check_list, self.cfg.GetVGName(),
nodeinfo = self.rpc.call_node_info(mem_check_list, None,
instance.hypervisor)
pninfo = nodeinfo[pnode]
msg = pninfo.fail_msg
......
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