Add job name back to node request data

With the circular dependency refactoring we also removed the job name
from the requestor data in the node request. However, this could
previously be used as part of the dynamic-tags in Nodepool which might
be useful for billing and cost calculations.

Add back the job name so those use-cases start working again.

Change-Id: Ie3be39819bf84d05a7427cd0e859f485de90835d
This commit is contained in:
Simon Westphahl 2024-03-06 08:43:52 +01:00
parent 496693bdaa
commit e41af7c312
No known key found for this signature in database
3 changed files with 12 additions and 6 deletions

View File

@ -5946,12 +5946,12 @@ For CI problems and help debugging, contact ci@example.org"""
system_id = self.scheds.first.sched.system.system_id
zk_nodepool = self.scheds.first.sched.nodepool.zk_nodepool
req1 = zuul.model.NodeRequest(system_id, "uuid1", "tenant",
"pipeline", "job", ['label'], None,
0, None)
"pipeline", "job_uuid", "job",
['label'], None, 0, None)
zk_nodepool.submitNodeRequest(req1, 100)
req2 = zuul.model.NodeRequest("someone else", "uuid1", "tenant",
"pipeline", "job", ['label'], None,
0, None)
"pipeline", "job_uuid", "job",
['label'], None, 0, None)
zk_nodepool.submitNodeRequest(req2, 100)
self.assertEqual(zk_nodepool.getNodeRequests(),
['100-0000000000', '100-0000000001'])

View File

@ -1650,13 +1650,17 @@ class NodeRequest(object):
"""A request for a set of nodes."""
def __init__(self, requestor, build_set_uuid, tenant_name, pipeline_name,
job_uuid, labels, provider, relative_priority,
job_uuid, job_name, labels, provider, relative_priority,
event_id=None, span_info=None):
self.requestor = requestor
self.build_set_uuid = build_set_uuid
self.tenant_name = tenant_name
self.pipeline_name = pipeline_name
self.job_uuid = job_uuid
# The requestor doesn't need the job name anymore after moving
# to job UUIDs, but we should keep it in the requestor data,
# since it can be used in Nodepool for dynamic label tags.
self.job_name = job_name
self.labels = labels
self.nodes = []
self._state = STATE_REQUESTED
@ -1720,6 +1724,7 @@ class NodeRequest(object):
"tenant_name": self.tenant_name,
"pipeline_name": self.pipeline_name,
"job_uuid": self.job_uuid,
"job_name": self.job_name,
"span_info": self.span_info,
}
d.setdefault('node_types', self.labels)
@ -1766,6 +1771,7 @@ class NodeRequest(object):
tenant_name=requestor_data.get("tenant_name"),
pipeline_name=requestor_data.get("pipeline_name"),
job_uuid=requestor_data.get("job_uuid"),
job_name=requestor_data.get("job_name"),
labels=data["node_types"],
provider=data["provider"],
relative_priority=data.get("relative_priority", 0),

View File

@ -191,7 +191,7 @@ class Nodepool(object):
else:
event_id = None
req = model.NodeRequest(self.system_id, build_set_uuid, tenant_name,
pipeline_name, job.uuid, labels,
pipeline_name, job.uuid, job.name, labels,
provider, relative_priority, event_id)
if job.nodeset.nodes: