Skip to content

Commit 3b7d29e

Browse files
Handle deleted fuzz targets in split builds (#4410)
Fixes: https://buganizer.corp.google.com/issues/377701732
1 parent f918c36 commit 3b7d29e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/clusterfuzz/_internal/build_management/build_manager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,13 @@ def _setup_split_targets_build(bucket_path, fuzz_target, revision=None):
11561156
bucket_path = environment.get_value('FUZZ_TARGET_BUILD_BUCKET_PATH')
11571157
if not fuzz_target:
11581158
raise BuildManagerError(
1159-
'Failed to choose a fuzz target (path=%s).' % bucket_path)
1159+
f'Failed to choose a fuzz target (path={bucket_path}).')
1160+
1161+
# Check this so that we handle deleted targets properly.
1162+
targets_list = _get_targets_list(bucket_path)
1163+
if fuzz_target not in targets_list:
1164+
raise errors.BuildNotFoundError(revision, environment.get_value('JOB_NAME'))
1165+
11601166
fuzz_target_bucket_path = _full_fuzz_target_path(bucket_path, fuzz_target)
11611167
if not revision:
11621168
revision = _get_latest_revision([fuzz_target_bucket_path])

src/clusterfuzz/_internal/tests/core/build_management/build_manager_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,9 @@ def test_target_no_longer_built(self):
17411741
build_manager._pick_random_fuzz_target_for_split_build(
17421742
target_weights={'target4': 1})
17431743

1744+
with self.assertRaises(errors.BuildNotFoundError):
1745+
build_manager.setup_build(fuzz_target='target4')
1746+
17441747

17451748
class GetPrimaryBucketPathTest(unittest.TestCase):
17461749
"""Tests for get_primary_bucket_path."""

0 commit comments

Comments
 (0)