Fix label name in reported label stats

Now the node type is a list of labels. This is not considered when
updating the node stats so the label in the reported stats is the
string representation of that list. Instead iterate over that list and
increase the counter for every label.

Change-Id: Id64cb933e310fa056deab0b63e9e02d451de5973
This commit is contained in:
Tobias Henkel 2018-09-07 08:20:57 +02:00
parent a54e4bf0dc
commit bb3c2dbf1b
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
2 changed files with 11 additions and 6 deletions

View File

@ -110,12 +110,15 @@ class StatsReporter(object):
states[key] += 1
# nodepool.label.LABEL.nodes.STATE
key = 'nodepool.label.%s.nodes.%s' % (node.type, node.state)
# It's possible we could see node types that aren't in our config
if key in states:
states[key] += 1
else:
states[key] = 1
# nodes can have several labels
for label in node.type:
key = 'nodepool.label.%s.nodes.%s' % (label, node.state)
# It's possible we could see node types that aren't in our
# config
if key in states:
states[key] += 1
else:
states[key] = 1
# nodepool.provider.PROVIDER.nodes.STATE
key = 'nodepool.provider.%s.nodes.%s' % (node.provider, node.state)

View File

@ -81,6 +81,8 @@ class TestLauncher(tests.DBTestCase):
self.waitForNodeRequestLockDeletion(req.id)
self.assertReportedStat('nodepool.nodes.ready', value='1', kind='g')
self.assertReportedStat('nodepool.nodes.building', value='0', kind='g')
self.assertReportedStat('nodepool.label.fake-label.nodes.ready',
value='1', kind='g')
def test_node_assignment_order(self):
"""Test that nodes are assigned in the order requested"""