Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix docker cache generation, cleanup output
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy committed Oct 18, 2019
1 parent f2ed1d4 commit 7dc622a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ def build_docker(platform: str, docker_binary: str, registry: str, num_retries:

@retry(subprocess.CalledProcessError, tries=num_retries)
def run_cmd():
logging.info("Running command: '%s'", ' '.join(cmd))
check_call(cmd)
logging.info("%s: Running command: '%s'", platform, ' '.join(cmd))
check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
logging.info("%s: Successfully finished command: '%s'", platform, ' '.join(cmd))

run_cmd()
# Get image id by reading the tag. It's guaranteed (except race condition) that the tag exists. Otherwise, the
Expand Down
11 changes: 6 additions & 5 deletions ci/docker_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _build_save_container(platform, registry, load_cache) -> Optional[str]:
load_docker_cache(registry=registry, docker_tag=docker_tag)

# Start building
logging.debug('Building %s as %s', platform, docker_tag)
logging.debug('%s: Building as %s', platform, docker_tag)
try:
# Increase the number of retries for building the cache.
image_id = build_util.build_docker(docker_binary='docker', platform=platform, registry=registry, num_retries=10, no_cache=False)
Expand All @@ -108,7 +108,7 @@ def _upload_image(registry, docker_tag, image_id) -> None:
# We don't have to retag the image since it is already in the right format
logging.info('Uploading %s (%s) to %s', docker_tag, image_id, registry)
push_cmd = ['docker', 'push', docker_tag]
subprocess.check_call(push_cmd)
subprocess.check_call(push_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)


@retry(target_exception=subprocess.CalledProcessError, tries=DOCKERHUB_LOGIN_NUM_RETRIES,
Expand Down Expand Up @@ -158,12 +158,13 @@ def load_docker_cache(registry, docker_tag) -> None:
return
assert docker_tag

logging.info('Loading Docker cache for %s from %s', docker_tag, registry)
logging.info('%s: loading cache from %s', docker_tag, registry)
pull_cmd = ['docker', 'pull', docker_tag]

# Don't throw an error if the image does not exist
subprocess.run(pull_cmd, timeout=DOCKER_CACHE_TIMEOUT_MINS*60)
logging.info('Successfully pulled docker cache')
subprocess.run(pull_cmd, timeout=DOCKER_CACHE_TIMEOUT_MINS*60,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
logging.info('%s: Successfully pulled docker cache', docker_tag)


def delete_local_docker_cache(docker_tag):
Expand Down

0 comments on commit 7dc622a

Please sign in to comment.