[proxy] dynamically mount -H dirs into the proxy when launching

This lets you use -H unix://*.sock outside /var/run/weave. Using a
socket directly in /var/run (i.e. /var/run/foo.sock), will reintroduce
the bug with namespaces not being GCed, so that is a warning.
This commit is contained in:
Paul Bellamy committed 2015-11-17 09:40:34 +00:00
1 parent d01c26e618
commit d80e72dfcd
2 files changed
+30 -6

No files matched your search

+24 -5
View File
@@ -1266,17 +1266,36 @@ tls_arg() {
PROXY_ARGS="$PROXY_ARGS $1 /home/weave/tls/$3.pem"
}
# TODO: Handle relative paths for args
# TODO: Handle args with spaces
host_arg() {
PROXY_HOST="$1"
if [ "$PROXY_HOST" != "${PROXY_HOST#unix://}" ]; then
host=$(dirname ${PROXY_HOST#unix://})
if [ "$host" = "${host#/}" ]; then
echo "When launching the proxy, unix sockets must be specified as an absolute path." >&2
exit 1
fi
if [ "$host" = "/var/run" ]; then
echo "WARNING: When launching the proxy, unix sockets directly in /var/run can lead to a bug with net namespace cleanup." >&2
echo "For more info, see https://github.com/weaveworks/weave/issues/1455" >&2
fi
PROXY_VOLUMES="$PROXY_VOLUMES -v $host:/host$host"
PROXY_ARGS="$PROXY_ARGS -H /host$host/$(basename ${PROXY_HOST#unix://})"
else
PROXY_ARGS="$PROXY_ARGS -H $1"
fi
}
proxy_parse_args() {
while [ $# -gt 0 ]; do
case "$1" in
-H)
PROXY_HOST="$2"
PROXY_ARGS="$PROXY_ARGS $1 $2"
host_arg "$2"
shift
;;
-H=*)
PROXY_HOST="${1#*=}"
PROXY_ARGS="$PROXY_ARGS $1"
host_arg "${1#*=}"
;;
-tls|--tls|-tlsverify|--tlsverify)
PROXY_TLS_ENABLED=1
@@ -1333,7 +1352,7 @@ proxy_args() {
PROXY_HOST="tcp://0.0.0.0:12375"
;;
esac
PROXY_ARGS="$PROXY_ARGS -H $PROXY_HOST"
host_arg "$PROXY_HOST"
fi
}