Merge pull request #24992 from brandonweeks/docker_machine_regenerate_certs

Automatic merge from submit-queue

Test for certificate error and prompt to regenerate

This resolves an issue where if the `${DOCKER_MACHINE_NAME}` VM was ever removed from `docker-machine` the build process would enter an infinite loop, with the following error being redirected to `/dev/null`.

>Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.102:2376": open /Users/weeks/.docker/machine/machines/kube-dev/server.pem: no such file or directory You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. Be advised that this will trigger a Docker daemon restart which will stop running containers.

Now the output is tested for the error string and if found prompts the user if they want to regenerate the certificate. Another option would be setting the `--force` flag on `docker-machine regenerate-certs`, so user intervention wouldn't be required.

/cc @mhbauer

<!-- Reviewable:start -->
---
This change is [<img src="http://reviewable.k8s.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](http://reviewable.k8s.io/reviews/kubernetes/kubernetes/24992)
<!-- Reviewable:end -->
This commit is contained in:
k8s-merge-robot 2016-07-06 14:48:18 -07:00 committed by GitHub
commit 567c64d1e2

View File

@ -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!"