Skip to content

Commit

Permalink
build_image.py waiting for docker daemon (kubeflow#864)
Browse files Browse the repository at this point in the history
* add waiting for docker daemon

* fix log
  • Loading branch information
lluunn authored and k8s-ci-robot committed May 24, 2018
1 parent 202ba9c commit 1c48df8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/build_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ def run(command, cwd=None, env=None, polling_interval=datetime.timedelta(seconds

return "\n".join(output)

def wait_for_docker_daemon(timeout=60):
"""Waiting for docker daemon to be ready. This is needed in DinD scenario."""
start_time = time.time()
while time.time() - start_time < timeout:
try:
subprocess.check_call(["docker", "ps"])
except subprocess.CalledProcessError:
time.sleep(5)
# Daemon ready.
logging.info("docker daemon ready.\n")
return
# Timeout.
logging.error("Timeout waiting for docker daemon\n")
# TODO(lunkai): use TimeoutError when we use py3.
raise RuntimeError

def get_build_args(config):
"""
Make the list of params for docker build from config.
Expand All @@ -78,6 +94,7 @@ def get_config(context_dir, version):
return config

def build_tf_serving(args):
wait_for_docker_daemon()
dir_path = os.path.dirname(os.path.realpath(__file__))
context_dir = os.path.join(dir_path, "k8s-model-server/images")
version = args.tf_version if args.platform == "cpu" else args.tf_version + "gpu"
Expand All @@ -97,6 +114,7 @@ def build_tf_serving(args):
run(["gcloud", "docker", "--", "push", image_name])

def build_tf_notebook(args):
wait_for_docker_daemon()
dir_path = os.path.dirname(os.path.realpath(__file__))
context_dir = os.path.join(dir_path, "tensorflow-notebook-image")
version = args.tf_version if args.platform == "cpu" else args.tf_version + "gpu"
Expand Down

0 comments on commit 1c48df8

Please sign in to comment.