Browse code

Make etcd3 setup work with IPv6 addresses

The client are told to connect to SERVICE_HOST instead of HOST_IP, so
we need to start etcd3 with matching listening parameters.

Change-Id: I96389090180d21d25d72df8f9e8905b850bcaee9
Partial-Bug: 1656329

Jens Harbott authored on 2017/09/20 15:18:08
Showing 1 changed files
... ...
@@ -40,9 +40,13 @@ function start_etcd3 {
40 40
     cmd+=" --initial-cluster-state new --initial-cluster-token etcd-cluster-01"
41 41
     cmd+=" --initial-cluster $HOSTNAME=http://$SERVICE_HOST:2380"
42 42
     cmd+=" --initial-advertise-peer-urls http://$SERVICE_HOST:2380"
43
-    cmd+=" --advertise-client-urls http://${HOST_IP}:$ETCD_PORT"
44
-    cmd+=" --listen-peer-urls http://0.0.0.0:2380 "
45
-    cmd+=" --listen-client-urls http://${HOST_IP}:$ETCD_PORT"
43
+    cmd+=" --advertise-client-urls http://$SERVICE_HOST:$ETCD_PORT"
44
+    if [ "$SERVICE_LISTEN_ADDRESS" == "::" ]; then
45
+        cmd+=" --listen-peer-urls http://[::]:2380 "
46
+    else
47
+        cmd+=" --listen-peer-urls http://0.0.0.0:2380 "
48
+    fi
49
+    cmd+=" --listen-client-urls http://$SERVICE_HOST:$ETCD_PORT"
46 50
 
47 51
     local unitfile="$SYSTEMD_DIR/$ETCD_SYSTEMD_SERVICE"
48 52
     write_user_unit_file $ETCD_SYSTEMD_SERVICE "$cmd" "" "root"