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

Commit

Permalink
Merge pull request #3791 from bacongobbler/fixup-etcd-set-default
Browse files Browse the repository at this point in the history
fix(*): check for key already exists errors only
  • Loading branch information
Matthew Fisher committed Jun 5, 2015
2 parents 445e50d + 7b4ed1a commit d8f012d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
7 changes: 4 additions & 3 deletions builder/rootfs/bin/boot
Expand Up @@ -30,9 +30,10 @@ sleep $(($ETCD_TTL+1))

function etcd_safe_mkdir {
set +e
etcdctl --no-sync -C $ETCD mkdir $1 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_safe_mkdir: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mkdir $1 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_safe_mkdir: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
Expand Down
14 changes: 8 additions & 6 deletions controller/bin/boot
Expand Up @@ -26,19 +26,21 @@ sleep $(($ETCD_TTL+1))

function etcd_set_default {
set +e
etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_set_default: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_set_default: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
}

function etcd_safe_mkdir {
set +e
etcdctl --no-sync -C $ETCD mkdir $1 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_safe_mkdir: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mkdir $1 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_safe_mkdir: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
Expand Down
7 changes: 4 additions & 3 deletions database/bin/boot
Expand Up @@ -28,9 +28,10 @@ sleep $(($ETCD_TTL+1))

function etcd_set_default {
set +e
etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_set_default: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_set_default: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
Expand Down
7 changes: 4 additions & 3 deletions registry/bin/boot
Expand Up @@ -32,9 +32,10 @@ sleep $(($ETCD_TTL+1))

function etcd_set_default {
set +e
etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_set_default: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_set_default: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
Expand Down
7 changes: 4 additions & 3 deletions store/monitor/bin/boot
Expand Up @@ -10,9 +10,10 @@ HOSTNAME=`hostname`

function etcd_set_default {
set +e
etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 >/dev/null 2>&1
if [[ $? -ne 0 && $? -ne 4 ]]; then
echo "etcd_set_default: an etcd error occurred. aborting..."
ERROR="$(etcdctl --no-sync -C $ETCD mk $ETCD_PATH/$1 $2 2>&1 >/dev/null)"
if [[ $? -ne 0 && $(echo $ERROR | grep -ive "key already exists") ]]; then
echo "etcd_set_default: an etcd error occurred ($ERROR)"
echo "aborting..."
exit 1
fi
set -e
Expand Down

0 comments on commit d8f012d

Please sign in to comment.