Skip to content

Commit

Permalink
Support cached images for cloud runner. (#690)
Browse files Browse the repository at this point in the history
Also fix the Docker image existence check to properly check remote
registries.
  • Loading branch information
oliverchang authored Nov 6, 2024
1 parent a170735 commit 004b660
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion experiment/builder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,12 +905,22 @@ def build_and_run_cloud(
f'--upload_coverage={coverage_path}',
f'--upload_reproducer={reproducer_path}',
f'--upload_corpus={corpus_path}',
f'--experiment_name={self.experiment_name}'
f'--experiment_name={self.experiment_name}',
f'--real_project={project_name}',
]

if oss_fuzz_checkout.ENABLE_CACHING and (
oss_fuzz_checkout.is_image_cached(project_name, 'address') and
oss_fuzz_checkout.is_image_cached(project_name, 'coverage')):
logger.info(f'Using cached image for {project_name}.')
command.append('--use_cached_image')

if cloud_build_tags:
command += ['--tags'] + cloud_build_tags
command += ['--'] + self._libfuzzer_args()

logger.info(f'Command: {command}')

if not self._run_with_retry_control(os.path.realpath(target_path),
command,
cwd=oss_fuzz_checkout.OSS_FUZZ_DIR):
Expand Down
4 changes: 2 additions & 2 deletions experiment/oss_fuzz_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

BUILD_DIR: str = 'build'
GLOBAL_TEMP_DIR: str = ''
ENABLE_CACHING = bool(int(os.getenv('OFG_USE_CACHING', '0')))
ENABLE_CACHING = bool(int(os.getenv('OFG_USE_CACHING', '1')))
# Assume OSS-Fuzz is at repo root dir by default.
# This will change if temp_dir is used.
OSS_FUZZ_DIR: str = os.path.join(
Expand Down Expand Up @@ -285,7 +285,7 @@ def is_image_cached(project_name: str, sanitizer: str) -> bool:
cached_image_name = _get_project_cache_image_name(project_name, sanitizer)
try:
sp.run(
['docker', 'inspect', '--type=image', cached_image_name],
['docker', 'manifest', 'inspect', cached_image_name],
check=True,
stdin=sp.DEVNULL,
stdout=sp.DEVNULL,
Expand Down

0 comments on commit 004b660

Please sign in to comment.