Skip to content

Commit d660222

Browse files
aledbfmboersma
authored andcommitted
ref(user-data): check etcdctl version in shutdown script
1 parent ccb2f9c commit d660222

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

contrib/coreos/user-data.example

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,16 @@ write_files:
274274
/usr/bin/docker exec deis-store-admin ceph mon remove `hostname -f` # fixme
275275
/usr/bin/docker stop deis-store-metadata || true
276276
fi
277-
NODE=$(curl -L http://127.0.0.1:7001/v2/admin/machines/`cat /etc/machine-id`)
278-
# remove from etcd cluster
279-
if [ $NODE != 'null' ]; then
280-
/usr/bin/curl -L -XDELETE http://127.0.0.1:7001/v2/admin/machines/`cat /etc/machine-id`
277+
278+
# TODO: remove the next check once etcdctl is using etcd2
279+
ETCDCTL=/usr/bin/etcdctl
280+
if ! $ETCDCTL --version | grep -q "etcdctl version 2.0."; then
281+
ETCD_VERSION=2.0.13
282+
curl -sSL https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz | \
283+
tar zxv -C /opt/bin etcd-v${ETCD_VERSION}-linux-amd64/etcdctl --strip=1
284+
ETCDCTL="/opt/bin/etcdctl"
281285
fi
286+
# removing the node from etcd
287+
NODE=$($ETCDCTL member list | grep `cat /etc/machine-id` | cut -d ':' -f 1)
288+
$ETCDCTL member remove $NODE
282289
manage_etc_hosts: localhost

0 commit comments

Comments
 (0)