Pass requestor data to Nodes
Propagate the NodeRequest.requestor to a new property Node.requestor which usually holds the zuul_system_id, or "NodePool:min_ready". This is set initially when first creating a node, and is updated when a ready node is assigned to a request. This is to always know for which requestor is a node got allocated. Change-Id: Ifd54a94bae39f31a70bdedce384a64c2a04495c1
This commit is contained in:
parent
c6c9f1a7c7
commit
7ae6b34e71
|
@ -466,6 +466,7 @@ class NodeRequestHandler(NodeRequestHandlerNotifications,
|
||||||
got_a_node = True
|
got_a_node = True
|
||||||
node.allocated_to = self.request.id
|
node.allocated_to = self.request.id
|
||||||
node.tenant_name = self.request.tenant_name
|
node.tenant_name = self.request.tenant_name
|
||||||
|
node.requestor = self.request.requestor
|
||||||
self.zk.storeNode(node)
|
self.zk.storeNode(node)
|
||||||
self.nodeset.append(node)
|
self.nodeset.append(node)
|
||||||
self._satisfied_types.add(ntype, node.id)
|
self._satisfied_types.add(ntype, node.id)
|
||||||
|
@ -514,6 +515,7 @@ class NodeRequestHandler(NodeRequestHandlerNotifications,
|
||||||
node.launcher = self.launcher_id
|
node.launcher = self.launcher_id
|
||||||
node.allocated_to = self.request.id
|
node.allocated_to = self.request.id
|
||||||
node.tenant_name = self.request.tenant_name
|
node.tenant_name = self.request.tenant_name
|
||||||
|
node.requestor = self.request.requestor
|
||||||
|
|
||||||
# This sets static data defined in the config file in the
|
# This sets static data defined in the config file in the
|
||||||
# ZooKeeper Node object.
|
# ZooKeeper Node object.
|
||||||
|
|
|
@ -49,6 +49,8 @@ class TestLauncher(tests.DBTestCase):
|
||||||
req = zk.NodeRequest()
|
req = zk.NodeRequest()
|
||||||
req.state = zk.REQUESTED
|
req.state = zk.REQUESTED
|
||||||
req.node_types.append('fake-label')
|
req.node_types.append('fake-label')
|
||||||
|
req.tenant_name = 'tenant-1'
|
||||||
|
req.requestor = 'unit-test'
|
||||||
self.zk.storeNodeRequest(req)
|
self.zk.storeNodeRequest(req)
|
||||||
|
|
||||||
req = self.waitForNodeRequest(req)
|
req = self.waitForNodeRequest(req)
|
||||||
|
@ -67,6 +69,8 @@ class TestLauncher(tests.DBTestCase):
|
||||||
self.assertEqual(node.connection_type, 'ssh')
|
self.assertEqual(node.connection_type, 'ssh')
|
||||||
self.assertEqual(node.connection_port, 22)
|
self.assertEqual(node.connection_port, 22)
|
||||||
self.assertEqual(node.python_path, '/usr/bin/python3')
|
self.assertEqual(node.python_path, '/usr/bin/python3')
|
||||||
|
self.assertEqual(node.tenant_name, 'tenant-1')
|
||||||
|
self.assertEqual(node.requestor, 'unit-test')
|
||||||
p = "{path}/{id}".format(
|
p = "{path}/{id}".format(
|
||||||
path=self.zk._imageUploadPath(image.image_name,
|
path=self.zk._imageUploadPath(image.image_name,
|
||||||
image.build_id,
|
image.build_id,
|
||||||
|
|
|
@ -599,6 +599,7 @@ class Node(BaseModel):
|
||||||
self.python_path = None
|
self.python_path = None
|
||||||
self.tenant_name = None
|
self.tenant_name = None
|
||||||
self.driver_data = None
|
self.driver_data = None
|
||||||
|
self.requestor = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
d = self.toDict()
|
d = self.toDict()
|
||||||
|
@ -641,7 +642,8 @@ class Node(BaseModel):
|
||||||
self.attributes == other.attributes and
|
self.attributes == other.attributes and
|
||||||
self.python_path == other.python_path and
|
self.python_path == other.python_path and
|
||||||
self.tenant_name == other.tenant_name and
|
self.tenant_name == other.tenant_name and
|
||||||
self.driver_data == other.driver_data)
|
self.driver_data == other.driver_data and
|
||||||
|
self.requestor == other.requestor)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -695,6 +697,7 @@ class Node(BaseModel):
|
||||||
d['python_path'] = self.python_path
|
d['python_path'] = self.python_path
|
||||||
d['tenant_name'] = self.tenant_name
|
d['tenant_name'] = self.tenant_name
|
||||||
d['driver_data'] = self.driver_data
|
d['driver_data'] = self.driver_data
|
||||||
|
d['requestor'] = self.requestor
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -763,6 +766,7 @@ class Node(BaseModel):
|
||||||
self.shell_type = d.get('shell_type')
|
self.shell_type = d.get('shell_type')
|
||||||
self.tenant_name = d.get('tenant_name')
|
self.tenant_name = d.get('tenant_name')
|
||||||
self.driver_data = d.get('driver_data')
|
self.driver_data = d.get('driver_data')
|
||||||
|
self.requestor = d.get('requestor')
|
||||||
|
|
||||||
|
|
||||||
class ZooKeeper(object):
|
class ZooKeeper(object):
|
||||||
|
|
Loading…
Reference in New Issue