From e1edce84d9d87f43f46c6758691257d8cdfc0a83 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 14 Jun 2016 10:33:46 +0100 Subject: [PATCH 1/3] Extract checkForUpdates to its own file --- prog/weaver/checkpoint.go | 39 ++++++++++++++++++++++ prog/weaver/main.go | 32 ------------------ vendor/github.com/weaveworks/go-checkpoint | 2 +- 3 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 prog/weaver/checkpoint.go diff --git a/prog/weaver/checkpoint.go b/prog/weaver/checkpoint.go new file mode 100644 index 00000000..831babda --- /dev/null +++ b/prog/weaver/checkpoint.go @@ -0,0 +1,39 @@ +package main + +import ( + "sync/atomic" + "time" + + "github.com/weaveworks/go-checkpoint" +) + +var checker *checkpoint.Checker +var newVersion atomic.Value + +const ( + updateCheckPeriod = 6 * time.Hour +) + +func checkForUpdates() { + newVersion.Store("") + + handleResponse := func(r *checkpoint.CheckResponse, err error) { + if err != nil { + Log.Printf("Error checking version: %v", err) + return + } + if r.Outdated { + newVersion.Store(r.CurrentVersion) + 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: "", + } + checker = checkpoint.CheckInterval(¶ms, updateCheckPeriod, handleResponse) +} diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 798a1f5a..74f9662c 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -9,7 +9,6 @@ import ( "runtime" "strconv" "strings" - "sync/atomic" "time" "github.com/docker/docker/pkg/mflag" @@ -17,7 +16,6 @@ import ( "github.com/pkg/profile" "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" @@ -30,8 +28,6 @@ import ( ) var version = "(unreleased version)" -var checker *checkpoint.Checker -var newVersion atomic.Value var Log = common.Log @@ -52,34 +48,6 @@ type dnsConfig struct { EffectiveListenAddress string } -const ( - updateCheckPeriod = 6 * time.Hour -) - -func checkForUpdates() { - newVersion.Store("") - - handleResponse := func(r *checkpoint.CheckResponse, err error) { - if err != nil { - Log.Printf("Error checking version: %v", err) - return - } - if r.Outdated { - newVersion.Store(r.CurrentVersion) - 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: "", - } - checker = checkpoint.CheckInterval(¶ms, updateCheckPeriod, handleResponse) -} - func (c *ipamConfig) Enabled() bool { var ( hasPeerCount = c.PeerCount > 0 diff --git a/vendor/github.com/weaveworks/go-checkpoint b/vendor/github.com/weaveworks/go-checkpoint index b6cc8365..62324982 160000 --- a/vendor/github.com/weaveworks/go-checkpoint +++ b/vendor/github.com/weaveworks/go-checkpoint @@ -1 +1 @@ -Subproject commit b6cc8365a31bccd0b19591ba4a68704082a17141 +Subproject commit 62324982ab514860761ec81e618664580513ffad From 1fe5c65fd43c45180cdb0f9da91acce55606c21d Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 14 Jun 2016 11:36:59 +0100 Subject: [PATCH 2/3] Add kernel version, Docker version and awsvpc setting to checkpoint info --- common/docker/client.go | 9 +++++++++ prog/weaver/checkpoint.go | 26 +++++++++++++++++++++++++- prog/weaver/main.go | 9 +++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/common/docker/client.go b/common/docker/client.go index 028bf05d..00100186 100644 --- a/common/docker/client.go +++ b/common/docker/client.go @@ -84,6 +84,15 @@ func (c *Client) Info() string { return fmt.Sprintf("Docker API on %s: %v", c.Endpoint(), env) } +func (c *Client) DockerVersion() string { + if env, err := c.Version(); err == nil { + if v, found := env.Map()["Version"]; found { + return v + } + } + return "unknown" +} + // AddObserver adds an observer for docker events func (c *Client) AddObserver(ob ContainerObserver) error { go func() { diff --git a/prog/weaver/checkpoint.go b/prog/weaver/checkpoint.go index 831babda..fac1b089 100644 --- a/prog/weaver/checkpoint.go +++ b/prog/weaver/checkpoint.go @@ -2,6 +2,7 @@ package main import ( "sync/atomic" + "syscall" "time" "github.com/weaveworks/go-checkpoint" @@ -14,7 +15,7 @@ const ( updateCheckPeriod = 6 * time.Hour ) -func checkForUpdates() { +func checkForUpdates(dockerVersion string, network string) { newVersion.Store("") handleResponse := func(r *checkpoint.CheckResponse, err error) { @@ -29,11 +30,34 @@ func checkForUpdates() { } } + var uts syscall.Utsname + syscall.Uname(&uts) + flags := map[string]string{ + "docker-version": dockerVersion, + "kernel-version": charsToString(uts.Release[:]), + } + if network != "" { + flags["network"] = network + } + // Start background version checking params := checkpoint.CheckParams{ Product: "weave-net", Version: version, SignatureFile: "", + Flags: flags, } checker = checkpoint.CheckInterval(¶ms, updateCheckPeriod, handleResponse) } + +func charsToString(ca []int8) string { + s := make([]byte, len(ca)) + i := 0 + for ; i < len(ca); i++ { + if ca[i] == 0 { + break + } + s[i] = uint8(ca[i]) + } + return string(s[:i]) +} diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 74f9662c..59315d43 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -204,8 +204,6 @@ func main() { Log.Println("Command line options:", options()) - checkForUpdates() - if prof != "" { defer profile.Start(profile.CPUProfile, profile.ProfilePath(prof), profile.NoShutdownHook).Stop() } @@ -257,6 +255,13 @@ func main() { } dockerCli = dc } + + network := "" + if isAWSVPC { + network = "awsvpc" + } + checkForUpdates(dockerCli.DockerVersion(), network) + observeContainers := func(o docker.ContainerObserver) { if dockerCli != nil { if err := dockerCli.AddObserver(o); err != nil { From c12e9098823fcea8f9b6ba53986cf8c46d994ca9 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 17 Jun 2016 16:47:26 +0100 Subject: [PATCH 3/3] Document what is sent in checkpoint request --- site/installing-weave.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/site/installing-weave.md b/site/installing-weave.md index 17a6c69b..ef439d8d 100644 --- a/site/installing-weave.md +++ b/site/installing-weave.md @@ -31,12 +31,20 @@ With Weave Net downloaded onto your VMs or hosts, you are ready to launch a Weav Weave Net [periodically contacts Weaveworks servers for available versions](https://github.com/weaveworks/go-checkpoint). New versions are announced in the log and in [the status -summary](/site/troubleshooting.md#weave-status). To disable this -check, run the following before launching Weave Net: +summary](/site/troubleshooting.md#weave-status). + +The information sent in this check is: + + * Host UUID hash + * Kernel version + * Docker version + * Weave Net version + * Network mode, e.g. 'awsvpc' + +To disable this check, run the following before launching Weave Net: export CHECKPOINT_DISABLE=1 - ###Guides for Specific Platforms CoreOS users see [here](/guides/networking-docker-containers-with-weave-on-coreos/) for an example of installing Weave using cloud-config.