CommercialTribe / kube-redis

Redis on Kubernetes as StatefulSet
MIT License
34 stars 22 forks source link

sidecar.sh error "unary operator expected" #8

Closed anna-deploy closed 7 years ago

anna-deploy commented 7 years ago

After start sidecar script if redis is master sidecar.sh set label correctly at first time But after first labeled get error

root@redis-cluster-2:/app# ./sidecar.sh 
pod "redis-cluster-2" labeled
(error) ERR Duplicated master name
OK
OK
OK
Ready!
pod "redis-cluster-2" labeled
./sidecar.sh: line 166: [: !=: unary operator expected
./sidecar.sh: line 166: [: !=: unary operator expected
./sidecar.sh: line 166: [: !=: unary operator expected
./sidecar.sh: line 166: [: !=: unary operator expected
^C./sidecar.sh: line 166: [: !=: unary operator expected

At line 166

    # Don't ever allow multiple masters
     if [ "$current_role" = "master" ] ; then
>      if [ `active-master` != $ip ] ; then
         # If I am a master and not the active one, then just become a slave
         become-slave-of $master
       fi
    fi

bash -x ./sidecar.sh

++ active-master
++ master=
+++ hosts
+++ echo ''
+++ kubectl get pods -l=name=redis-cluster-node,role=none '--template={{range $i, $e :=.items}}{{$e.status.podIP}} {{end}}'
+++ sed 's/ $//'
+++ tr ' ' '\n'
+++ grep --invert-match 192.168.1.32
+++ grep -E '^[0-9]'
++ echo -n
+ '[' '!=' 192.168.1.32 ']'
./sidecar.sh: line 166: [: !=: unary operator expected
+ sleep 1
^C
anna-deploy commented 7 years ago

Found source of the problem and solution In current develop for sidecar.sh use image: commercialtribe/redis-sentinel-sidecar:v20170425.0 But in master use image: commercialtribe/redis-sentinel-sidecar:v20170816.19 After update that error was disappear