Skip to content

Commit 8ca18b1

Browse files
Fix error scheduling variant for mac (#3628)
Fixes: #3576
1 parent 5cbfafd commit 8ca18b1

File tree

4 files changed

+56
-12
lines changed

4 files changed

+56
-12
lines changed

src/clusterfuzz/_internal/bot/tasks/task_creation.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ def create_postminimize_tasks(testcase):
285285
schedule_tasks(tasks)
286286

287287

288-
def is_remote_utask(task: Task) -> bool:
289-
"""Returns True if |task| is supposed to be executed remotely (i.e. preprocess
290-
utask_main and postprocess on different machines."""
291-
command = task.name
292-
return task_types.COMMAND_TYPES[command].is_execution_remote()
293-
294-
295288
def _preprocess(task: Task) -> None:
296289
"""Runs preprocess portion of task and saves the uworker_input to task."""
297290
from clusterfuzz._internal.bot.tasks import commands
@@ -320,7 +313,7 @@ def schedule_tasks(tasks: List[Task]):
320313
uworker_tasks = []
321314
tasks = [task for task in tasks if task is not None]
322315
for task in tasks:
323-
if not task_types.is_remote_utask(task.name):
316+
if not task_types.is_remote_utask(task.name, task.job):
324317
taskslib.add_task(task.name, task.argument, task.job,
325318
task.queue_for_platform)
326319
logs.log(f'UTask {task.name} not remote.')

src/clusterfuzz/_internal/bot/tasks/task_types.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ def preprocess(self, task_argument, job_type, uworker_env):
6969
raise NotImplementedError('Child class must implement.')
7070

7171

72-
def is_remote_utask(command):
73-
return COMMAND_TYPES[command].is_execution_remote()
72+
def is_remote_utask(command, job):
73+
if not COMMAND_TYPES[command].is_execution_remote():
74+
return False
75+
76+
if environment.is_uworker():
77+
# Return True even if we can't query the db.
78+
return True
79+
80+
return batch.is_remote_task(command, job)
7481

7582

7683
class UTaskLocalExecutor(BaseUTask):
@@ -132,8 +139,7 @@ def execute(self, task_argument, job_type, uworker_env):
132139

133140
def is_remotely_executing_utasks():
134141
return bool(environment.is_production() and
135-
environment.get_value('REMOTE_UTASK_EXECUTION') and
136-
environment.platform() == 'LINUX')
142+
environment.get_value('REMOTE_UTASK_EXECUTION'))
137143

138144

139145
class PostprocessTask(BaseTask):

src/clusterfuzz/_internal/google_cloud_utils/batch.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ def _get_job(job_name):
214214
return data_types.Job.query(data_types.Job.name == job_name).get()
215215

216216

217+
def is_remote_task(command, job_name):
218+
try:
219+
_get_spec_from_config(command, job_name)
220+
return True
221+
except ValueError:
222+
return False
223+
224+
217225
def _get_spec_from_config(command, job_name):
218226
"""Gets the configured specifications for a batch workload."""
219227
job = _get_job(job_name)

src/clusterfuzz/_internal/tests/core/bot/tasks/task_types_test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from unittest import mock
1717

1818
from clusterfuzz._internal.bot.tasks import task_types
19+
from clusterfuzz._internal.datastore import data_types
1920
from clusterfuzz._internal.tests.test_libs import helpers
21+
from clusterfuzz._internal.tests.test_libs import test_utils
2022

2123

2224
class UTaskCombinedTest(unittest.TestCase):
@@ -29,3 +31,38 @@ def test_is_remote(self):
2931
'clusterfuzz._internal.bot.tasks.task_types.is_remotely_executing_utasks',
3032
return_value=True):
3133
self.assertTrue(task_types.UTaskCombined.is_execution_remote())
34+
35+
36+
@test_utils.with_cloud_emulators('datastore')
37+
class IsRemoteUtaskTest(unittest.TestCase):
38+
"""Tests for is_remote_utask."""
39+
40+
def setUp(self):
41+
helpers.patch_environ(self)
42+
43+
def test_mac(self):
44+
job_name = 'libfuzzer_mac_asan'
45+
46+
with mock.patch(
47+
'clusterfuzz._internal.bot.tasks.task_types.is_remotely_executing_utasks',
48+
return_value=True):
49+
data_types.Job(name=job_name, platform='MAC').put()
50+
self.assertFalse(task_types.is_remote_utask('variant', job_name))
51+
52+
def test_linux(self):
53+
job_name = 'libfuzzer_linux_asan'
54+
55+
with mock.patch(
56+
'clusterfuzz._internal.bot.tasks.task_types.is_remotely_executing_utasks',
57+
return_value=True):
58+
data_types.Job(name=job_name, platform='LINUX').put()
59+
self.assertTrue(task_types.is_remote_utask('variant', job_name))
60+
61+
def test_trusted(self):
62+
job_name = 'libfuzzer_linux_asan'
63+
64+
with mock.patch(
65+
'clusterfuzz._internal.bot.tasks.task_types.is_remotely_executing_utasks',
66+
return_value=True):
67+
data_types.Job(name=job_name, platform='LINUX').put()
68+
self.assertFalse(task_types.is_remote_utask('impact', job_name))

0 commit comments

Comments
 (0)