Skip to content

Commit

Permalink
[orion-decision] Fix keeping track of recipe, test and build tasks cr…
Browse files Browse the repository at this point in the history
…eated
  • Loading branch information
yescomply committed Oct 28, 2024
1 parent 95152a2 commit 4ccec55
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions services/orion-decision/src/orion_decision/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,15 @@ def create_tasks(self) -> None:
service_build_tasks = {
(service, arch): slugId()
for service in self.services
for arch in WORKERS_ARCHS
for arch in getattr(self.services[service], "archs", ["amd64"])
}
for (service, arch), task_id in service_build_tasks.items():
LOG.debug("Task %s is a build of %s on %s", task_id, service, arch)
recipe_test_tasks = {recipe: slugId() for recipe in self.services.recipes}
for recipe, task_id in recipe_test_tasks.items():
LOG.debug("Task %s is a recipe test for %s", task_id, recipe)
test_tasks_created: Set[str] = set()
test_tasks_created: Dict[Tuple[str, str], str] = {}
recipe_tasks_created: Set[str] = set()
build_tasks_created: Set[str] = set()
combine_tasks_created: Dict[str, str] = {}
push_tasks_created: Set[str] = set()
Expand All @@ -490,12 +491,12 @@ def create_tasks(self) -> None:
for arch in getattr(obj, "archs", ["amd64"])
if self.services[dep].dirty
]
# TODO: implement tests for all archs in the future
if is_svc:
assert isinstance(obj, Service)
dirty_test_dep_tasks = []
for test in obj.tests:
assert isinstance(test, ToxServiceTest)
# TODO: implement tests for all archs in the future
if (test.image, "amd64") in service_build_tasks and self.services[
test.image
].dirty:
Expand All @@ -513,7 +514,9 @@ def create_tasks(self) -> None:
pending_deps = (
set(dirty_dep_tasks) | set(dirty_test_dep_tasks)
) - build_tasks_created
pending_deps |= set(dirty_recipe_test_tasks) - test_tasks_created
pending_deps |= (
set(dirty_recipe_test_tasks) - set(test_tasks_created.values())
) - recipe_tasks_created
if pending_deps:
if is_svc:
task_id = service_build_tasks[(obj.name, arch)]
Expand All @@ -536,10 +539,13 @@ def create_tasks(self) -> None:
assert isinstance(obj, Service)
for test in obj.tests:
assert isinstance(test, ToxServiceTest)
task_id = self._create_svc_test_task(
obj, test, service_build_tasks, arch
)
test_tasks_created.add(task_id)
if arch == "amd64":
task_id = self._create_svc_test_task(
obj, test, service_build_tasks, arch
)
test_tasks_created[(obj.name, test.name)] = task_id
else:
task_id = test_tasks_created[(obj.name, test.name)]
test_tasks.append(task_id)
test_tasks.extend(dirty_recipe_test_tasks)

Expand Down Expand Up @@ -576,17 +582,18 @@ def create_tasks(self) -> None:
)
)
else:
test_tasks_created.add(
self._create_recipe_test_task(
obj,
dirty_dep_tasks + dirty_recipe_test_tasks,
recipe_test_tasks,
if arch == "amd64":
recipe_tasks_created.add(
self._create_recipe_test_task(
obj,
dirty_dep_tasks + dirty_recipe_test_tasks,
recipe_test_tasks,
)
)
)
LOG.info(
"%s %d test tasks, %d build tasks, %d combine tasks and %d push tasks",
self._created_str,
len(test_tasks_created),
len(test_tasks_created) + len(recipe_tasks_created),
len(build_tasks_created),
len(combine_tasks_created),
len(push_tasks_created),
Expand Down

0 comments on commit 4ccec55

Please sign in to comment.