[proxy] Auto-symlink /var/run/*.sock in from /var/run/weave/*.sock
Avoids the obscure warning for users
This commit is contained in:
1 parent
f57988761c
commit
77bc22baf5
3 files changed
+18
-7
No files matched your search
+5
-3
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -283,15 +284,16 @@ func (proxy *Proxy) listen(protoAndAddr string) (net.Listener, string, error) {
|
||||
}
|
||||
|
||||
case "unix":
|
||||
localAddr := filepath.Join("/host", addr)
|
||||
// remove socket from last invocation
|
||||
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
|
||||
if err := os.Remove(localAddr); err != nil && !os.IsNotExist(err) {
|
||||
return nil, "", err
|
||||
}
|
||||
listener, err = net.Listen(proto, addr)
|
||||
listener, err = net.Listen(proto, localAddr)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if err = copyOwnerAndPermissions(dockerSock, addr); err != nil {
|
||||
if err = copyOwnerAndPermissions(dockerSock, localAddr); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
|
||||
@@ -28,4 +28,10 @@ weave_on $HOST1 stop
|
||||
weave_on $HOST1 launch-proxy -H tcp://0.0.0.0:12375 -H unix:///var/run/weave/weave.sock
|
||||
check
|
||||
|
||||
# Check we can use weave env/config with unix -Hs specified
|
||||
weave_on $HOST1 stop
|
||||
weave_on $HOST1 launch-proxy -H unix:///var/run/weave/weave.sock
|
||||
assert_raises "run_on $HOST1 'eval \$(weave env) ; docker $CMD'"
|
||||
assert_raises "run_on $HOST1 'docker \$(weave config) $CMD'"
|
||||
|
||||
end_suite
|
||||
@@ -101,6 +101,7 @@ usage() {
|
||||
exec_remote() {
|
||||
docker $DOCKER_CLIENT_ARGS run --rm --privileged --net=host \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /var/run:/host/var/run \
|
||||
-v /proc:/hostproc \
|
||||
-e PROCFS=/hostproc \
|
||||
-e DOCKERHUB_USER="$DOCKERHUB_USER" \
|
||||
@@ -1277,11 +1278,11 @@ host_arg() {
|
||||
exit 1
|
||||
fi
|
||||
if [ "$host" = "/var/run" ]; then
|
||||
echo "WARNING: Proxying sockets whose immediate parent directory is /var/run is unreliable." >&2
|
||||
echo "To work around this, put the unix socket in a subdirectory of /var/run, and symlink it into place." >&2
|
||||
host=/var/run/weave
|
||||
PROXY_VAR_RUN_SYMLINKS="$PROXY_VAR_RUN_SYMLINKS $(basename ${PROXY_HOST#unix://})"
|
||||
fi
|
||||
PROXY_VOLUMES="$PROXY_VOLUMES -v $host:/host$host"
|
||||
PROXY_ARGS="$PROXY_ARGS -H unix:///host$host/$(basename ${PROXY_HOST#unix://})"
|
||||
PROXY_ARGS="$PROXY_ARGS -H unix://$host/$(basename ${PROXY_HOST#unix://})"
|
||||
else
|
||||
PROXY_ARGS="$PROXY_ARGS -H $1"
|
||||
fi
|
||||
@@ -1561,7 +1562,6 @@ launch_proxy() {
|
||||
PROXY_CONTAINER=$(docker run --privileged -d --name=$PROXY_CONTAINER_NAME --net=host \
|
||||
$PROXY_VOLUMES \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /var/run/weave:/var/run/weave \
|
||||
-v /proc:/hostproc \
|
||||
-e PROCFS=/hostproc \
|
||||
-e WEAVE_CIDR=none \
|
||||
@@ -1571,6 +1571,9 @@ launch_proxy() {
|
||||
--entrypoint=/home/weave/weaveproxy \
|
||||
$WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $COVERAGE_ARGS $PROXY_ARGS)
|
||||
wait_for_status $PROXY_CONTAINER_NAME http_call_unix $PROXY_CONTAINER_NAME status.sock
|
||||
for sock in $PROXY_VAR_RUN_SYMLINKS; do
|
||||
ln -sf -T "/var/run/weave/$sock" "/host/var/run/$sock"
|
||||
done
|
||||
}
|
||||
|
||||
stop_proxy() {
|
||||
|
||||
Reference in new issue
Block a user