From bebaa48520240090820f377f5a8f22359f930f3a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 16 May 2017 13:08:06 +0000 Subject: [PATCH] Change weavedb from an emptyDir to a hostPath volume EmptyDir has the same lifetime as the pod, whereas we want our persistence to extend past that, e.g. when Weave Net is upgraded. `weave reset` cleans out the file. We assume that /var/lib is writable. --- prog/weave-kube/launch.sh | 1 + prog/weave-kube/weave-daemonset-k8s-1.6.yaml | 3 ++- prog/weave-kube/weave-daemonset.yaml | 3 ++- weave | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/prog/weave-kube/launch.sh b/prog/weave-kube/launch.sh index 62c71654..b44222bc 100755 --- a/prog/weave-kube/launch.sh +++ b/prog/weave-kube/launch.sh @@ -117,6 +117,7 @@ post_start_actions & /home/weave/weaver $EXTRA_ARGS --port=6783 $(router_bridge_opts) \ --host-root=$HOST_ROOT \ --http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \ + --db-prefix="/weavedb/weave-net" \ --ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \ --ipalloc-init $IPALLOC_INIT \ --conn-limit=$CONN_LIMIT \ diff --git a/prog/weave-kube/weave-daemonset-k8s-1.6.yaml b/prog/weave-kube/weave-daemonset-k8s-1.6.yaml index 5e2aeafc..4d08dee9 100644 --- a/prog/weave-kube/weave-daemonset-k8s-1.6.yaml +++ b/prog/weave-kube/weave-daemonset-k8s-1.6.yaml @@ -102,7 +102,8 @@ spec: type: spc_t volumes: - name: weavedb - emptyDir: {} + hostPath: + path: /var/lib/weave - name: cni-bin hostPath: path: /opt diff --git a/prog/weave-kube/weave-daemonset.yaml b/prog/weave-kube/weave-daemonset.yaml index 88aaabe7..e7dca82b 100644 --- a/prog/weave-kube/weave-daemonset.yaml +++ b/prog/weave-kube/weave-daemonset.yaml @@ -62,7 +62,8 @@ spec: restartPolicy: Always volumes: - name: weavedb - emptyDir: {} + hostPath: + path: /var/lib/weave - name: cni-bin hostPath: path: /opt diff --git a/weave b/weave index 4034599d..357e1421 100755 --- a/weave +++ b/weave @@ -126,7 +126,7 @@ docker_run_options() { exec_options() { case "$1" in - setup|setup-cni|launch) + setup|setup-cni|launch|reset) echo -v /:/host -e HOST_ROOT=/host ;; # All the other commands that may create the bridge and need machine id files. @@ -1634,6 +1634,7 @@ case "$COMMAND" in protect_against_docker_hang VOLUME_CONTAINERS=$(docker ps -qa --filter label=weavevolumes) [ -n "$VOLUME_CONTAINERS" ] && docker rm -v $VOLUME_CONTAINERS >/dev/null 2>&1 || true + rm -f $HOST_ROOT/var/lib/weave/weave-netdata.db >/dev/null 2>&1 || true destroy_bridge for LOCAL_IFNAME in $(ip link show | grep v${CONTAINER_IFNAME}pl | cut -d ' ' -f 2 | tr -d ':') ; do ip link del ${LOCAL_IFNAME%@*} >/dev/null 2>&1 || true