introduce 'weave stop'

which, as well as stopping&removing the weave container also clears
the UDP connection tracking for the weave port, without which UDP
connections to a quickly (<3min) re-started weave would fail.

Fixes #18
This commit is contained in:
Matthias Radestock committed 2014-09-01 16:08:47 +01:00
1 parent aed818fb22
commit 0a7df2220c
2 files changed
+38 -12

No files matched your search

+14 -8
View File
@@ -30,8 +30,15 @@ To run weave on a host, you need to install...
https://raw.githubusercontent.com/zettio/weave/master/weaver/weave https://raw.githubusercontent.com/zettio/weave/master/weaver/weave
sudo chmod a+x /usr/local/bin/weave sudo chmod a+x /usr/local/bin/weave
3. ethtool. On many systems that is installed already; if not then 3. (recommended) ethtool. On many systems this is installed already;
grab it via your favourite package manager. if not then grab it via your favourite package manager. On some
systems, weave application container networking may not operate
correctly unless ethtool is available.
4. (optional) conntrack. Install this via your favourite package
manager. Without conntrack, the weave network may not re-establish
itself fully when individual weave instances are stopped (with
`weave stop`) and restarted quickly (typically within ~3 minutes).
## Example ## Example
@@ -286,12 +293,11 @@ the partition heals.
The weave container is very light-weight - just over 8MB image size The weave container is very light-weight - just over 8MB image size
and a few 10s of MBs of runtime memory - and disposable. I.e. should and a few 10s of MBs of runtime memory - and disposable. I.e. should
weave ever run into difficulty, one can simply bounce the weave weave ever run into difficulty, one can simply stop it (with `weave
container (though note stop`) and restart it. Application containers do *not* have to be
[issue #18](https://github.com/zettio/weave/issues/18)). Application restarted in that event, and indeed may not even experience a
containers do *not* have to be restarted in that event, and indeed may temporary connectivity failure if the weave container is restarted
not even experience a temporary connectivity failure if the weave quickly enough.
container is restarted quickly enough.
## Troubleshooting ## Troubleshooting
+24 -4
View File
@@ -6,6 +6,7 @@ usage() {
echo "weave launch <ipaddr>/<subnet> [-passwd <passwd>] <peer_host> ..." echo "weave launch <ipaddr>/<subnet> [-passwd <passwd>] <peer_host> ..."
echo "weave run <ipaddr>/<subnet> <docker run args> ..." echo "weave run <ipaddr>/<subnet> <docker run args> ..."
echo "weave expose <ipaddr>/<subnet>" echo "weave expose <ipaddr>/<subnet>"
echo "weave stop"
exit 1 exit 1
} }
@@ -14,16 +15,15 @@ usage() {
exit 1 exit 1
} }
[ $# -gt 1 ] || usage [ $# -gt 0 ] || usage
BRIDGE=weave BRIDGE=weave
CONTAINER_IFNAME=ethwe CONTAINER_IFNAME=ethwe
MTU=65535 MTU=65535
COMMAND=$1 COMMAND=$1
IPADDR=$2
shift 2 shift 1
create_bridge() { create_bridge() {
[ ! -d /sys/class/net/$BRIDGE ] && { [ ! -d /sys/class/net/$BRIDGE ] && {
@@ -50,6 +50,9 @@ setup_masquerading() {
case "$COMMAND" in case "$COMMAND" in
launch) launch)
[ $# -gt 0 ] || usage
IPADDR=$1
shift 1
create_bridge create_bridge
setup_masquerading setup_masquerading
# We set the router name to the bridge mac since that is # We set the router name to the bridge mac since that is
@@ -64,18 +67,35 @@ case "$COMMAND" in
IFACE=eth0 IFACE=eth0
;; ;;
run) run)
[ $# -gt 0 ] || usage
IPADDR=$1
shift 1
create_bridge create_bridge
CONTAINER=$(docker run -d "$@") CONTAINER=$(docker run -d "$@")
echo $CONTAINER echo $CONTAINER
IFACE=$CONTAINER_IFNAME IFACE=$CONTAINER_IFNAME
;; ;;
expose) expose)
[ $# -gt 0 ] || usage
IPADDR=$1
shift 1
if ! ip addr list dev $BRIDGE | grep -qF $IPADDR if ! ip addr list dev $BRIDGE | grep -qF $IPADDR
then then
ip addr add dev $BRIDGE $IPADDR ip addr add dev $BRIDGE $IPADDR
fi fi
exit 0 exit 0
;; ;;
stop)
docker kill weave > /dev/null
docker rm weave > /dev/null
if command -v conntrack >/dev/null 2>&1
then
conntrack -D -p udp --dport 6783 >/dev/null 2>&1
else
echo "Cannot find conntrack; please install it. Continuing without it." >&2
fi
exit 0
;;
*) *)
echo "Unknown weave command '$COMMAND'" echo "Unknown weave command '$COMMAND'"
usage usage
@@ -114,7 +134,7 @@ if command -v ethtool >/dev/null 2>&1
then then
ip netns exec $NSPID ethtool -K $IFACE tx off > /dev/null ip netns exec $NSPID ethtool -K $IFACE tx off > /dev/null
else else
echo "Cannot find ethtool; continuing without it" >&2 echo "Cannot find ethtool; please install it. Continuing without it." >&2
fi fi
[ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID [ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID