diff --git a/scripts/etcd-metrics-proxy-wrapper.sh b/scripts/etcd-metrics-proxy-wrapper.sh index d336324..1867c53 100644 --- a/scripts/etcd-metrics-proxy-wrapper.sh +++ b/scripts/etcd-metrics-proxy-wrapper.sh @@ -14,6 +14,14 @@ function require_ev_all() { ETCD_METRICS_PROXY_IMAGE=${ETCD_METRICS_PROXY_IMAGE_REPO}:${ETCD_METRICS_PROXY_IMAGE_TAG} +# Waiting for ENI (eth1) to be attached to the instance +set +e +until [[ $(ifconfig eth1 2>/dev/null) ]]; do + echo "Waiting for ENI (eth1) to be attached..." + sleep 10 +done +set -e + if [[ $CLOUD_PROVIDER == "aws" ]]; then export HOSTNAME=$(curl -s http://169.254.169.254/latest/meta-data/local-hostname) export HOST_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) diff --git a/scripts/etcd-wrapper.sh b/scripts/etcd-wrapper.sh index e96c4b9..9d0f828 100644 --- a/scripts/etcd-wrapper.sh +++ b/scripts/etcd-wrapper.sh @@ -27,9 +27,18 @@ require_ev_one ETCD_IMAGE ETCD_IMAGE_TAG ETCD_IMAGE_REPO="${ETCD_IMAGE_REPO:-${ETCD_ACI:-quay.io/coreos/etcd}}" ETCD_IMAGE="${ETCD_IMAGE:-${ETCD_IMAGE_REPO}:${ETCD_IMAGE_TAG}}" +# Waiting for ENI (eth1) to be attached to the instance +set +e +until [[ $(ifconfig eth1 2>/dev/null) ]]; do + echo "Waiting for ENI (eth1) to be attached..." + sleep 10 +done +set -e + if [[ $CLOUD_PROVIDER == "aws" ]]; then - export HOSTNAME=$(curl -s http://169.254.169.254/latest/meta-data/local-hostname | cut -d '.' -f 1) - export HOST_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) + MAC_ADDR=$(ifconfig eth1 | grep ether | awk '{print $2}') + export HOSTNAME=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/local-hostname | cut -d '.' -f 1) + export HOST_IP=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/local-ipv4s) fi [[ ! -n "$HOSTNAME" ]] && export HOSTNAME=$(hostname)