From 1cc61174eaddb82431ab921e8f03f06e69a5f405 Mon Sep 17 00:00:00 2001 From: jayunit100 Date: Wed, 1 Apr 2015 20:26:34 -0400 Subject: [PATCH] Check to prevent split brain api-servers/api-clients which can happen if etcd dies between rerun of local-up-cluster.sh --- hack/local-up-cluster.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh index 3be3c8f541b..0ce5ee3d602 100755 --- a/hack/local-up-cluster.sh +++ b/hack/local-up-cluster.sh @@ -49,6 +49,16 @@ API_CORS_ALLOWED_ORIGINS=${API_CORS_ALLOWED_ORIGINS:-"/127.0.0.1(:[0-9]+)?$,/loc KUBELET_PORT=${KUBELET_PORT:-10250} LOG_LEVEL=${LOG_LEVEL:-3} +# For the common local scenario, fail fast if server is already running. +# this can happen if you run local-up-cluster.sh twice and kill etcd in between. +curl $API_HOST:$API_PORT +if [ ! $? -eq 0 ]; then + echo "API SERVER port is free, proceeding..." +else + echo "ERROR starting API SERVER, exiting. Some host on $API_HOST is serving already on $API_PORT" + exit 1 +fi + # Detect the OS name/arch so that we can find our binary case "$(uname -s)" in Darwin)