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

NodeQuery: mark live fields as UNAVAIL for non-vm_capable nodes



Since we don't have the data per design, UNAVAIL is appropriate here,
while NODATA is not.

The patch also adds a comment: if we extend the live fields list to
contain other data in the future, we need to reevaluate this solution.

This should fix issue 143. The listing now shows (node2==ofline,
node3==not vm_capable):

  Node     DTotal     DFree    MTotal     MNode     MFree Pinst Sinst
  node1    698.6G    630.5G     32.0G      1.0G     30.0G     8     7
  node2 (offline) (offline) (offline) (offline) (offline)     9     4
  node3 (unavail) (unavail) (unavail) (unavail) (unavail)     0     0
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 74f258b6
......@@ -487,6 +487,7 @@ _NODE_SIMPLE_FIELDS = {
#: Fields requiring talking to the node
# Note that none of these are available for non-vm_capable nodes
_NODE_LIVE_FIELDS = {
"bootid": ("BootID", QFT_TEXT, "bootid"),
"cnodes": ("CNodes", QFT_NUMBER, "cpu_nodes"),
......@@ -577,6 +578,9 @@ def _GetLiveNodeField(field, kind, ctx, node):
if node.offline:
return _FS_OFFLINE
if not node.vm_capable:
return _FS_UNAVAIL
if not ctx.curlive_data:
return _FS_NODATA
......
......@@ -355,7 +355,7 @@ class TestNodeQuery(unittest.TestCase):
master_candidate=(name != master_name and idx % 3 == 0),
offline=False,
drained=False,
vm_capable=False,
vm_capable=True,
master_capable=False,
ndparams={},
group="default",
......@@ -468,10 +468,16 @@ class TestNodeQuery(unittest.TestCase):
def testGetLiveNodeField(self):
nodes = [
objects.Node(name="node1", drained=False, offline=False),
objects.Node(name="node2", drained=True, offline=False),
objects.Node(name="node3", drained=False, offline=False),
objects.Node(name="node4", drained=False, offline=True),
objects.Node(name="node1", drained=False, offline=False,
vm_capable=True),
objects.Node(name="node2", drained=True, offline=False,
vm_capable=True),
objects.Node(name="node3", drained=False, offline=False,
vm_capable=True),
objects.Node(name="node4", drained=False, offline=True,
vm_capable=True),
objects.Node(name="node5", drained=False, offline=False,
vm_capable=False),
]
live_data = dict.fromkeys([node.name for node in nodes], {})
......@@ -511,6 +517,13 @@ class TestNodeQuery(unittest.TestCase):
self.assertRaises(AssertionError, query._GetLiveNodeField,
"hello", constants.QFT_BOOL, ctx, nodes[0])
# Non-vm_capable node
assert not nodes[4].vm_capable
ctx = _QueryData(None, curlive_data={})
self.assertEqual(query._GetLiveNodeField("hello", constants.QFT_NUMBER,
ctx, nodes[4]),
query._FS_UNAVAIL, None)
class TestInstanceQuery(unittest.TestCase):
def _Create(self, selected):
......
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