From d3208c6c3fd684b2b358a2932cd468cfc35567b7 Mon Sep 17 00:00:00 2001 From: Brandon Weeks Date: Fri, 29 Apr 2016 11:35:57 -0700 Subject: [PATCH] Test for certificate error and prompt to regenerate If the docker-machine certificates get in a bad state, the current behavior causes an infinite loop waiting for `docker-machine env` to return. Now it will echo the certificate error and prompt the user to regenerate. --- build/common.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build/common.sh b/build/common.sh index 9f9c3e58f74..e0d06ade9f5 100755 --- a/build/common.sh +++ b/build/common.sh @@ -201,8 +201,14 @@ function kube::build::prepare_docker_machine() { } docker-machine start "${DOCKER_MACHINE_NAME}" &> /dev/null # it takes `docker-machine env` a few seconds to work if the machine was just started - while ! docker-machine env ${DOCKER_MACHINE_NAME} &> /dev/null; do - sleep 1 + local docker_machine_out + while ! docker_machine_out=$(docker-machine env "${DOCKER_MACHINE_NAME}" 2>&1); do + if [[ ${docker_machine_out} =~ "Error checking TLS connection" ]]; then + echo ${docker_machine_out} + docker-machine regenerate-certs ${DOCKER_MACHINE_NAME} + else + sleep 1 + fi done eval $(docker-machine env "${DOCKER_MACHINE_NAME}") kube::log::status "A Docker host using docker-machine named '${DOCKER_MACHINE_NAME}' is ready to go!"