Skip to content

Commit 1bf12fb

Browse files
Gabriel MonroyMatthew Fisher
authored andcommitted
fix(etcdctl): use no-sync option to prevent connectivity issues
1 parent 1845649 commit 1bf12fb

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ RUN mkdir -p /templates && chown -R deis:deis /templates
3838
# create directory for logs
3939
RUN mkdir -p /var/log/deis && chown -R deis:deis /var/log/deis
4040

41+
# install latest etcdctl including no-sync options
42+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
43+
RUN chmod +x /usr/local/bin/etcdctl
44+
4145
# define the execution environment
4246
WORKDIR /app
4347
CMD ["/app/bin/boot"]

bin/boot

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/controller}
1515
export ETCD_TTL=${ETCD_TTL:-10}
1616

1717
# wait for etcd to be available
18-
until etcdctl -C $ETCD ls >/dev/null; do
18+
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
1919
echo "waiting for etcd at $ETCD..."
2020
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
2121
done
@@ -24,10 +24,10 @@ done
2424
sleep $(($ETCD_TTL+1))
2525

2626
# seed initial service configuration if necessary
27-
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
28-
etcdctl -C $ETCD set $ETCD_PATH/protocol ${DEIS_PROTOCOL:-http} >/dev/null
29-
etcdctl -C $ETCD set $ETCD_PATH/secretKey ${DEIS_SECRET_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
30-
etcdctl -C $ETCD set $ETCD_PATH/builderKey ${DEIS_BUILDER_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
27+
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
28+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/protocol ${DEIS_PROTOCOL:-http} >/dev/null
29+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/secretKey ${DEIS_SECRET_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
30+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/builderKey ${DEIS_BUILDER_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
3131
fi
3232

3333
# wait for confd to run once and install initial templates
@@ -82,8 +82,8 @@ if [[ ! -z $PUBLISH ]]; then
8282

8383
# while the port is listening, publish to etcd
8484
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do
85-
etcdctl -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
86-
etcdctl -C $ETCD set $ETCD_PATH/port $PORT --ttl $ETCD_TTL >/dev/null
85+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
86+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $PORT --ttl $ETCD_TTL >/dev/null
8787
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
8888
done
8989

0 commit comments

Comments
 (0)