Skip to content

Commit 2b9fa82

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

14 files changed

Lines changed: 81 additions & 44 deletions

File tree

builder/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
33

44
ENV DEBIAN_FRONTEND noninteractive
55

6+
RUN apt-get update
7+
68
# install ssh server
79
RUN apt-get install -yq openssh-server
810
RUN rm /etc/ssh/ssh_host_*
@@ -44,6 +46,10 @@ RUN echo "%git ALL=(ALL:ALL) NOPASSWD:/home/git/builder" >> /etc/sudoers
4446
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/confd -O /usr/local/bin/confd
4547
RUN chmod +x /usr/local/bin/confd
4648

49+
# install latest etcdctl including no-sync options
50+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
51+
RUN chmod +x /usr/local/bin/etcdctl
52+
4753
# add the current build context to /app
4854
ADD . /app
4955
RUN chown -R root:root /app

builder/bin/boot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/builder}
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,8 +24,8 @@ 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 mkdir $ETCD_PATH/users >/dev/null 2>&1 || true
27+
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
28+
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH/users >/dev/null 2>&1 || true
2929
fi
3030

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

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

cache/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ RUN add-apt-repository ppa:chris-lea/redis-server -y
77
RUN apt-get update
88
RUN apt-get install -yq redis-server
99

10+
# install latest etcdctl including no-sync options
11+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
12+
RUN chmod +x /usr/local/bin/etcdctl
13+
1014
# add the current build context to /app
1115
ADD . /app
1216

cache/bin/boot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/cache}
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,8 +24,8 @@ 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 mkdir $ETCD_PATH >/dev/null 2>&1 || true
27+
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
28+
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
2929
fi
3030

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

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

controller/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"]

controller/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

database/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ RUN wget --quiet --no-check-certificate -O - https://www.postgresql.org/media/ke
88
RUN apt-get update
99
RUN apt-get install -yq postgresql-9.3 && /etc/init.d/postgresql stop
1010

11+
# install latest etcdctl including no-peers options
12+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
13+
RUN chmod +x /usr/local/bin/etcdctl
14+
15+
# install latest etcdctl including no-sync options
16+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
17+
RUN chmod +x /usr/local/bin/etcdctl
18+
19+
# debug to remove
20+
RUN apt-get install -yq curl
21+
1122
# add the current build context to /app
1223
ADD . /app
1324

database/bin/boot

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if [[ ! -d /var/lib/postgresql/9.3/main ]]; then
2222
fi
2323

2424
# wait for etcd to be available
25-
until etcdctl -C $ETCD ls >/dev/null; do
25+
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
2626
echo "waiting for etcd at $ETCD..."
2727
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
2828
done
@@ -31,13 +31,13 @@ done
3131
sleep $(($ETCD_TTL+1))
3232

3333
# seed initial service configuration if necessary
34-
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
35-
etcdctl -C $ETCD set $ETCD_PATH/engine postgresql_psycopg2 >/dev/null
36-
etcdctl -C $ETCD set $ETCD_PATH/adminUser ${PG_ADMIN_USER:-postgres} >/dev/null
37-
etcdctl -C $ETCD set $ETCD_PATH/adminPass ${PG_ADMIN_PASS:-changeme123} >/dev/null
38-
etcdctl -C $ETCD set $ETCD_PATH/user ${PG_USER_NAME:-deis} >/dev/null
39-
etcdctl -C $ETCD set $ETCD_PATH/password ${PG_USER_PASS:-changeme123} >/dev/null
40-
etcdctl -C $ETCD set $ETCD_PATH/name ${PG_USER_DB:-deis} >/dev/null
34+
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
35+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/engine postgresql_psycopg2 >/dev/null
36+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/adminUser ${PG_ADMIN_USER:-postgres} >/dev/null
37+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/adminPass ${PG_ADMIN_PASS:-changeme123} >/dev/null
38+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/user ${PG_USER_NAME:-deis} >/dev/null
39+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/password ${PG_USER_PASS:-changeme123} >/dev/null
40+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/name ${PG_USER_DB:-deis} >/dev/null
4141
fi
4242

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

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

logger/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ RUN apt-get install -yq --force-yes rsyslog
1212
# create /var/log/deis for holding logs (access via bind mount)
1313
RUN mkdir -p /var/log/deis
1414

15+
# install latest etcdctl including no-sync options
16+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
17+
RUN chmod +x /usr/local/bin/etcdctl
18+
1519
# add the current build context to /app
1620
ADD . /app
1721

logger/bin/boot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/logs}
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,8 +24,8 @@ 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 mkdir $ETCD_PATH >/dev/null 2>&1 || true
27+
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
28+
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
2929
fi
3030

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

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

0 commit comments

Comments
 (0)