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:
Martynas Pumputis authored and Bryan Boreham committed 2017-04-12 13:05:39 +00:00
1 parent 4916badcc4
commit 4f42029228
3 files changed
+85 -20

No files matched your search

+38 -5
View File
@@ -18,9 +18,10 @@
},
"mounts": [
{
"destination": "/procmount",
"type": "proc",
"source": "proc"
"destination": "/host/proc/",
"type": "bind",
"source": "/proc/",
"options": ["rbind", "rw"]
},
{
"destination": "/var/run/docker.sock",
@@ -29,10 +30,42 @@
"options": ["rbind"]
},
{
"destination": "/var/lib/weave",
"source": "/var/lib/weave",
"destination": "/host/var/lib/",
"source": "/var/lib/",
"type": "bind",
"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": {
+20 -8
View File
@@ -7,17 +7,26 @@ IPALLOC_RANGE=${IPALLOC_RANGE:-10.32.0.0/12}
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
STATUS_ADDR=${WEAVE_STATUS_ADDR:-0.0.0.0:6782}
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
/usr/bin/weaveutil netcheck $IPALLOC_RANGE weave
SWARM_PEERS=$(/usr/bin/weaveutil swarm-manager-peers 2>>$LOG_FILE)
! /usr/bin/weaveutil is-swarm-manager 2>>$LOG_FILE || IS_SWARM_MANAGER=1
SWARM_PEERS=$(/usr/bin/weaveutil swarm-manager-peers 2>>$LOG_FILE_WEAVER)
! /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"
if [ "$(/home/weave/weave --local bridge-type)" = "bridge" ]; then
@@ -44,8 +53,10 @@ fi
--ipalloc-range=$IPALLOC_RANGE \
--ipalloc-init $IPALLOC_INIT \
--nickname "$(hostname)" \
--log-level=debug \
--db-prefix="$WEAVE_DIR/weave" \
$(echo $SWARM_PEERS | tr '\n' ' ') \
>>$LOG_FILE 2>&1 &
>>$LOG_FILE_WEAVER 2>&1 &
WEAVE_PID=$!
# Wait for weave process to become responsive
@@ -58,8 +69,9 @@ while true; do
sleep 1
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