Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hub: do not assign tasks to workers with incompatible arches #237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kobo/hub/xmlrpc/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_tasks_to_assign(request):
return task_list

# awaited tasks
for task in Task.objects.free().filter(awaited=True).order_by("-priority", "id")[:max_tasks]:
for task in Task.objects.free().filter(awaited=True, arch__in=request.worker.arches.all()).order_by("-priority", "id")[:max_tasks]:
lzaoral marked this conversation as resolved.
Show resolved Hide resolved
task_info = task.export(flat=False)
task_list.append(task_info)

Expand All @@ -210,7 +210,7 @@ def get_tasks_to_assign(request):
# free tasks for each channel relevant to the worker
tasks = []
for channel in request.worker.channels.all():
for task in Task.objects.free().filter(awaited=False, channel=channel, priority__gte=request.worker.min_priority).order_by("-priority", "id")[:max_tasks]:
for task in Task.objects.free().filter(awaited=False, channel=channel, arch__in=request.worker.arches.all(), priority__gte=request.worker.min_priority).order_by("-priority", "id")[:max_tasks]:
task_info = task.export(flat=False)
tasks.append(task_info)

Expand Down
9 changes: 9 additions & 0 deletions tests/test_xmlrpc_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ def test_update_worker(self):
self.assertEqual(wi['task_count'], 1)

def test_get_tasks_to_assign(self):
new_arch = Arch.objects.create(name='testarch2', pretty_name='testarch2')

for _ in range(2):
Task.objects.create(
worker=self._worker,
Expand Down Expand Up @@ -790,6 +792,13 @@ def test_get_tasks_to_assign(self):
state=TASK_STATES['CLOSED'],
)

# task with an incompatible architecture
Task.objects.create(
arch=new_arch,
channel=self._channel,
owner=self._user,
)

req = _make_request(self._worker)
tasks = worker.get_tasks_to_assign(req)

Expand Down
Loading