From cb6a02965cd77d73a75be682973956c871d1bf1a Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 26 Nov 2010 18:42:39 +0000 Subject: [PATCH] RPC call_node_info: change protocol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 27 ++++++++++++++------------- lib/cmdlib.py | 7 +++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 1e5afa026..479b0c289 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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") diff --git a/lib/cmdlib.py b/lib/cmdlib.py index b9402d96c..b4885ced8 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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 -- GitLab