From b228bbb9fb5f5bde999d7f371f5d8d20f2f0523e Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 4 Feb 2016 16:35:56 +0000 Subject: [PATCH] Periocially check for up to date versions of weave. --- .gitmodules | 9 +++++++ README.md | 6 +++++ prog/weaver/main.go | 29 ++++++++++++++++++++++ vendor/github.com/certifi/gocertifi | 1 + vendor/github.com/hashicorp/go-cleanhttp | 1 + vendor/github.com/weaveworks/go-checkpoint | 1 + weave | 3 +++ 7 files changed, 50 insertions(+) create mode 160000 vendor/github.com/certifi/gocertifi create mode 160000 vendor/github.com/hashicorp/go-cleanhttp create mode 160000 vendor/github.com/weaveworks/go-checkpoint diff --git a/.gitmodules b/.gitmodules index d03fda92..27922680 100644 --- a/.gitmodules +++ b/.gitmodules @@ -58,3 +58,12 @@ [submodule "vendor/github.com/boltdb/bolt"] path = vendor/github.com/boltdb/bolt url = https://github.com/boltdb/bolt +[submodule "vendor/github.com/weaveworks/go-checkpoint"] + path = vendor/github.com/weaveworks/go-checkpoint + url = https://github.com/weaveworks/go-checkpoint +[submodule "vendor/github.com/certifi/gocertifi"] + path = vendor/github.com/certifi/gocertifi + url = https://github.com/certifi/gocertifi +[submodule "vendor/github.com/hashicorp/go-cleanhttp"] + path = vendor/github.com/hashicorp/go-cleanhttp + url = http://github.com/hashicorp/go-cleanhttp diff --git a/README.md b/README.md index 57fc2360..9242afc6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ For installing weave on other platforms, follow the [integration guides](http:// Weave respects the environment variable `DOCKER_HOST`, so you can run it locally to control a weave network on a remote host. +Weave will periodically check with our servers to see if a new version is available. To disable this, run: + +``` +CHECKPOINT_DISABLE=true weave launch +``` + ## Quick Start Screencast diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 1bd8d0be..97e20f78 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -15,6 +15,7 @@ import ( "github.com/gorilla/mux" "github.com/weaveworks/mesh" + "github.com/weaveworks/go-checkpoint" . "github.com/weaveworks/weave/common" "github.com/weaveworks/weave/common/docker" "github.com/weaveworks/weave/db" @@ -35,6 +36,32 @@ type dnsConfig struct { EffectiveListenAddress string } +const ( + signatureFile = "/etc/weave/signature" + versionCheckPeriod = 6 * time.Hour +) + +func check() { + handleResponse := func(r *checkpoint.CheckResponse, err error) { + if err != nil { + Log.Printf("Error checking version: %v", err) + } else if r.Outdated { + Log.Printf("Weave version %s is available; please update at %s", + r.CurrentVersion, r.CurrentDownloadURL) + } + } + + // Start background version checking + params := checkpoint.CheckParams{ + Product: "weave-net", + Version: version, + SignatureFile: signatureFile, + } + resp, err := checkpoint.Check(¶ms) + handleResponse(resp, err) + checkpoint.CheckInterval(¶ms, versionCheckPeriod, handleResponse) +} + func main() { procs := runtime.NumCPU() // packet sniffing can block an OS thread, so we need one thread @@ -129,6 +156,8 @@ func main() { Log.Println("Command line options:", options()) Log.Println("Command line peers:", peers) + go check() + if prof != "" { p := *profile.CPUProfile p.ProfilePath = prof diff --git a/vendor/github.com/certifi/gocertifi b/vendor/github.com/certifi/gocertifi new file mode 160000 index 00000000..f1816508 --- /dev/null +++ b/vendor/github.com/certifi/gocertifi @@ -0,0 +1 @@ +Subproject commit f1816508e036f5cb705fee34af63f2d91954f300 diff --git a/vendor/github.com/hashicorp/go-cleanhttp b/vendor/github.com/hashicorp/go-cleanhttp new file mode 160000 index 00000000..ce617e79 --- /dev/null +++ b/vendor/github.com/hashicorp/go-cleanhttp @@ -0,0 +1 @@ +Subproject commit ce617e79981a8fff618bb643d155133a8f38db96 diff --git a/vendor/github.com/weaveworks/go-checkpoint b/vendor/github.com/weaveworks/go-checkpoint new file mode 160000 index 00000000..285991b3 --- /dev/null +++ b/vendor/github.com/weaveworks/go-checkpoint @@ -0,0 +1 @@ +Subproject commit 285991b3508f51033aa288a38d242b9ad26c5274 diff --git a/weave b/weave index ef774ab3..e9608a62 100755 --- a/weave +++ b/weave @@ -131,6 +131,7 @@ exec_remote() { -e DOCKER_CLIENT_ARGS \ -e PROXY_HOST="$PROXY_HOST" \ -e COVERAGE \ + -e CHECKPOINT_DISABLE \ $WEAVEEXEC_DOCKER_ARGS $EXEC_IMAGE --local "$@" } @@ -1592,6 +1593,8 @@ launch_router() { ROUTER_CONTAINER=$(docker run --name=$CONTAINER_NAME \ -d --privileged --net=host $(docker_sock_options) \ -e WEAVE_PASSWORD \ + -e CHECKPOINT_DISABLE \ + -v /etc/weave:/etc/weave \ $WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \ --port $CONTAINER_PORT --name "$PEERNAME" --nickname "$(hostname)" \ $(router_opts_$BRIDGE_TYPE) \