Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(etcdctl): use no-sync option to prevent connectivity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Monroy authored and Matthew Fisher committed Apr 15, 2014
1 parent e173103 commit 2b9fa82
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 44 deletions.
6 changes: 6 additions & 0 deletions builder/Dockerfile
Expand Up @@ -3,6 +3,8 @@ MAINTAINER Gabriel Monroy <gabriel@opdemand.com>

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update

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

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# add the current build context to /app
ADD . /app
RUN chown -R root:root /app
Expand Down
10 changes: 5 additions & 5 deletions builder/bin/boot
Expand Up @@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/builder}
export ETCD_TTL=${ETCD_TTL:-10}

# wait for etcd to be available
until etcdctl -C $ETCD ls >/dev/null; do
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
echo "waiting for etcd at $ETCD..."
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
Expand All @@ -24,8 +24,8 @@ done
sleep $(($ETCD_TTL+1))

# seed initial service configuration if necessary
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
etcdctl -C $ETCD mkdir $ETCD_PATH/users >/dev/null 2>&1 || true
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH/users >/dev/null 2>&1 || true
fi

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

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

Expand Down
4 changes: 4 additions & 0 deletions cache/Dockerfile
Expand Up @@ -7,6 +7,10 @@ RUN add-apt-repository ppa:chris-lea/redis-server -y
RUN apt-get update
RUN apt-get install -yq redis-server

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# add the current build context to /app
ADD . /app

Expand Down
10 changes: 5 additions & 5 deletions cache/bin/boot
Expand Up @@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/cache}
export ETCD_TTL=${ETCD_TTL:-10}

# wait for etcd to be available
until etcdctl -C $ETCD ls >/dev/null; do
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
echo "waiting for etcd at $ETCD..."
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
Expand All @@ -24,8 +24,8 @@ done
sleep $(($ETCD_TTL+1))

# seed initial service configuration if necessary
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
etcdctl -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1 ; then
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
fi

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

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

Expand Down
4 changes: 4 additions & 0 deletions controller/Dockerfile
Expand Up @@ -38,6 +38,10 @@ RUN mkdir -p /templates && chown -R deis:deis /templates
# create directory for logs
RUN mkdir -p /var/log/deis && chown -R deis:deis /var/log/deis

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# define the execution environment
WORKDIR /app
CMD ["/app/bin/boot"]
Expand Down
14 changes: 7 additions & 7 deletions controller/bin/boot
Expand Up @@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/controller}
export ETCD_TTL=${ETCD_TTL:-10}

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

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

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

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

Expand Down
11 changes: 11 additions & 0 deletions database/Dockerfile
Expand Up @@ -8,6 +8,17 @@ RUN wget --quiet --no-check-certificate -O - https://www.postgresql.org/media/ke
RUN apt-get update
RUN apt-get install -yq postgresql-9.3 && /etc/init.d/postgresql stop

# install latest etcdctl including no-peers options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# debug to remove
RUN apt-get install -yq curl

# add the current build context to /app
ADD . /app

Expand Down
20 changes: 10 additions & 10 deletions database/bin/boot
Expand Up @@ -22,7 +22,7 @@ if [[ ! -d /var/lib/postgresql/9.3/main ]]; then
fi

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

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

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

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

Expand Down
4 changes: 4 additions & 0 deletions logger/Dockerfile
Expand Up @@ -12,6 +12,10 @@ RUN apt-get install -yq --force-yes rsyslog
# create /var/log/deis for holding logs (access via bind mount)
RUN mkdir -p /var/log/deis

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# add the current build context to /app
ADD . /app

Expand Down
10 changes: 5 additions & 5 deletions logger/bin/boot
Expand Up @@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/logs}
export ETCD_TTL=${ETCD_TTL:-10}

# wait for etcd to be available
until etcdctl -C $ETCD ls >/dev/null; do
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
echo "waiting for etcd at $ETCD..."
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
Expand All @@ -24,8 +24,8 @@ done
sleep $(($ETCD_TTL+1))

