Add resource metadata to nodes
We currently don't really have statistics about the resource utilization of projects or tenants in zuul. This can be solved by adding resource metadata to the node data structure that can be used by zuul (which has the knowledge about projects and tenants) to report resource usage statistics. The new introduced optional resources field is a plain dict and could be extended in the future with further resource information like ports or volume size that might be useful in the future. This change is fully backwards compatible and doesn't need a total shutdown of nodepool to upgrade. Change-Id: I670d4bfd7d35ce1109b3ee9b3342fb45ee283a79
This commit is contained in:
parent
e0ebaa9799
commit
722d0c9141
|
@ -142,6 +142,11 @@ class OpenStackNodeLauncher(NodeLauncher):
|
|||
self.node.external_id = server.id
|
||||
self.node.hostname = hostname
|
||||
self.node.image_id = image_id
|
||||
|
||||
pool = self.handler.provider.pools.get(self.node.pool)
|
||||
resources = self.handler.manager.quotaNeededByNodeType(
|
||||
self.node.type[0], pool)
|
||||
self.node.resources = resources.quota['compute']
|
||||
if username:
|
||||
self.node.username = username
|
||||
self.node.connection_type = connection_type
|
||||
|
|
|
@ -70,6 +70,12 @@ class TestLauncher(tests.DBTestCase):
|
|||
image.provider_name),
|
||||
id=image.id)
|
||||
self.assertEqual(node.image_id, p)
|
||||
resources = {
|
||||
'cores': 4,
|
||||
'instances': 1,
|
||||
'ram': 8192,
|
||||
}
|
||||
self.assertEqual(node.resources, resources)
|
||||
self.zk.lockNode(node, blocking=False)
|
||||
self.zk.unlockNode(node)
|
||||
|
||||
|
|
|
@ -515,6 +515,7 @@ class Node(BaseModel):
|
|||
self.connection_type = None
|
||||
self.host_keys = []
|
||||
self.hold_expiration = None
|
||||
self.resources = None
|
||||
|
||||
def __repr__(self):
|
||||
d = self.toDict()
|
||||
|
@ -549,7 +550,8 @@ class Node(BaseModel):
|
|||
self.connection_type == other.connection_type and
|
||||
self.connection_port == other.connection_port and
|
||||
self.host_keys == other.host_keys and
|
||||
self.hold_expiration == other.hold_expiration)
|
||||
self.hold_expiration == other.hold_expiration and
|
||||
self.resources == other.resources)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -595,6 +597,7 @@ class Node(BaseModel):
|
|||
d['connection_type'] = self.connection_type
|
||||
d['connection_port'] = self.connection_port
|
||||
d['hold_expiration'] = self.hold_expiration
|
||||
d['resources'] = self.resources
|
||||
return d
|
||||
|
||||
@staticmethod
|
||||
|
@ -644,6 +647,7 @@ class Node(BaseModel):
|
|||
o.hold_expiration = 0
|
||||
else:
|
||||
o.hold_expiration = hold_expiration
|
||||
o.resources = d.get('resources')
|
||||
return o
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue