Skip to content

Commit

Permalink
[orion-decision] Schedule all tasks per separate (service, arch)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuleimanov committed Oct 26, 2024
1 parent 0f59217 commit 7ce0913
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions services/orion-decision/src/orion_decision/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,15 @@ def create_tasks(self) -> None:
build_tasks_created: Set[str] = set()
combine_tasks_created: Dict[str, str] = {}
push_tasks_created: Set[str] = set()
to_create = sorted(
self.services.recipes.values(), key=lambda x: x.name
) + sorted(self.services.values(), key=lambda x: x.name)
to_create = [
(recipe, "amd64")
for recipe in sorted(self.services.recipes.values(), key=lambda x: x.name)
]
for service in sorted(self.services.values(), key=lambda x: x.name):
for arch in getattr(service, "archs", ["amd64"]):
to_create.append((service, arch))
while to_create:
obj = to_create.pop(0)
obj, arch = to_create.pop(0)
is_svc = isinstance(obj, Service)

if not obj.dirty:
Expand All @@ -486,13 +490,13 @@ def create_tasks(self) -> None:
dirty_test_dep_tasks = []
for test in obj.tests:
assert isinstance(test, ToxServiceTest)
for arch in obj.archs:
if (test.image, arch) in service_build_tasks and self.services[
test.image
].dirty:
dirty_test_dep_tasks.append(
service_build_tasks[(test.image, arch)]
)
# TODO: implement tests for all archs in the future
if (test.image, "amd64") in service_build_tasks and self.services[
test.image
].dirty:
dirty_test_dep_tasks.append(
service_build_tasks[(test.image, "amd64")]
)
else:
dirty_test_dep_tasks = []
dirty_recipe_test_tasks = [
Expand All @@ -507,8 +511,7 @@ def create_tasks(self) -> None:
pending_deps |= set(dirty_recipe_test_tasks) - test_tasks_created
if pending_deps:
if is_svc:
for arch in obj.archs:
task_id = service_build_tasks[(obj.name, arch)]
task_id = service_build_tasks[(obj.name, arch)]
else:
task_id = recipe_test_tasks[obj.name]

Expand All @@ -519,46 +522,52 @@ def create_tasks(self) -> None:
task_id,
", ".join(pending_deps),
)
assert obj not in to_create, f"{obj.name} creates circular dependency"
to_create.append(obj)
assert to_create, f"{obj.name} creates circular dependency"
to_create.append((obj, arch))
continue

if is_svc:
test_tasks = []
assert isinstance(obj, Service)
for test in obj.tests:
assert isinstance(test, ToxServiceTest)
for arch in obj.archs:
task_id = self._create_svc_test_task(
obj, test, service_build_tasks, arch
)
test_tasks_created.add(task_id)
test_tasks.append(task_id)
task_id = self._create_svc_test_task(
obj, test, service_build_tasks, arch
)
test_tasks_created.add(task_id)
test_tasks.append(task_id)
test_tasks.extend(dirty_recipe_test_tasks)

if isinstance(obj, ServiceTestOnly):
assert obj.tests
continue

for arch in obj.archs:
build_tasks_created.add(
self._create_build_task(
obj, dirty_dep_tasks, test_tasks, arch, service_build_tasks
)
build_tasks_created.add(
self._create_build_task(
obj, dirty_dep_tasks, test_tasks, arch, service_build_tasks
)
if len(obj.archs) > 1:
)
multi_arch = len(obj.archs) > 1
last_build_for_svc = not any(
obj is pending for (pending, _) in to_create
)

if multi_arch and last_build_for_svc:
combine_tasks_created[obj.name] = self._create_combine_task(
obj, service_build_tasks
)
if should_push:
if len(obj.archs) > 1:
push_tasks_created.add(
self._create_push_task(obj, combine_tasks_created[obj.name])
)
if multi_arch:
if last_build_for_svc:
push_tasks_created.add(
self._create_push_task(
obj, combine_tasks_created[obj.name]
)
)
else:
push_tasks_created.add(
self._create_push_task(
obj, service_build_tasks[(obj.name, obj.archs[0])]
obj, service_build_tasks[(obj.name, arch)]
)
)
else:
Expand Down

0 comments on commit 7ce0913

Please sign in to comment.