File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ sleep $(($ETCD_TTL+1))
3030
3131function etcd_safe_mkdir {
3232 set +e
33- etcdctl --no-sync -C $ETCD mkdir $1 > /dev/null 2>&1
34- if [[ $? -ne 0 && $? -ne 4 ]]; then
35- echo " etcd_safe_mkdir: an etcd error occurred. aborting..."
33+ ERROR=" $( etcdctl --no-sync -C $ETCD mkdir $1 2>&1 > /dev/null) "
34+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
35+ echo " etcd_safe_mkdir: an etcd error occurred ($ERROR )"
36+ echo " aborting..."
3637 exit 1
3738 fi
3839 set -e
Original file line number Diff line number Diff line change @@ -26,19 +26,21 @@ sleep $(($ETCD_TTL+1))
2626
2727function etcd_set_default {
2828 set +e
29- etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 > /dev/null 2>&1
30- if [[ $? -ne 0 && $? -ne 4 ]]; then
31- echo " etcd_set_default: an etcd error occurred. aborting..."
29+ ERROR=" $( etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 2>&1 > /dev/null) "
30+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
31+ echo " etcd_set_default: an etcd error occurred ($ERROR )"
32+ echo " aborting..."
3233 exit 1
3334 fi
3435 set -e
3536}
3637
3738function etcd_safe_mkdir {
3839 set +e
39- etcdctl --no-sync -C $ETCD mkdir $1 > /dev/null 2>&1
40- if [[ $? -ne 0 && $? -ne 4 ]]; then
41- echo " etcd_safe_mkdir: an etcd error occurred. aborting..."
40+ ERROR=" $( etcdctl --no-sync -C $ETCD mkdir $1 2>&1 > /dev/null) "
41+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
42+ echo " etcd_safe_mkdir: an etcd error occurred ($ERROR )"
43+ echo " aborting..."
4244 exit 1
4345 fi
4446 set -e
Original file line number Diff line number Diff line change @@ -28,9 +28,10 @@ sleep $(($ETCD_TTL+1))
2828
2929function etcd_set_default {
3030 set +e
31- etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 > /dev/null 2>&1
32- if [[ $? -ne 0 && $? -ne 4 ]]; then
33- echo " etcd_set_default: an etcd error occurred. aborting..."
31+ ERROR=" $( etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 2>&1 > /dev/null) "
32+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
33+ echo " etcd_set_default: an etcd error occurred ($ERROR )"
34+ echo " aborting..."
3435 exit 1
3536 fi
3637 set -e
Original file line number Diff line number Diff line change @@ -32,9 +32,10 @@ sleep $(($ETCD_TTL+1))
3232
3333function etcd_set_default {
3434 set +e
35- etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 > /dev/null 2>&1
36- if [[ $? -ne 0 && $? -ne 4 ]]; then
37- echo " etcd_set_default: an etcd error occurred. aborting..."
35+ ERROR=" $( etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 2>&1 > /dev/null) "
36+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
37+ echo " etcd_set_default: an etcd error occurred ($ERROR )"
38+ echo " aborting..."
3839 exit 1
3940 fi
4041 set -e
Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ HOSTNAME=`hostname`
1010
1111function etcd_set_default {
1212 set +e
13- etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 > /dev/null 2>&1
14- if [[ $? -ne 0 && $? -ne 4 ]]; then
15- echo " etcd_set_default: an etcd error occurred. aborting..."
13+ ERROR=" $( etcdctl --no-sync -C $ETCD mk $ETCD_PATH /$1 $2 2>&1 > /dev/null) "
14+ if [[ $? -ne 0 && $( echo $ERROR | grep -ive " key already exists" ) ]]; then
15+ echo " etcd_set_default: an etcd error occurred ($ERROR )"
16+ echo " aborting..."
1617 exit 1
1718 fi
1819 set -e
You can’t perform that action at this time.
0 commit comments