Skip to content

Commit

Permalink
FIX: etcd config should use the attached eni as main ip (#19)
Browse files Browse the repository at this point in the history
After this change
(getamis/vishwakarma@791f061),
etcd config should use the attached ENI IP as main IP / hostname.

CI Test Passed:
https://app.circleci.com/pipelines/github/getamis/vishwakarma/454/workflows/de328f85-a7dd-458f-bd7e-d520300a756b/jobs/551
  • Loading branch information
Downager authored Dec 7, 2022
1 parent 455d04d commit 698bff0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions scripts/etcd-metrics-proxy-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions scripts/etcd-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 698bff0

Please sign in to comment.