diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2021-10-05 09:01:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-05 09:01:38 -0400 |
commit | 26a0eab439cbb05a89e5e4bedcfb9de22b42754f (patch) | |
tree | 678cf4e9b1aa7b58f6423c444d0b737a95751122 | |
parent | 1d588e62cdc119f676316fbcab13cc331c7fb08c (diff) | |
download | oss-fuzz-26a0eab439cbb05a89e5e4bedcfb9de22b42754f.tar.gz |
[cifuzz][prow] Support docker in docker to support prow. (#6556)
-rw-r--r-- | infra/cifuzz/build_fuzzers.py | 3 | ||||
-rw-r--r-- | infra/cifuzz/config_utils.py | 1 | ||||
-rw-r--r-- | infra/cifuzz/docker.py | 10 |
3 files changed, 9 insertions, 5 deletions
diff --git a/infra/cifuzz/build_fuzzers.py b/infra/cifuzz/build_fuzzers.py index 6b6d78658..6722be5e9 100644 --- a/infra/cifuzz/build_fuzzers.py +++ b/infra/cifuzz/build_fuzzers.py @@ -80,7 +80,8 @@ class Builder: # pylint: disable=too-many-instance-attributes """Moves the source code we want to fuzz into the project builder and builds the fuzzers from that source code. Returns True on success.""" docker_args, docker_container = docker.get_base_docker_run_args( - self.workspace, self.config.sanitizer, self.config.language) + self.workspace, self.config.sanitizer, self.config.language, + self.config.docker_in_docker) if not docker_container: docker_args.extend( _get_docker_build_fuzzers_args_not_container(self.host_repo_path)) diff --git a/infra/cifuzz/config_utils.py b/infra/cifuzz/config_utils.py index b14d1d317..cc89a9099 100644 --- a/infra/cifuzz/config_utils.py +++ b/infra/cifuzz/config_utils.py @@ -209,6 +209,7 @@ class BaseConfig: self.git_store_branch = os.environ.get('GIT_STORE_BRANCH') self.git_store_branch_coverage = os.environ.get('GIT_STORE_BRANCH_COVERAGE', self.git_store_branch) + self.docker_in_docker = os.environ.get('DOCKER_IN_DOCKER') # TODO(metzman): Fix tests to create valid configurations and get rid of # CIFUZZ_TEST here and in presubmit.py. diff --git a/infra/cifuzz/docker.py b/infra/cifuzz/docker.py index a4227b651..935773d92 100644 --- a/infra/cifuzz/docker.py +++ b/infra/cifuzz/docker.py @@ -69,7 +69,8 @@ def delete_images(images): def get_base_docker_run_args(workspace, sanitizer=constants.DEFAULT_SANITIZER, - language=constants.DEFAULT_LANGUAGE): + language=constants.DEFAULT_LANGUAGE, + docker_in_docker=False): """Returns arguments that should be passed to every invocation of 'docker run'.""" docker_args = _DEFAULT_DOCKER_RUN_ARGS.copy() @@ -81,7 +82,7 @@ def get_base_docker_run_args(workspace, docker_args += get_docker_env_vars(env_mapping) docker_container = utils.get_container_name() logging.info('Docker container: %s.', docker_container) - if docker_container: + if docker_container and not docker_in_docker: # Don't map specific volumes if in a docker container, it breaks when # running a sibling container. docker_args += ['--volumes-from', docker_container] @@ -92,11 +93,12 @@ def get_base_docker_run_args(workspace, def get_base_docker_run_command(workspace, sanitizer=constants.DEFAULT_SANITIZER, - language=constants.DEFAULT_LANGUAGE): + language=constants.DEFAULT_LANGUAGE, + docker_in_docker=False): """Returns part of the command that should be used everytime 'docker run' is invoked.""" docker_args, docker_container = get_base_docker_run_args( - workspace, sanitizer, language) + workspace, sanitizer, language, docker_in_docker=docker_in_docker) command = _DEFAULT_DOCKER_RUN_COMMAND.copy() + docker_args return command, docker_container |