Enable WEAVE_{MTU,PASSWORD} env vars, persistence and ARP settings in plugin-v2
The vars can be customized before enabling the plugin with e.g.:
docker plugin set $PLUGIN_NAME set WEAVE_MTU=8160
The ARP settings apply to "weave" bridge. In order to manipulate them,
we bind mount the host's /proc to /host/proc.
(The mount type of /proc changed to bind, Otherwise (when type =
"proc"), the kernel does not propagate pids of host processes as the
plugin runs in a separate PID ns.)
Persistence relies on weave.db which is stored under
/var/lib/weave/weave.db on the host.
NOTE: we do not persist peer list for plugin-v2, as it gets
restored from existing alive master nodes during the peer discovery.
This commit is contained in:
1 parent
4916badcc4
commit
4f42029228
3 files changed
+85
-20
No files matched your search
@@ -18,9 +18,10 @@
|
|||||||
},
|
},
|
||||||
"mounts": [
|
"mounts": [
|
||||||
{
|
{
|
||||||
"destination": "/procmount",
|
"destination": "/host/proc/",
|
||||||
"type": "proc",
|
"type": "bind",
|
||||||
"source": "proc"
|
"source": "/proc/",
|
||||||
|
"options": ["rbind", "rw"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "/var/run/docker.sock",
|
"destination": "/var/run/docker.sock",
|
||||||
@@ -29,10 +30,42 @@
|
|||||||
"options": ["rbind"]
|
"options": ["rbind"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "/var/lib/weave",
|
"destination": "/host/var/lib/",
|
||||||
"source": "/var/lib/weave",
|
"source": "/var/lib/",
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
"options": ["rbind"]
|
"options": ["rbind"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"destination": "/host/etc/",
|
||||||
|
"source": "/etc/",
|
||||||
|
"type": "bind",
|
||||||
|
"options": ["rbind"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"env": [
|
||||||
|
{
|
||||||
|
"description": "Extra args to `weaver` and `plugin`",
|
||||||
|
"name": "EXTRA_ARGS",
|
||||||
|
"settable": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Encryption password",
|
||||||
|
"name": "WEAVE_PASSWORD",
|
||||||
|
"settable": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "MTU",
|
||||||
|
"name": "WEAVE_MTU",
|
||||||
|
"settable": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"value": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"network": {
|
"network": {
|
||||||
|
|||||||
@@ -7,17 +7,26 @@ IPALLOC_RANGE=${IPALLOC_RANGE:-10.32.0.0/12}
|
|||||||
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
||||||
STATUS_ADDR=${WEAVE_STATUS_ADDR:-0.0.0.0:6782}
|
STATUS_ADDR=${WEAVE_STATUS_ADDR:-0.0.0.0:6782}
|
||||||
HOST_ROOT=${HOST_ROOT:-/host}
|
HOST_ROOT=${HOST_ROOT:-/host}
|
||||||
LOG_FILE=/var/lib/weave/weaver.log
|
WEAVE_DIR="/host/var/lib/weave"
|
||||||
|
LOG_FILE_WEAVER="$WEAVE_DIR/weaver.log"
|
||||||
|
LOG_FILE_PLUGIN="$WEAVE_DIR/plugin.log"
|
||||||
|
|
||||||
echo "Starting launch.sh" >>$LOG_FILE
|
mkdir $WEAVE_DIR || true
|
||||||
|
|
||||||
|
echo "Starting launch.sh" >>$LOG_FILE_WEAVER
|
||||||
|
|
||||||
# Check if the IP range overlaps anything existing on the host
|
# Check if the IP range overlaps anything existing on the host
|
||||||
/usr/bin/weaveutil netcheck $IPALLOC_RANGE weave
|
/usr/bin/weaveutil netcheck $IPALLOC_RANGE weave
|
||||||
|
|
||||||
SWARM_PEERS=$(/usr/bin/weaveutil swarm-manager-peers 2>>$LOG_FILE)
|
SWARM_PEERS=$(/usr/bin/weaveutil swarm-manager-peers 2>>$LOG_FILE_WEAVER)
|
||||||
! /usr/bin/weaveutil is-swarm-manager 2>>$LOG_FILE || IS_SWARM_MANAGER=1
|
! /usr/bin/weaveutil is-swarm-manager 2>>$LOG_FILE_WEAVER || IS_SWARM_MANAGER=1
|
||||||
|
# Prevent from restoring from a persisted peers list
|
||||||
|
rm -f "/restart.sentinel"
|
||||||
|
|
||||||
/home/weave/weave --local create-bridge --force >>$LOG_FILE 2>&1
|
/home/weave/weave --local create-bridge \
|
||||||
|
--proc-path=/host/proc \
|
||||||
|
--weavedb-dir-path=$WEAVE_DIR \
|
||||||
|
--force >>$LOG_FILE_WEAVER 2>&1
|
||||||
|
|
||||||
BRIDGE_OPTIONS="--datapath=datapath"
|
BRIDGE_OPTIONS="--datapath=datapath"
|
||||||
if [ "$(/home/weave/weave --local bridge-type)" = "bridge" ]; then
|
if [ "$(/home/weave/weave --local bridge-type)" = "bridge" ]; then
|
||||||
@@ -44,8 +53,10 @@ fi
|
|||||||
--ipalloc-range=$IPALLOC_RANGE \
|
--ipalloc-range=$IPALLOC_RANGE \
|
||||||
--ipalloc-init $IPALLOC_INIT \
|
--ipalloc-init $IPALLOC_INIT \
|
||||||
--nickname "$(hostname)" \
|
--nickname "$(hostname)" \
|
||||||
|
--log-level=debug \
|
||||||
|
--db-prefix="$WEAVE_DIR/weave" \
|
||||||
$(echo $SWARM_PEERS | tr '\n' ' ') \
|
$(echo $SWARM_PEERS | tr '\n' ' ') \
|
||||||
>>$LOG_FILE 2>&1 &
|
>>$LOG_FILE_WEAVER 2>&1 &
|
||||||
WEAVE_PID=$!
|
WEAVE_PID=$!
|
||||||
|
|
||||||
# Wait for weave process to become responsive
|
# Wait for weave process to become responsive
|
||||||
@@ -58,8 +69,9 @@ while true; do
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
/home/weave/plugin --meshsocket='' --docker-api='' >/var/lib/weave/plugin.log 2>&1 &
|
# TODO(mp) docker api?
|
||||||
|
/home/weave/plugin $EXTRA_ARGS --log-level=debug --meshsocket='' --docker-api='' >>$LOG_FILE_PLUGIN 2>&1 &
|
||||||
|
|
||||||
echo "End of launch.sh" >>$LOG_FILE
|
echo "End of launch.sh" >>$LOG_FILE_WEAVER
|
||||||
|
|
||||||
wait $WEAVE_PID
|
wait $WEAVE_PID
|
||||||
@@ -361,6 +361,7 @@ HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
|||||||
STATUS_ADDR=${WEAVE_STATUS_ADDR:-127.0.0.1:6782}
|
STATUS_ADDR=${WEAVE_STATUS_ADDR:-127.0.0.1:6782}
|
||||||
PROXY_PORT=12375
|
PROXY_PORT=12375
|
||||||
PROXY_CONTAINER_NAME=weaveproxy
|
PROXY_CONTAINER_NAME=weaveproxy
|
||||||
|
PROC_PATH="/proc"
|
||||||
COVERAGE_ARGS=""
|
COVERAGE_ARGS=""
|
||||||
[ -n "$COVERAGE" ] && COVERAGE_ARGS="-test.coverprofile=/home/weave/cover.prof --"
|
[ -n "$COVERAGE" ] && COVERAGE_ARGS="-test.coverprofile=/home/weave/cover.prof --"
|
||||||
|
|
||||||
@@ -442,9 +443,9 @@ delete_iptables_rule() {
|
|||||||
# makes containers react more quickly to a change in the MAC address
|
# makes containers react more quickly to a change in the MAC address
|
||||||
# associated with an IP address.
|
# associated with an IP address.
|
||||||
configure_arp_cache() {
|
configure_arp_cache() {
|
||||||
$2 sh -c "echo 5 >/proc/sys/net/ipv4/neigh/$1/base_reachable_time &&
|
$2 sh -c "echo 5 >$PROC_PATH/sys/net/ipv4/neigh/$1/base_reachable_time &&
|
||||||
echo 2 >/proc/sys/net/ipv4/neigh/$1/delay_first_probe_time &&
|
echo 2 >$PROC_PATH/sys/net/ipv4/neigh/$1/delay_first_probe_time &&
|
||||||
echo 1 >/proc/sys/net/ipv4/neigh/$1/ucast_solicit"
|
echo 1 >$PROC_PATH/sys/net/ipv4/neigh/$1/ucast_solicit"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send out an ARP announcement
|
# Send out an ARP announcement
|
||||||
@@ -725,8 +726,10 @@ init_bridge_prep() {
|
|||||||
# Running this from 'weave --local' when weaveexec is not on the
|
# Running this from 'weave --local' when weaveexec is not on the
|
||||||
# path will run it as a Docker container that does not have access
|
# path will run it as a Docker container that does not have access
|
||||||
# to /etc/machine-id, so will not give the full range of persistent IDs
|
# to /etc/machine-id, so will not give the full range of persistent IDs
|
||||||
WEAVEDB_PATH=$(docker inspect -f '{{with index .Mounts 0}}{{.Source}}{{end}}' $DB_CONTAINER_NAME 2>/dev/null)
|
if [ -z "$WEAVEDB_DIR_PATH" ]; then
|
||||||
MAC=$(util_op unique-id "$HOST_ROOT/$WEAVEDB_PATH/weave" "$HOST_ROOT")
|
WEAVEDB_DIR_PATH="$HOST_ROOT/$(docker inspect -f '{{with index .Mounts 0}}{{.Source}}{{end}}' $DB_CONTAINER_NAME 2>/dev/null)"
|
||||||
|
fi
|
||||||
|
MAC=$(util_op unique-id "$WEAVEDB_DIR_PATH/weave" "$HOST_ROOT")
|
||||||
|
|
||||||
ip link set dev $BRIDGE address $MAC
|
ip link set dev $BRIDGE address $MAC
|
||||||
|
|
||||||
@@ -1698,11 +1701,11 @@ setup_awsvpc() {
|
|||||||
# Set proxy_arp on the bridge, so that it could accept packets destined
|
# Set proxy_arp on the bridge, so that it could accept packets destined
|
||||||
# to containers within the same subnet but running on remote hosts.
|
# to containers within the same subnet but running on remote hosts.
|
||||||
# Without it, exact routes on each container are required.
|
# Without it, exact routes on each container are required.
|
||||||
echo 1 >/proc/sys/net/ipv4/conf/$BRIDGE/proxy_arp
|
echo 1 >$PROC_PATH/sys/net/ipv4/conf/$BRIDGE/proxy_arp
|
||||||
# Avoid delaying the first ARP request. Also, setting it to 0 avoids
|
# Avoid delaying the first ARP request. Also, setting it to 0 avoids
|
||||||
# placing the request into a bounded queue as it can be seen:
|
# placing the request into a bounded queue as it can be seen:
|
||||||
# https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/ipv4/arp.c?id=refs/tags/v4.6.1#n819
|
# https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/ipv4/arp.c?id=refs/tags/v4.6.1#n819
|
||||||
echo 0 >/proc/sys/net/ipv4/neigh/$BRIDGE/proxy_delay
|
echo 0 >$PROC_PATH/sys/net/ipv4/neigh/$BRIDGE/proxy_delay
|
||||||
expose_ip
|
expose_ip
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -1945,6 +1948,22 @@ case "$COMMAND" in
|
|||||||
# intentionally undocumented since it assumes knowledge of weave
|
# intentionally undocumented since it assumes knowledge of weave
|
||||||
# internals
|
# internals
|
||||||
create-bridge)
|
create-bridge)
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--proc-path=*)
|
||||||
|
PROC_PATH="${1#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--weavedb-dir-path=*)
|
||||||
|
WEAVEDB_DIR_PATH="${1#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ "$1" != "--force" ] ; then
|
if [ "$1" != "--force" ] ; then
|
||||||
cat 1>&2 <<EOF
|
cat 1>&2 <<EOF
|
||||||
WARNING: 'weave create-bridge' is deprecated. Instead use 'weave attach-bridge'
|
WARNING: 'weave create-bridge' is deprecated. Instead use 'weave attach-bridge'
|
||||||
@@ -1966,6 +1985,7 @@ EOF
|
|||||||
else
|
else
|
||||||
shift 1
|
shift 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_bridge --without-ethtool "$@"
|
create_bridge --without-ethtool "$@"
|
||||||
;;
|
;;
|
||||||
attach-bridge)
|
attach-bridge)
|
||||||
|
|||||||
Reference in new issue
Block a user