Skip to content

Commit 59c04db

Browse files
author
Matthew Fisher
committed
Merge pull request #2131 from bacongobbler/router_num
fix(router): publish routers to /deis/router/hosts
2 parents c27f260 + 5a3bf5a commit 59c04db

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

docs/managing_deis/router_settings.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ Settings set by router
1919
--------------------------
2020
The following etcd keys are set by the router component, typically in its /bin/boot script.
2121

22-
=========================== =================================================================================
22+
============================= ===================================================================================
2323
setting description
24-
=========================== =================================================================================
25-
/deis/router/$HOST/host IP address of the host running this router (there can be multiple routers)
26-
/deis/router/$HOST/port port used by this router service (there can be multiple routers) (default: 80)
27-
=========================== =================================================================================
24+
============================= ===================================================================================
25+
/deis/router/hosts/$HOST IP address and port of the host running this router (there can be multiple routers)
26+
============================= ===================================================================================
2827

2928
Settings used by router
3029
---------------------------

router/bin/boot

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -eo pipefail
1313
export ETCD_PORT=${ETCD_PORT:-4001}
1414
export ETCD="$HOST:$ETCD_PORT"
1515
export ETCD_PATH=${ETCD_PATH:-/deis/router}
16-
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/router/$HOST}
16+
export HOST_ETCD_PATH=${HOST_ETCD_PATH:-/deis/router/hosts/$HOST}
1717
export ETCD_TTL=${ETCD_TTL:-10}
1818

1919
# wait for etcd to be available
@@ -85,8 +85,7 @@ if [[ ! -z $EXTERNAL_PORT ]]; then
8585

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

router/tests/router_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ func TestRouter(t *testing.T) {
6060
time.Sleep(5000 * time.Millisecond)
6161
dockercli.DeisServiceTest(t, name, port, "http")
6262
etcdutils.VerifyEtcdValue(t, "/deis/router/gzip", "on", etcdPort)
63-
routerKeyPrefix := "/deis/router/" + host
64-
etcdutils.VerifyEtcdValue(t, routerKeyPrefix+"/host", host, etcdPort)
65-
etcdutils.VerifyEtcdValue(t, routerKeyPrefix+"/port", port, etcdPort)
63+
etcdutils.VerifyEtcdValue(t,
64+
"/deis/router/hosts/"+host,
65+
fmt.Sprintf("%s:%s", host, port),
66+
etcdPort)
6667
_ = cli.CmdRm("-f", name)
6768
}

0 commit comments

Comments
 (0)