diff --git a/nodepool/stats.py b/nodepool/stats.py index bdb27c18f..1c17cd727 100755 --- a/nodepool/stats.py +++ b/nodepool/stats.py @@ -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) diff --git a/nodepool/tests/test_launcher.py b/nodepool/tests/test_launcher.py index 7d646bc2f..92296a057 100644 --- a/nodepool/tests/test_launcher.py +++ b/nodepool/tests/test_launcher.py @@ -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"""