Fix parsing of zone from path in executor API

The get() method of the executor API receives the full path to a build
request. In case of a zoned request the zone wasn't correctly derived
from the given path so that the resulting "zone" still contained the
request's UUID.

This lead to the creation of an `ExecutorQueue` for each build request
through the default factory of the `DefaultKeyDict`.

Change-Id: I9aafcee0ea24b45d095e35e242c24639dc149536
This commit is contained in:
Simon Westphahl 2021-09-06 09:57:26 +02:00
parent eac6b253cc
commit a93a1199be
2 changed files with 6 additions and 1 deletions

View File

@ -591,6 +591,9 @@ class TestExecutorApi(ZooKeeperBaseTestCase):
d = executor_api.get(path_d)
e = executor_api.get(path_e)
# Make sure the get() method used the correct zone keys
self.assertEqual(set(executor_api.zone_queues.keys()), {"zone", None})
b.state = BuildRequest.RUNNING
executor_api.update(b)

View File

@ -131,7 +131,9 @@ class ExecutorApi:
def get(self, path):
if path.startswith(self.zones_root):
zone = path[len(self.zones_root):]
# Remove zone root so we end up with: <zone>/requests/<uuid>
rel_path = path[len(f"{self.zones_root}/"):]
zone = rel_path.split("/")[0]
else:
zone = None
return self.zone_queues[zone].get(path)