diff --git a/kobo/hub/xmlrpc/worker.py b/kobo/hub/xmlrpc/worker.py index 6f817706..bb714789 100644 --- a/kobo/hub/xmlrpc/worker.py +++ b/kobo/hub/xmlrpc/worker.py @@ -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]: task_info = task.export(flat=False) task_list.append(task_info) @@ -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) diff --git a/tests/test_xmlrpc_worker.py b/tests/test_xmlrpc_worker.py index 2f4ab806..87d687aa 100644 --- a/tests/test_xmlrpc_worker.py +++ b/tests/test_xmlrpc_worker.py @@ -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, @@ -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)