diff --git a/experiment/builder_runner.py b/experiment/builder_runner.py index 862bef50c..8bc80e9e9 100644 --- a/experiment/builder_runner.py +++ b/experiment/builder_runner.py @@ -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): diff --git a/experiment/oss_fuzz_checkout.py b/experiment/oss_fuzz_checkout.py index 20b33a891..ac3a937f9 100644 --- a/experiment/oss_fuzz_checkout.py +++ b/experiment/oss_fuzz_checkout.py @@ -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( @@ -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,