From 06c22c699a8cced0ad7c9f7d8eea7186a2864543 Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Wed, 13 May 2015 19:05:58 -0700 Subject: [PATCH] Ensure basic DNS functionality before doing real work in configure-vm.sh Fixes #8196. Maybe. If my theory is correct on how we got there. Also changes the inference of master to be based on the master name, not the node instance prefix. That way if we somehow have a bogus hostname, the master will configure itself as a node, the whole cluster fails, and it's a ton more obvious. --- cluster/gce/configure-vm.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 30c0e9ecd0..6fc1f99a8d 100644 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -24,6 +24,26 @@ is_push=$@ readonly KNOWN_TOKENS_FILE="/srv/salt-overlay/salt/kube-apiserver/known_tokens.csv" readonly BASIC_AUTH_FILE="/srv/salt-overlay/salt/kube-apiserver/basic_auth.csv" +function ensure-basic-networking() { + # Deal with GCE networking bring-up race. (We rely on DNS for a lot, + # and it's just not worth doing a whole lot of startup work if this + # isn't ready yet.) + until getent hosts metadata.google.internal &>/dev/null; do + echo 'Waiting for functional DNS (trying to resolve metadata.google.internal)...' + sleep 3 + done + until getent hosts $(hostname -f) &>/dev/null; do + echo 'Waiting for functional DNS (trying to resolve my own FQDN)...' + sleep 3 + done + until getent hosts $(hostname -i) &>/dev/null; do + echo 'Waiting for functional DNS (trying to resolve my own IP)...' + sleep 3 + done + + echo "Networking functional on $(hostname) ($(hostname -i))" +} + function ensure-install-dir() { INSTALL_DIR="/var/cache/kubernetes-install" mkdir -p ${INSTALL_DIR} @@ -58,11 +78,11 @@ for k,v in yaml.load(sys.stdin).iteritems(): print "readonly {var}={value}".format(var = k, value = pipes.quote(str(v))) ''' < "${kube_env_yaml}") - # Infer master status from presence in node pool - if [[ $(hostname) = ${NODE_INSTANCE_PREFIX}* ]]; then - KUBERNETES_MASTER="false" - else + # Infer master status from hostname + if [[ $(hostname) == "${INSTANCE_PREFIX}-master" ]]; then KUBERNETES_MASTER="true" + else + KUBERNETES_MASTER="false" fi } @@ -466,6 +486,7 @@ function run-salt() { if [[ -z "${is_push}" ]]; then echo "== kube-up node config starting ==" set-broken-motd + ensure-basic-networking ensure-install-dir set-kube-env [[ "${KUBERNETES_MASTER}" == "true" ]] && mount-master-pd @@ -483,6 +504,7 @@ if [[ -z "${is_push}" ]]; then echo "== kube-up node config done ==" else echo "== kube-push node config starting ==" + ensure-basic-networking ensure-install-dir set-kube-env create-salt-pillar