From e51f89268c0b03ffc8ab3f5d176d15b09a7f0b60 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 18 Sep 2014 05:50:13 +0100 Subject: [PATCH 1/7] Stop waiting for interface after 5 seconds --- weaver/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/weaver/main.go b/weaver/main.go index 63bb60d1..a16aabc9 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -24,11 +24,15 @@ func ensureInterface(ifaceName string, wait bool) (iface *net.Interface, err err return } log.Println("Waiting for interface", ifaceName, "to come up") - for err != nil { + count := 0 + for err != nil && count < 5 { + count += 1 time.Sleep(1 * time.Second) iface, err = findInterface(ifaceName) } - log.Println("Interface", ifaceName, "is up") + if err == nil { + log.Println("Interface", ifaceName, "is up") + } return } @@ -47,6 +51,7 @@ func main() { log.SetPrefix(weave.Protocol + " ") log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) + log.Println(os.Args) procs := runtime.NumCPU() // packet sniffing can block an OS thread, so we need one thread @@ -87,6 +92,9 @@ func main() { if err != nil { log.Fatal(err) } + if wait && iface == nil { + os.Exit(1) + } if connLimit < 0 { connLimit = 0 From add13ff8578365158b25a7c82b0c539227003da5 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 18 Sep 2014 06:18:43 +0100 Subject: [PATCH 2/7] Add section to README on reboots --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 475ec6b2..4f86dfe6 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,28 @@ Any running application containers will permanently lose connectivity with the weave network and have to be restarted in order to re-connect. +### Reboots + +If the host you are running your containers on gets rebooted, the +default behaviour of Docker is to restart any containers that were +running, but weave relies on a bridge and virtual ethernet devices +being set up outside of the containers, so the weave network will not +function in this state. + +For the weave router, the best thing is to stop any container that +Docker may have restarted and re-launch, i.e. something like: + + host1# weave stop + host1# weave launch 10.0.0.1/16 + +After that, other containers may be re-attached if you can identify +them, like this: + + host1# weave attach 10.0.1.1/24 + +Alternatively, you may prefer to disable the auto-restart feature in +Docker as described [here](https://docs.docker.com/articles/host_integration/). + ## Installation with Boot2Docker If you are running Docker inside the Boot2Docker VM, e.g. because you From 5b935770541927dc737fd8535b8d0530c49e1d49 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 22 Sep 2014 16:42:18 +0100 Subject: [PATCH 3/7] log.Fatal() does os.Exit(1) so we don't need to do it again --- weaver/main.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/weaver/main.go b/weaver/main.go index a16aabc9..4ff2349d 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -92,9 +92,6 @@ func main() { if err != nil { log.Fatal(err) } - if wait && iface == nil { - os.Exit(1) - } if connLimit < 0 { connLimit = 0 From 0d3eebb208854cb0c6fccc84e043d0482a27fbe4 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 22 Sep 2014 16:48:55 +0100 Subject: [PATCH 4/7] Change -wait from bool to int number of seconds to wait --- weaver/Dockerfile | 2 +- weaver/main.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/weaver/Dockerfile b/weaver/Dockerfile index adf86d35..9baf50bb 100644 --- a/weaver/Dockerfile +++ b/weaver/Dockerfile @@ -3,4 +3,4 @@ MAINTAINER Zettio weave@zett.io WORKDIR /home/weave ADD ./weaver /home/weave/ CMD [] -ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait"] +ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait", "5"] diff --git a/weaver/main.go b/weaver/main.go index 4ff2349d..bd9014c0 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -18,15 +18,13 @@ import ( "time" ) -func ensureInterface(ifaceName string, wait bool) (iface *net.Interface, err error) { +func ensureInterface(ifaceName string, wait int) (iface *net.Interface, err error) { iface, err = findInterface(ifaceName) - if err == nil || !wait { + if err == nil || wait == 0 { return } log.Println("Waiting for interface", ifaceName, "to come up") - count := 0 - for err != nil && count < 5 { - count += 1 + for ; err != nil && wait > 0; wait -= 1 { time.Sleep(1 * time.Second) iface, err = findInterface(ifaceName) } @@ -65,7 +63,7 @@ func main() { ifaceName string routerName string password string - wait bool + wait int debug bool prof string peers []string @@ -76,7 +74,7 @@ func main() { flag.StringVar(&ifaceName, "iface", "", "name of interface to read from") flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)") flag.StringVar(&password, "password", "", "network password") - flag.BoolVar(&wait, "wait", false, "wait for interface to be created and come up") + flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up") flag.BoolVar(&debug, "debug", false, "enable debug logging") flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path") flag.IntVar(&connLimit, "connlimit", 10, "connection limit (defaults to 10, set to 0 for unlimited)") From 02efccc36ae41493a1948e7b9c8c28523ff6d247 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 23 Sep 2014 16:18:00 +0100 Subject: [PATCH 5/7] cosmetic --- weaver/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weaver/main.go b/weaver/main.go index bd9014c0..3ca078db 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -74,7 +74,7 @@ func main() { flag.StringVar(&ifaceName, "iface", "", "name of interface to read from") flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)") flag.StringVar(&password, "password", "", "network password") - flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up") + flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up (defaults to 0, i.e. don't wait)") flag.BoolVar(&debug, "debug", false, "enable debug logging") flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path") flag.IntVar(&connLimit, "connlimit", 10, "connection limit (defaults to 10, set to 0 for unlimited)") From d10ce1e801f19ac44f8d8f1cfc763365d70a34d6 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 23 Sep 2014 17:24:52 +0100 Subject: [PATCH 6/7] reword --- README.md | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ff45947c..a6a109e8 100644 --- a/README.md +++ b/README.md @@ -434,25 +434,18 @@ re-connect. ### Reboots -If the host you are running your containers on gets rebooted, the -default behaviour of Docker is to restart any containers that were -running, but weave relies on a bridge and virtual ethernet devices -being set up outside of the containers, so the weave network will not +When a host reboots, docker's default behaviour is to restart any +containers that were running. Since weave relies on special network +configuration outside of the containers, the weave network will not function in this state. -For the weave router, the best thing is to stop any container that -Docker may have restarted and re-launch, i.e. something like: +To remedy this, stop and re-launch the weave container, and re-attach +the application containers with `weave attach`. - host1# weave stop - host1# weave launch 10.0.0.1/16 - -After that, other containers may be re-attached if you can identify -them, like this: - - host1# weave attach 10.0.1.1/24 - -Alternatively, you may prefer to disable the auto-restart feature in -Docker as described [here](https://docs.docker.com/articles/host_integration/). +For a mor permanent solution, +[disable Docker's auto-restart feature](https://docs.docker.com/articles/host_integration/), +and create appropriate startup scripts to launch weave and run +application containers from your favourite process manager. ## Installation with Boot2Docker From ebe8207f8adaf7fb7f73efa98ad36f47ac30ebe3 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 24 Sep 2014 12:23:51 +0100 Subject: [PATCH 7/7] typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a6a109e8..4b2cb115 100644 --- a/README.md +++ b/README.md @@ -442,8 +442,8 @@ function in this state. To remedy this, stop and re-launch the weave container, and re-attach the application containers with `weave attach`. -For a mor permanent solution, -[disable Docker's auto-restart feature](https://docs.docker.com/articles/host_integration/), +For a more permanent solution, +[disable Docker's auto-restart feature](https://docs.docker.com/articles/host_integration/) and create appropriate startup scripts to launch weave and run application containers from your favourite process manager.