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

IAllocator: fix breakage for non-vm_capable nodes



Currently, the IAllocator doesn't know that non-vm_capable nodes
should not be queried for hypervisor/instance information.

This patch updates the node data computation to generate basic info,
but not the runtime data for such nodes. Furthermore, the
documentation is updated to note that such nodes will node have
runtime data.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent abd42b0a
...@@ -246,10 +246,10 @@ nodes ...@@ -246,10 +246,10 @@ nodes
or ``offline`` flags set. More details about these of node status or ``offline`` flags set. More details about these of node status
flags is available in the manpage :manpage:`ganeti(7)`. flags is available in the manpage :manpage:`ganeti(7)`.
.. [*] Note that no run-time data is present for offline or drained .. [*] Note that no run-time data is present for offline, drained or
nodes; this means the tags total_memory, reserved_memory, non-vm_capable nodes; this means the tags total_memory,
free_memory, total_disk, free_disk, total_cpus, i_pri_memory and reserved_memory, free_memory, total_disk, free_disk, total_cpus,
i_pri_up memory will be absent i_pri_memory and i_pri_up memory will be absent
Response message Response message
......
# #
# #
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc. # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -10640,11 +10640,12 @@ class IAllocator(object): ...@@ -10640,11 +10640,12 @@ class IAllocator(object):
"enabled_hypervisors": list(cluster_info.enabled_hypervisors), "enabled_hypervisors": list(cluster_info.enabled_hypervisors),
# we don't have job IDs # we don't have job IDs
} }
ninfo = cfg.GetAllNodesInfo()
iinfo = cfg.GetAllInstancesInfo().values() iinfo = cfg.GetAllInstancesInfo().values()
i_list = [(inst, cluster_info.FillBE(inst)) for inst in iinfo] i_list = [(inst, cluster_info.FillBE(inst)) for inst in iinfo]
# node data # node data
node_list = cfg.GetNodeList() node_list = [n.name for n in ninfo.values() if n.vm_capable]
if self.mode == constants.IALLOCATOR_MODE_ALLOC: if self.mode == constants.IALLOCATOR_MODE_ALLOC:
hypervisor_name = self.hypervisor hypervisor_name = self.hypervisor
...@@ -10661,7 +10662,11 @@ class IAllocator(object): ...@@ -10661,7 +10662,11 @@ class IAllocator(object):
data["nodegroups"] = self._ComputeNodeGroupData(cfg) data["nodegroups"] = self._ComputeNodeGroupData(cfg)
data["nodes"] = self._ComputeNodeData(cfg, node_data, node_iinfo, i_list) config_ndata = self._ComputeBasicNodeData(ninfo)
data["nodes"] = self._ComputeDynamicNodeData(ninfo, node_data, node_iinfo,
i_list, config_ndata)
assert len(data["nodes"]) == len(ninfo), \
"Incomplete node data computed"
data["instances"] = self._ComputeInstanceData(cluster_info, i_list) data["instances"] = self._ComputeInstanceData(cluster_info, i_list)
...@@ -10681,14 +10686,16 @@ class IAllocator(object): ...@@ -10681,14 +10686,16 @@ class IAllocator(object):
return ng return ng
@staticmethod @staticmethod
def _ComputeNodeData(cfg, node_data, node_iinfo, i_list): def _ComputeBasicNodeData(node_cfg):
"""Compute global node data. """Compute global node data.
@rtype: dict
@returns: a dict of name: (node dict, node config)
""" """
node_results = {} node_results = {}
for nname, nresult in node_data.items(): for ninfo in node_cfg.values():
# first fill in static (config-based) values # fill in static (config-based) values
ninfo = cfg.GetNodeInfo(nname)
pnr = { pnr = {
"tags": list(ninfo.GetTags()), "tags": list(ninfo.GetTags()),
"primary_ip": ninfo.primary_ip, "primary_ip": ninfo.primary_ip,
...@@ -10701,6 +10708,24 @@ class IAllocator(object): ...@@ -10701,6 +10708,24 @@ class IAllocator(object):
"vm_capable": ninfo.vm_capable, "vm_capable": ninfo.vm_capable,
} }
node_results[ninfo.name] = pnr
return node_results
@staticmethod
def _ComputeDynamicNodeData(node_cfg, node_data, node_iinfo, i_list,
node_results):
"""Compute global node data.
@param node_results: the basic node structures as filled from the config
"""
# make a copy of the current dict
node_results = dict(node_results)
for nname, nresult in node_data.items():
assert nname in node_results, "Missing basic data for node %s" % nname
ninfo = node_cfg[nname]
if not (ninfo.offline or ninfo.drained): if not (ninfo.offline or ninfo.drained):
nresult.Raise("Can't get data for node %s" % nname) nresult.Raise("Can't get data for node %s" % nname)
node_iinfo[nname].Raise("Can't get node instance info from node %s" % node_iinfo[nname].Raise("Can't get node instance info from node %s" %
...@@ -10742,9 +10767,9 @@ class IAllocator(object): ...@@ -10742,9 +10767,9 @@ class IAllocator(object):
"i_pri_memory": i_p_mem, "i_pri_memory": i_p_mem,
"i_pri_up_memory": i_p_up_mem, "i_pri_up_memory": i_p_up_mem,
} }
pnr.update(pnr_dyn) pnr_dyn.update(node_results[nname])
node_results[nname] = pnr node_results[nname] = pnr_dyn
return node_results return node_results
......
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