Store multiple provider node launch attempts

Store a list of attempted provider node launchers as part of the nodeset
request in preparation for the retry handling logic.

Change-Id: I32029dd8caab639c8a03e505dee8ae9118ba6e12
This commit is contained in:
Simon Westphahl authored and James E. Blair committed 2024-09-27 08:57:00 -07:00
1 parent 81dc153ae2
commit 880baeb44a
5 files changed
+16 -13

No files matched your search

+6 -6
View File
@@ -359,7 +359,7 @@ class TestLauncher(ZuulTestCase):
labels = ["debian-normal", "debian-unavailable"]
request = self._requestNodes(labels)
self.assertEqual(request.state, model.NodesetRequest.State.FAILED)
self.assertEqual(len(request.provider_nodes), 0)
self.assertEqual(len(request.nodes), 0)
request.delete(ctx)
self.waitUntilSettled()
@@ -376,7 +376,7 @@ class TestLauncher(ZuulTestCase):
request = client.getRequest(request.uuid)
self.assertEqual(request.state, model.NodesetRequest.State.FULFILLED)
self.assertEqual(len(request.provider_nodes), 1)
self.assertEqual(len(request.nodes), 1)
client.acceptNodeset(request, nodeset)
self.waitUntilSettled()
@@ -418,7 +418,7 @@ class TestLauncher(ZuulTestCase):
request = self._requestNodes(["debian-normal"])
provider_nodes = []
for node_id in request.provider_nodes:
for node_id in request.nodes:
provider_nodes.append(model.ProviderNode.fromZK(
ctx, path=model.ProviderNode._getPath(node_id)))
@@ -444,10 +444,10 @@ class TestLauncher(ZuulTestCase):
ctx = self.createZKContext(None)
request = self._requestNodes(["debian-invalid"])
self.assertEqual(request.state, model.NodesetRequest.State.FAILED)
self.assertEqual(len(request.provider_nodes), 1)
self.assertEqual(len(request.nodes), 1)
provider_nodes = []
for node_id in request.provider_nodes:
for node_id in request.nodes:
provider_nodes.append(model.ProviderNode.fromZK(
ctx, path=model.ProviderNode._getPath(node_id)))
@@ -502,7 +502,7 @@ class TestLauncher(ZuulTestCase):
request = client.getRequest(request.uuid)
self.assertEqual(request.state, model.NodesetRequest.State.FULFILLED)
self.assertEqual(len(request.provider_nodes), 1)
self.assertEqual(len(request.nodes), 1)
client.acceptNodeset(request, nodeset)
self.waitUntilSettled()
+2 -2
View File
@@ -2560,7 +2560,7 @@ class TestLauncherApi(ZooKeeperBaseTestCase):
request.updateAttributes(
context,
state=model.NodesetRequest.State.ACCEPTED,
provider_nodes=[n.uuid for n in provider_nodes])
provider_nodes=[[n.uuid] for n in provider_nodes])
# "Fulfill" requested provider nodes
for node in self.api.getMatchingProviderNodes():
@@ -2582,7 +2582,7 @@ class TestLauncherApi(ZooKeeperBaseTestCase):
# Wait for nodes to show up be ready and unlocked
for _ in iterate_timeout(10, "nodes to be ready"):
requested_nodes = [self.api.getProviderNode(ni)
for ni in request.provider_nodes]
for ni in request.nodes]
if len(requested_nodes) != 2:
continue
if all(n.state == model.ProviderNode.State.READY
+2 -2
View File
@@ -86,7 +86,7 @@ class LauncherClient:
def getNodesetInfo(self, request):
# TODO: populated other nodeset info fields
return NodesetInfo(nodes=list(request.provider_nodes))
return NodesetInfo(nodes=list(request.nodes))
def acceptNodeset(self, request, nodeset):
log = get_annotated_logger(self.log, request)
@@ -94,7 +94,7 @@ class LauncherClient:
try:
with self.createZKContext(None, self.log) as ctx:
for node_id, node in zip(
request.provider_nodes, nodeset.getNodes()
request.nodes, nodeset.getNodes()
):
provider_node = ProviderNode.fromZK(
ctx, path=ProviderNode._getPath(node_id))
+2 -2
View File
@@ -340,7 +340,7 @@ class Launcher:
tags=tags,
)
log.debug("Requested node %s", node)
provider_nodes.append(node.uuid)
provider_nodes.append([node.uuid])
request.updateAttributes(
ctx,
@@ -365,7 +365,7 @@ class Launcher:
def _checkRequest(self, request, log):
log.debug("Checking request %s", request)
requested_nodes = [self.api.getProviderNode(p)
for p in request.provider_nodes]
for p in request.nodes]
if any(n is None for n in requested_nodes):
# Cache may not be up to date enough for the next check
return
+4 -1
View File
@@ -2317,6 +2317,9 @@ class NodesetRequest(zkobject.LockableZKObject):
request_time=time.time(),
zuul_event_id="",
span_info=None,
# A list of list with the attempted provider nodes. The last
# item in the contained lists is the current attempt. E.g.
# [[label-A-failed, label-A-building], [label-b-ready], ...]
provider_nodes=[],
# Attributes that are not serialized
lock=None,
@@ -2331,7 +2334,7 @@ class NodesetRequest(zkobject.LockableZKObject):
@property
def nodes(self):
return self.provider_nodes
return [n[-1] for n in self.provider_nodes]
@property
def created_time(self):