# seed initial service configuration if necessary
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
etcdctl -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>&1; then
etcdctl --no-sync -C $ETCD mkdir $ETCD_PATH >/dev/null 2>&1 || true
fi

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

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

Expand Down
4 changes: 4 additions & 0 deletions registry/Dockerfile
Expand Up @@ -22,6 +22,10 @@ RUN cd /docker-registry && git checkout 0.6.6
RUN cp /docker-registry/config/boto.cfg /etc/boto.cfg
RUN cd /docker-registry && pip install -r requirements.txt

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

# create data volume
RUN mkdir -p /data/repositories && chown -R registry:registry /data
VOLUME /data
Expand Down
12 changes: 6 additions & 6 deletions registry/bin/boot
Expand Up @@ -18,7 +18,7 @@ export ETCD_TTL=${ETCD_TTL:-10}
export REGISTRY_PORT=${PORT:-5000}

# wait for etcd to be available
until etcdctl -C $ETCD ls >/dev/null; do
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
echo "waiting for etcd at $ETCD..."
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
Expand All @@ -27,9 +27,9 @@ done
sleep $(($ETCD_TTL+1))

# seed initial service configuration if necessary
if ! etcdctl -C $ETCD ls $ETCD_PATH >/dev/null 2>/dev/null; then
etcdctl -C $ETCD set $ETCD_PATH/protocol http >/dev/null
etcdctl -C $ETCD set $ETCD_PATH/secretKey ${REGISTRY_SECRET_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
if ! etcdctl --no-sync -C $ETCD ls $ETCD_PATH >/dev/null 2>/dev/null; then
etcdctl --no-sync -C $ETCD set $ETCD_PATH/protocol http >/dev/null
etcdctl --no-sync -C $ETCD set $ETCD_PATH/secretKey ${REGISTRY_SECRET_KEY:-`openssl rand -base64 64 | tr -d '\n'`} >/dev/null
fi

# wait for confd to run once and install initial templates
Expand Down Expand Up @@ -70,8 +70,8 @@ if [[ ! -z $PUBLISH ]]; then

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

Expand Down
4 changes: 4 additions & 0 deletions router/Dockerfile
Expand Up @@ -8,6 +8,10 @@ RUN add-apt-repository ppa:nginx/stable -y
RUN apt-get update
RUN apt-get install -yq nginx

# install latest etcdctl including no-sync options
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/etcdctl.no-sync -O /usr/local/bin/etcdctl
RUN chmod +x /usr/local/bin/etcdctl

ADD . /app
WORKDIR /app
EXPOSE 80
Expand Down
12 changes: 6 additions & 6 deletions router/bin/boot
Expand Up @@ -15,7 +15,7 @@ export ETCD_PATH=${ETCD_PATH:-/deis/router}
export ETCD_TTL=${ETCD_TTL:-10}

# wait for etcd to be available
until etcdctl -C $ETCD ls >/dev/null; do
until etcdctl --no-sync -C $ETCD ls >/dev/null; do
echo "waiting for etcd at $ETCD..."
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
Expand All @@ -24,9 +24,9 @@ done
sleep $(($ETCD_TTL+1))

# seed initial service configuration if necessary
if ! etcdctl -C $ETCD ls /deis/services >/dev/null 2>&1; then
etcdctl -C $ETCD mkdir /deis/services || true >/dev/null 2>&1
etcdctl -C $ETCD set $ETCD_PATH/port ${PORT:-80} >/dev/null
if ! etcdctl --no-sync -C $ETCD ls /deis/services >/dev/null 2>&1; then
etcdctl --no-sync -C $ETCD mkdir /deis/services || true >/dev/null 2>&1
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port ${PORT:-80} >/dev/null
fi

# wait for confd to run once and install initial templates
Expand Down Expand Up @@ -66,8 +66,8 @@ if [[ ! -z $PUBLISH ]]; then

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

Expand Down

0 comments on commit 2b9fa82

Please sign in to comment.