Skip to content

Commit 0da0f80

Browse files
committed
fix(scheduler/coreos): have announcer fail if it cannot get a port
Instead of publishing an invalid upstream for the router to use, we simply check if the port is nil and exit.
1 parent bda1ed0 commit 0da0f80

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

controller/scheduler/coreos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,15 @@ def attach(self, name):
207207
TimeoutStartSec=20m
208208
"""
209209

210+
# TODO revisit the "not getting a port" issue after we upgrade to Docker 1.1.0
210211
ANNOUNCE_TEMPLATE = """
211212
[Unit]
212213
Description={name} announce
213214
BindsTo={name}.service
214215
215216
[Service]
216217
EnvironmentFile=/etc/environment
217-
ExecStartPre=/bin/sh -c "until docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name} >/dev/null 2>&1; do sleep 2; done; port=$(docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); echo Waiting for $port/tcp...; until netstat -lnt | grep :$port >/dev/null; do sleep 1; done"
218+
ExecStartPre=/bin/sh -c "until docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name} >/dev/null 2>&1; do sleep 2; done; port=$(docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); if [[ -z $port ]]; then echo We have no port...; exit 1; fi; echo Waiting for $port/tcp...; until netstat -lnt | grep :$port >/dev/null; do sleep 1; done"
218219
ExecStart=/bin/sh -c "port=$(docker inspect -f '{{{{range $i, $e := .HostConfig.PortBindings }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); echo Connected to $COREOS_PRIVATE_IPV4:$port/tcp, publishing to etcd...; while netstat -lnt | grep :$port >/dev/null; do etcdctl set /deis/services/{app}/{name} $COREOS_PRIVATE_IPV4:$port --ttl 60 >/dev/null; sleep 45; done"
219220
ExecStop=/usr/bin/etcdctl rm --recursive /deis/services/{app}/{name}
220221

0 commit comments

Comments
 (0)