Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4b3a68531 | ||
|
|
ee7a3e48c9 | ||
|
|
ba27fd6523 | ||
|
|
2d43b92572 | ||
|
|
e9469b88af | ||
|
|
0af9b2cbab | ||
|
|
734a3abae8 | ||
|
|
cd985c1bed | ||
|
|
b8e4ad1314 | ||
|
|
da3d343f26 | ||
|
|
618de144d9 | ||
|
|
82b54aabcd | ||
|
|
1fc37bf8df | ||
|
|
e33885ecca | ||
|
|
57e86a8796 | ||
|
|
eb628ec84a | ||
|
|
7b6ea37fea | ||
|
|
dd34099e06 | ||
|
|
5da2219dc8 | ||
|
|
fd6f65e28f | ||
|
|
edabd8393d | ||
|
|
82423ad466 | ||
|
|
5f69637f31 | ||
|
|
2a1a40c05e | ||
|
|
2481079957 | ||
|
|
87b3537b54 | ||
|
|
859878c004 | ||
|
|
00832dcbb5 | ||
|
|
57856a5584 | ||
|
|
d3002384d7 | ||
|
|
a2fcda9267 |
No files matched your search
@@ -27,5 +27,7 @@ _testmain.go
|
|||||||
*~
|
*~
|
||||||
|
|
||||||
# Project specific
|
# Project specific
|
||||||
|
weaver/weaver
|
||||||
weavedns/weavedns
|
weavedns/weavedns
|
||||||
|
tools/bin
|
||||||
releases
|
releases
|
||||||
+29
-3
@@ -1,4 +1,30 @@
|
|||||||
== Release 0.7.0
|
## Release 0.8.0
|
||||||
|
|
||||||
This is the first release assigned a version number. See the README at
|
- Align script and image version. When the `weave` script has a
|
||||||
https://github.com/zettio/weave#readme for more information.
|
version number, i.e. it is part of an official release, it runs
|
||||||
|
docker images matching that version. Thus the script and image
|
||||||
|
versions are automatically aligned. Unversioned/unreleased `weave`
|
||||||
|
scripts run the 'latest'-tagged image versions.
|
||||||
|
|
||||||
|
- Eliminate dependency on ethtool and conntrack. Instead of requiring
|
||||||
|
these to be installed on the host, weave invokes them via a
|
||||||
|
`weavetools` docker image that contains minimally packaged versions
|
||||||
|
of these utilities.
|
||||||
|
|
||||||
|
- New `weave setup` command. This downloads all docker images used by
|
||||||
|
weave. Invoking this is strictly optional; its main purpose is to
|
||||||
|
facilitate automated installation of weave and preventing delays in
|
||||||
|
subsequent weave command execution due to image downloading.
|
||||||
|
|
||||||
|
## Release 0.7.0
|
||||||
|
|
||||||
|
This is the first release assigned a version number.
|
||||||
|
|
||||||
|
When downloading weave you now have the following choices...
|
||||||
|
|
||||||
|
1. a specific version, e.g. https://github.com/zettio/weave/releases/download/v0.7.0/weave
|
||||||
|
2. latest released version: https://github.com/zettio/weave/releases/download/latest_release/weave
|
||||||
|
3. most recent 'master' commit: https://raw.githubusercontent.com/zettio/weave/master/weave
|
||||||
|
|
||||||
|
Previously the only documented download location was (3). We recommend
|
||||||
|
that any automated scripts using that be changed to either (1) or (2).
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
.DEFAULT: all
|
.DEFAULT: all
|
||||||
.PHONY: all publish clean tests
|
.PHONY: all update tests clean
|
||||||
|
|
||||||
# If you can use docker without being root, you can do "make SUDO="
|
# If you can use docker without being root, you can do "make SUDO="
|
||||||
SUDO=sudo
|
SUDO=sudo
|
||||||
@@ -7,15 +7,21 @@ SUDO=sudo
|
|||||||
WEAVE_VERSION=git-$(shell git rev-parse --short=12 HEAD)
|
WEAVE_VERSION=git-$(shell git rev-parse --short=12 HEAD)
|
||||||
WEAVER_EXE=weaver/weaver
|
WEAVER_EXE=weaver/weaver
|
||||||
WEAVEDNS_EXE=weavedns/weavedns
|
WEAVEDNS_EXE=weavedns/weavedns
|
||||||
|
WEAVETOOLS_EXES=tools/bin
|
||||||
WEAVER_IMAGE=zettio/weave
|
WEAVER_IMAGE=zettio/weave
|
||||||
WEAVEDNS_IMAGE=zettio/weavedns
|
WEAVEDNS_IMAGE=zettio/weavedns
|
||||||
|
WEAVETOOLS_IMAGE=zettio/weavetools
|
||||||
WEAVER_EXPORT=/var/tmp/weave.tar
|
WEAVER_EXPORT=/var/tmp/weave.tar
|
||||||
WEAVEDNS_EXPORT=/var/tmp/weavedns.tar
|
WEAVEDNS_EXPORT=/var/tmp/weavedns.tar
|
||||||
|
WEAVETOOLS_EXPORT=/var/tmp/weavetools.tar
|
||||||
|
|
||||||
all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT)
|
all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
|
||||||
|
|
||||||
|
update:
|
||||||
|
go get -u -f -v -tags -netgo ./$(dir $(WEAVER_EXE)) ./$(dir $(WEAVEDNS_EXE))
|
||||||
|
|
||||||
$(WEAVER_EXE) $(WEAVEDNS_EXE):
|
$(WEAVER_EXE) $(WEAVEDNS_EXE):
|
||||||
go get -tags netgo ./$(shell dirname $@)
|
go get -tags netgo ./$(@D)
|
||||||
go build -ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -o $@ ./$(shell dirname $@)
|
go build -ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -o $@ ./$(shell dirname $@)
|
||||||
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
||||||
rm $@; \
|
rm $@; \
|
||||||
@@ -29,6 +35,9 @@ $(WEAVER_EXE) $(WEAVEDNS_EXE):
|
|||||||
$(WEAVER_EXE): router/*.go weaver/main.go
|
$(WEAVER_EXE): router/*.go weaver/main.go
|
||||||
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go
|
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go
|
||||||
|
|
||||||
|
$(WEAVETOOLS_EXES): tools/build.sh
|
||||||
|
$(SUDO) docker run --rm -v $(realpath $(<D)):/home/weave ubuntu sh /home/weave/build.sh
|
||||||
|
|
||||||
$(WEAVER_EXPORT): weaver/Dockerfile $(WEAVER_EXE)
|
$(WEAVER_EXPORT): weaver/Dockerfile $(WEAVER_EXE)
|
||||||
$(SUDO) docker build -t $(WEAVER_IMAGE) weaver
|
$(SUDO) docker build -t $(WEAVER_IMAGE) weaver
|
||||||
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
|
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
|
||||||
@@ -37,10 +46,15 @@ $(WEAVEDNS_EXPORT): weavedns/Dockerfile $(WEAVEDNS_EXE)
|
|||||||
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) weavedns
|
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) weavedns
|
||||||
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@
|
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@
|
||||||
|
|
||||||
|
$(WEAVETOOLS_EXPORT): tools/Dockerfile $(WEAVETOOLS_EXES)
|
||||||
|
$(SUDO) docker build -t $(WEAVETOOLS_IMAGE) tools
|
||||||
|
$(SUDO) docker save $(WEAVETOOLS_IMAGE):latest > $@
|
||||||
|
|
||||||
# Add more directories in here as more tests are created
|
# Add more directories in here as more tests are created
|
||||||
tests:
|
tests:
|
||||||
cd nameserver; go test -tags netgo
|
cd nameserver; go test -tags netgo
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE)
|
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVETOOLS_IMAGE)
|
||||||
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT)
|
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
|
||||||
|
$(SUDO) rm -rf $(WEAVETOOLS_EXES)
|
||||||
@@ -27,26 +27,12 @@ capabilities, so these can continue to be used by containers.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To run weave on a host, you need to install...
|
Ensure you are running Linux (kernel 3.5 or later) and have Docker
|
||||||
|
(version 0.9.1 or later) installed. Then install weave with
|
||||||
|
|
||||||
1. Linux and Docker. We've tested with Docker versions 0.9.1 through
|
sudo wget -O /usr/local/bin/weave \
|
||||||
1.3.1, but other versions should work too. Linux kernels after 3.5
|
https://github.com/zettio/weave/releases/download/latest_release/weave
|
||||||
are known to work; the newer the better.
|
sudo chmod a+x /usr/local/bin/weave
|
||||||
2. weave. Install this with
|
|
||||||
|
|
||||||
sudo wget -O /usr/local/bin/weave \
|
|
||||||
https://raw.githubusercontent.com/zettio/weave/master/weave
|
|
||||||
sudo chmod a+x /usr/local/bin/weave
|
|
||||||
|
|
||||||
3. (recommended) ethtool. On many systems this is installed already;
|
|
||||||
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).
|
|
||||||
|
|
||||||
## Quick Start Screencast
|
## Quick Start Screencast
|
||||||
|
|
||||||
@@ -66,7 +52,13 @@ On `$HOST1` run (as root)
|
|||||||
host1# C=$(weave run 10.0.1.1/24 -t -i ubuntu)
|
host1# C=$(weave run 10.0.1.1/24 -t -i ubuntu)
|
||||||
|
|
||||||
The first line starts the weave router, in a container. This needs to
|
The first line starts the weave router, in a container. This needs to
|
||||||
be done once on each host.
|
be done once on each host. The required docker image for the weave
|
||||||
|
router container is downloaded automatically. There is also a `weave
|
||||||
|
setup` command for downloading this and other images required for
|
||||||
|
weave operation; this is a strictly optional step which is especially
|
||||||
|
useful for automated installation of weave and ensures that any
|
||||||
|
subsequent weave commands do not encounter delays due to image
|
||||||
|
downloading.
|
||||||
|
|
||||||
The second line runs our application container. We give it an IP
|
The second line runs our application container. We give it an IP
|
||||||
address and network, in
|
address and network, in
|
||||||
|
|||||||
Vendored
+10
-5
@@ -1,7 +1,7 @@
|
|||||||
VAGRANTFILE_API_VERSION = "2"
|
VAGRANTFILE_API_VERSION = "2"
|
||||||
|
|
||||||
vm_ip = "172.16.0.3" # arbitrary private IP
|
vm_ip = "172.16.0.3" # arbitrary private IP
|
||||||
pkgs = "lxc-docker golang ethtool libpcap-dev git mercurial"
|
pkgs = "lxc-docker build-essential ethtool libpcap-dev git mercurial"
|
||||||
|
|
||||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
config.vm.box = "phusion/ubuntu-14.04-amd64"
|
config.vm.box = "phusion/ubuntu-14.04-amd64"
|
||||||
@@ -14,14 +14,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||||||
config.vm.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9"
|
config.vm.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9"
|
||||||
config.vm.provision :shell, :inline => "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
|
config.vm.provision :shell, :inline => "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
|
||||||
|
|
||||||
pkg_cmd = "apt-get update -qq; " \
|
pkg_cmd = "export DEBIAN_FRONTEND=noninteractive; " \
|
||||||
"apt-get install -q -y --force-yes --no-install-recommends "
|
"apt-get update -qq; " \
|
||||||
pkg_cmd << pkgs
|
"apt-get install -qq --no-install-recommends #{pkgs}"
|
||||||
|
|
||||||
|
install_go_toolchain = "curl -s https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | tar xz -C /usr/local"
|
||||||
|
|
||||||
config.vm.provision :shell, :inline => pkg_cmd
|
config.vm.provision :shell, :inline => pkg_cmd
|
||||||
|
config.vm.provision :shell, :inline => install_go_toolchain
|
||||||
config.vm.provision :shell, :inline => "usermod -a -G docker vagrant; "
|
config.vm.provision :shell, :inline => "usermod -a -G docker vagrant; "
|
||||||
config.vm.provision :shell, :inline => "echo export GOPATH=/home/vagrant >> /home/vagrant/.bashrc"
|
config.vm.provision :shell, :inline => "echo export GOPATH=/home/vagrant >> /home/vagrant/.bashrc"
|
||||||
|
config.vm.provision :shell, :inline => "echo export PATH=/usr/local/go/bin:${PATH} >> /home/vagrant/.bashrc"
|
||||||
config.vm.provision :shell, :inline => "chown -R vagrant:vagrant /home/vagrant/src"
|
config.vm.provision :shell, :inline => "chown -R vagrant:vagrant /home/vagrant/src"
|
||||||
config.vm.provision :shell, :inline => "sudo go install -a -tags netgo std"
|
config.vm.provision :shell, :inline => "/usr/local/go/bin/go clean -i net; /usr/local/go/bin/go install -tags netgo std"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -37,7 +37,7 @@ build() {
|
|||||||
cd $RELEASE_DIR
|
cd $RELEASE_DIR
|
||||||
|
|
||||||
## Check that the top changelog entry is this version
|
## Check that the top changelog entry is this version
|
||||||
if ! latest_changelog=$(grep -o "== Release [0-9].*" -m1 ./CHANGELOG.md) || \
|
if ! latest_changelog=$(grep -o "## Release [0-9].*" -m1 ./CHANGELOG.md) || \
|
||||||
! [ `echo "$latest_changelog" | grep -o '[0-9][^ ]*'` == "$VERSION" ]; then
|
! [ `echo "$latest_changelog" | grep -o '[0-9][^ ]*'` == "$VERSION" ]; then
|
||||||
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
|
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -121,14 +121,13 @@ publish() {
|
|||||||
|
|
||||||
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/weave:$VERSION
|
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/weave:$VERSION
|
||||||
|
|
||||||
echo == Tagging $DOCKERHUB_USER/weave and $DOCKERHUB_USER/weavedns as $VERSION
|
for IMAGE in weave weavedns weavetools ; do
|
||||||
docker tag $DOCKERHUB_USER/weave $DOCKERHUB_USER/weave:$VERSION
|
echo == Tagging $DOCKERHUB_USER/$IMAGE as $VERSION
|
||||||
docker tag $DOCKERHUB_USER/weavedns $DOCKERHUB_USER/weavedns:$VERSION
|
docker tag $DOCKERHUB_USER/$IMAGE $DOCKERHUB_USER/$IMAGE:$VERSION
|
||||||
|
docker push $DOCKERHUB_USER/$IMAGE:$VERSION
|
||||||
docker push $DOCKERHUB_USER/weave:$VERSION
|
docker push $DOCKERHUB_USER/$IMAGE:latest
|
||||||
echo "** Pushed $DOCKERHUB_USER/weave:$VERSION to docker hub"
|
echo "** Pushed $DOCKERHUB_USER/$IMAGE:$VERSION to docker hub"
|
||||||
docker push $DOCKERHUB_USER/weavedns:$VERSION
|
done
|
||||||
echo "** Pushed $DOCKERHUB_USER/weavedns:$VERSION to docker hub"
|
|
||||||
|
|
||||||
echo "== Creating GitHub release $RELEASE_NAME $VERSION"
|
echo "== Creating GitHub release $RELEASE_NAME $VERSION"
|
||||||
# This cannot be done as a draft because of a bug in
|
# This cannot be done as a draft because of a bug in
|
||||||
@@ -173,7 +172,7 @@ publish() {
|
|||||||
--file "./weave"
|
--file "./weave"
|
||||||
|
|
||||||
echo "** Published $RELEASE_NAME as latest_release at"
|
echo "** Published $RELEASE_NAME as latest_release at"
|
||||||
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/latest_release"
|
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/latest_release"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
InitLogging(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package nameserver
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
@@ -32,6 +32,10 @@ func InitLogging(debugHandle io.Writer,
|
|||||||
Error = log.New(errorHandle, "ERROR: ", standardLogFlags)
|
Error = log.New(errorHandle, "ERROR: ", standardLogFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func InitDefaultLogging(debug bool) {
|
||||||
InitLogging(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
|
debugOut := ioutil.Discard
|
||||||
|
if debug {
|
||||||
|
debugOut = os.Stderr
|
||||||
|
}
|
||||||
|
InitLogging(debugOut, os.Stdout, os.Stdout, os.Stderr)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CallSite() string {
|
||||||
|
_, file, line, ok := runtime.Caller(2)
|
||||||
|
if ok {
|
||||||
|
// Truncate file name at last file name separator.
|
||||||
|
if index := strings.LastIndex(file, "/"); index >= 0 {
|
||||||
|
file = file[index+1:]
|
||||||
|
} else if index = strings.LastIndex(file, "\\"); index >= 0 {
|
||||||
|
file = file[index+1:]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file = "???"
|
||||||
|
line = 1
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s:%d: ", file, line)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertNoErr(t *testing.T, err error) {
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(CallSite(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertStatus(t *testing.T, got int, wanted int, desc string) {
|
||||||
|
if got != wanted {
|
||||||
|
t.Fatalf("%s: Expected %s %d but got %d", CallSite(), desc, wanted, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertErrorInterface(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||||
|
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||||
|
if !gotT.Implements(wantedT) {
|
||||||
|
t.Fatalf("%s: Expected %s but got %s (%s)", CallSite(), wantedT.String(), gotT.String(), desc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertErrorType(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||||
|
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||||
|
if gotT != wantedT {
|
||||||
|
t.Fatalf("%s: Expected %s but got %s (%s)", CallSite(), wantedT.String(), gotT.String(), desc)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
. "github.com/zettio/weave/common"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
+14
-13
@@ -2,6 +2,7 @@ package nameserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
wt "github.com/zettio/weave/common"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -38,12 +39,12 @@ func TestHttp(t *testing.T) {
|
|||||||
addrUrl := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, containerID, addrParts[0])
|
addrUrl := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, containerID, addrParts[0])
|
||||||
resp, err := genForm("PUT", addrUrl,
|
resp, err := genForm("PUT", addrUrl,
|
||||||
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
assertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
||||||
|
|
||||||
// Check that the address is now there.
|
// Check that the address is now there.
|
||||||
foundIP, err := zone.LookupLocal(successTestName)
|
foundIP, err := zone.LookupLocal(successTestName)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
ip, _, _ := net.ParseCIDR(testAddr1)
|
ip, _, _ := net.ParseCIDR(testAddr1)
|
||||||
if !foundIP.Equal(ip) {
|
if !foundIP.Equal(ip) {
|
||||||
t.Fatal("Unexpected result for", successTestName, foundIP)
|
t.Fatal("Unexpected result for", successTestName, foundIP)
|
||||||
@@ -52,34 +53,34 @@ func TestHttp(t *testing.T) {
|
|||||||
// Adding exactly the same address should be OK
|
// Adding exactly the same address should be OK
|
||||||
resp, err = genForm("PUT", addrUrl,
|
resp, err = genForm("PUT", addrUrl,
|
||||||
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
assertStatus(t, resp.StatusCode, http.StatusOK, "http success response for duplicate add")
|
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http success response for duplicate add")
|
||||||
|
|
||||||
// Now try adding the same address again with a different ident --
|
// Now try adding the same address again with a different ident --
|
||||||
// again should be fine
|
// again should be fine
|
||||||
otherUrl := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, "other", addrParts[0])
|
otherUrl := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, "other", addrParts[0])
|
||||||
resp, err = genForm("PUT", otherUrl,
|
resp, err = genForm("PUT", otherUrl,
|
||||||
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
assertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
||||||
|
|
||||||
// Delete the address
|
// Delete the address
|
||||||
resp, err = genForm("DELETE", addrUrl, nil)
|
resp, err = genForm("DELETE", addrUrl, nil)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
assertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
||||||
|
|
||||||
// Check that the address is still resolvable.
|
// Check that the address is still resolvable.
|
||||||
_, err = zone.LookupLocal(successTestName)
|
_, err = zone.LookupLocal(successTestName)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
// Delete the address record mentioning the other container
|
// Delete the address record mentioning the other container
|
||||||
resp, err = genForm("DELETE", otherUrl, nil)
|
resp, err = genForm("DELETE", otherUrl, nil)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
assertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
|
||||||
|
|
||||||
// Check that the address is gone
|
// Check that the address is gone
|
||||||
_, err = zone.LookupLocal(successTestName)
|
_, err = zone.LookupLocal(successTestName)
|
||||||
assertErrorType(t, err, (*LookupError)(nil), "fully-removed address")
|
wt.AssertErrorType(t, err, (*LookupError)(nil), "fully-removed address")
|
||||||
|
|
||||||
// Would like to shut down the http server at the end of this test
|
// Would like to shut down the http server at the end of this test
|
||||||
// but it's complicated.
|
// but it's complicated.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package nameserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
wt "github.com/zettio/weave/common"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -61,9 +62,9 @@ func RunLocalMulticastServer() (*dns.Server, error) {
|
|||||||
|
|
||||||
func setup(t *testing.T) (*MDNSClient, *dns.Server, error) {
|
func setup(t *testing.T) (*MDNSClient, *dns.Server, error) {
|
||||||
mdnsClient, err := NewMDNSClient()
|
mdnsClient, err := NewMDNSClient()
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
err = mdnsClient.Start(nil)
|
err = mdnsClient.Start(nil)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
server, err := RunLocalMulticastServer()
|
server, err := RunLocalMulticastServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -87,7 +88,7 @@ func (c *testContext) checkResponse(t *testing.T, channelOk bool, resp *Response
|
|||||||
c.channel = nil
|
c.channel = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assertNoErr(t, resp.Err)
|
wt.AssertNoErr(t, resp.Err)
|
||||||
log.Printf("Got address response %s addr %s", resp.Name, resp.Addr)
|
log.Printf("Got address response %s addr %s", resp.Name, resp.Addr)
|
||||||
c.receivedAddr = resp.Addr
|
c.receivedAddr = resp.Addr
|
||||||
c.receivedCount++
|
c.receivedCount++
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package nameserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
. "github.com/zettio/weave/common"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package nameserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
wt "github.com/zettio/weave/common"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -36,16 +37,16 @@ func TestServerSimpleQuery(t *testing.T) {
|
|||||||
zone.AddRecord(containerID, "test.weave.", ip)
|
zone.AddRecord(containerID, "test.weave.", ip)
|
||||||
|
|
||||||
mdnsServer, err := NewMDNSServer(zone)
|
mdnsServer, err := NewMDNSServer(zone)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
err = mdnsServer.Start(nil)
|
err = mdnsServer.Start(nil)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
var receivedAddr net.IP
|
var receivedAddr net.IP
|
||||||
receivedCount := 0
|
receivedCount := 0
|
||||||
|
|
||||||
// Implement a minimal listener for responses
|
// Implement a minimal listener for responses
|
||||||
multicast, err := LinkLocalMulticastListener(nil)
|
multicast, err := LinkLocalMulticastListener(nil)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
handleMDNS := func(w dns.ResponseWriter, r *dns.Msg) {
|
handleMDNS := func(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
// Only handle responses here
|
// Only handle responses here
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nameserver
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
. "github.com/zettio/weave/common"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
package nameserver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func assertNoErr(t *testing.T, err error) {
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertStatus(t *testing.T, got int, wanted int, desc string) {
|
|
||||||
if got != wanted {
|
|
||||||
t.Fatalf("Expected %s %d but got %d", desc, wanted, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertErrorInterface(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
|
||||||
if got == nil {
|
|
||||||
t.Fatalf("Expected %s but got nil (%s)", reflect.TypeOf(wanted).Elem(), desc)
|
|
||||||
}
|
|
||||||
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
|
||||||
if !gotT.Implements(wantedT) {
|
|
||||||
t.Fatalf("Expected %s but got %s (%s)", wantedT, gotT, desc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertErrorType(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
|
||||||
if got == nil {
|
|
||||||
t.Fatalf("Expected %s but got nil (%s)", reflect.TypeOf(wanted).Elem(), desc)
|
|
||||||
}
|
|
||||||
gotT, wantedT := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
|
||||||
if gotT != wantedT {
|
|
||||||
t.Fatalf("Expected %s but got %s (%s)", wantedT, gotT, desc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package nameserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
|
. "github.com/zettio/weave/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkError(err error, apiPath string) {
|
func checkError(err error, apiPath string) {
|
||||||
|
|||||||
+15
-14
@@ -1,6 +1,7 @@
|
|||||||
package nameserver
|
package nameserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
wt "github.com/zettio/weave/common"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -17,17 +18,17 @@ func TestZone(t *testing.T) {
|
|||||||
|
|
||||||
ip, _, _ := net.ParseCIDR(testAddr1)
|
ip, _, _ := net.ParseCIDR(testAddr1)
|
||||||
err := zone.AddRecord(containerID, successTestName, ip)
|
err := zone.AddRecord(containerID, successTestName, ip)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
// Add a few more records to make the job harder
|
// Add a few more records to make the job harder
|
||||||
err = zone.AddRecord("abcdef0123", "adummy.weave.", net.ParseIP("10.0.0.1"))
|
err = zone.AddRecord("abcdef0123", "adummy.weave.", net.ParseIP("10.0.0.1"))
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
err = zone.AddRecord("0123abcdef", "zdummy.weave.", net.ParseIP("10.0.0.2"))
|
err = zone.AddRecord("0123abcdef", "zdummy.weave.", net.ParseIP("10.0.0.2"))
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
// Check that the address is now there.
|
// Check that the address is now there.
|
||||||
foundIP, err := zone.LookupLocal(successTestName)
|
foundIP, err := zone.LookupLocal(successTestName)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
if !foundIP.Equal(ip) {
|
if !foundIP.Equal(ip) {
|
||||||
t.Fatal("Unexpected result for", successTestName, foundIP)
|
t.Fatal("Unexpected result for", successTestName, foundIP)
|
||||||
@@ -35,33 +36,33 @@ func TestZone(t *testing.T) {
|
|||||||
|
|
||||||
// See if we can find the address by IP.
|
// See if we can find the address by IP.
|
||||||
foundName, err := zone.ReverseLookupLocal(ip)
|
foundName, err := zone.ReverseLookupLocal(ip)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
if foundName != successTestName {
|
if foundName != successTestName {
|
||||||
t.Fatal("Unexpected result for", ip, foundName)
|
t.Fatal("Unexpected result for", ip, foundName)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = zone.AddRecord(containerID, successTestName, ip)
|
err = zone.AddRecord(containerID, successTestName, ip)
|
||||||
assertErrorType(t, err, (*DuplicateError)(nil), "duplicate add")
|
wt.AssertErrorType(t, err, (*DuplicateError)(nil), "duplicate add")
|
||||||
|
|
||||||
err = zone.AddRecord(otherContainerID, successTestName, ip)
|
err = zone.AddRecord(otherContainerID, successTestName, ip)
|
||||||
// Delete the record for the original container
|
// Delete the record for the original container
|
||||||
err = zone.DeleteRecord(containerID, ip)
|
err = zone.DeleteRecord(containerID, ip)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
_, err = zone.LookupLocal(successTestName)
|
_, err = zone.LookupLocal(successTestName)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
err = zone.DeleteRecord(otherContainerID, ip)
|
err = zone.DeleteRecord(otherContainerID, ip)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
// Check that the address is not there now.
|
// Check that the address is not there now.
|
||||||
_, err = zone.LookupLocal(successTestName)
|
_, err = zone.LookupLocal(successTestName)
|
||||||
assertErrorType(t, err, (*LookupError)(nil), "after deleting record")
|
wt.AssertErrorType(t, err, (*LookupError)(nil), "after deleting record")
|
||||||
|
|
||||||
// Delete a record that isn't there
|
// Delete a record that isn't there
|
||||||
err = zone.DeleteRecord(containerID, net.ParseIP("0.0.0.0"))
|
err = zone.DeleteRecord(containerID, net.ParseIP("0.0.0.0"))
|
||||||
assertErrorType(t, err, (*LookupError)(nil), "when deleting record that doesn't exist")
|
wt.AssertErrorType(t, err, (*LookupError)(nil), "when deleting record that doesn't exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteFor(t *testing.T) {
|
func TestDeleteFor(t *testing.T) {
|
||||||
@@ -75,13 +76,13 @@ func TestDeleteFor(t *testing.T) {
|
|||||||
for _, addr := range []string{addr1, addr2} {
|
for _, addr := range []string{addr1, addr2} {
|
||||||
ip, _, _ := net.ParseCIDR(addr)
|
ip, _, _ := net.ParseCIDR(addr)
|
||||||
err := zone.AddRecord(id, name, ip)
|
err := zone.AddRecord(id, name, ip)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := zone.LookupLocal(name)
|
_, err := zone.LookupLocal(name)
|
||||||
assertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
err = zone.DeleteRecordsFor(id)
|
err = zone.DeleteRecordsFor(id)
|
||||||
_, err = zone.LookupLocal(name)
|
_, err = zone.LookupLocal(name)
|
||||||
assertErrorType(t, err, (*LookupError)(nil), "after deleting records for ident")
|
wt.AssertErrorType(t, err, (*LookupError)(nil), "after deleting records for ident")
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
insecure_private_key
|
insecure_private_key
|
||||||
assert.sh
|
assert.sh
|
||||||
.vagrant
|
.vagrant
|
||||||
|
.ssh_known_hosts
|
||||||
+1
-1
@@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
. ./assert.sh
|
. ./assert.sh
|
||||||
|
|
||||||
SSH=${SSH:-ssh -l vagrant -i ./insecure_private_key}
|
SSH=${SSH:-ssh -l vagrant -i ./insecure_private_key -o UserKnownHostsFile=./.ssh_known_hosts -o CheckHostIP=no -o StrictHostKeyChecking=no}
|
||||||
HOST1=${HOST1:-192.168.48.19}
|
HOST1=${HOST1:-192.168.48.19}
|
||||||
HOST2=${HOST2:-192.168.48.15}
|
HOST2=${HOST2:-192.168.48.15}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
FROM scratch
|
||||||
|
MAINTAINER Weaveworks Inc <help@weave.works>
|
||||||
|
ADD ./bin /bin
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
apt-get -y update
|
||||||
|
apt-get -y install curl make pkg-config gcc bison flex
|
||||||
|
|
||||||
|
BASEDIR=$(dirname $0)
|
||||||
|
mkdir -p "$BASEDIR"/bin
|
||||||
|
|
||||||
|
# ethtool
|
||||||
|
|
||||||
|
ETHTOOL=ethtool-3.16
|
||||||
|
|
||||||
|
rm -rf $ETHTOOL
|
||||||
|
|
||||||
|
curl -s -S https://www.kernel.org/pub/software/network/ethtool/$ETHTOOL.tar.gz | tar xvz
|
||||||
|
(cd $ETHTOOL; ./configure LDFLAGS=-static; make)
|
||||||
|
cp $ETHTOOL/ethtool "$BASEDIR"/bin/
|
||||||
|
|
||||||
|
# conntrack
|
||||||
|
|
||||||
|
PACKAGES="libmnl-1.0.3 libnfnetlink-1.0.1 libnetfilter_cttimeout-1.0.0 libnetfilter_cthelper-1.0.0 libnetfilter_queue-1.0.2 libnetfilter_conntrack-1.0.4"
|
||||||
|
CONNTRACK=conntrack-tools-1.4.2
|
||||||
|
|
||||||
|
rm -rf $PACKAGES $CONNTRACK
|
||||||
|
|
||||||
|
fetch() {
|
||||||
|
curl -s -S http://www.netfilter.org/projects/${1%-*}/files/$1.tar.bz2 | tar xj
|
||||||
|
}
|
||||||
|
|
||||||
|
for PACKAGE in $PACKAGES; do
|
||||||
|
fetch $PACKAGE
|
||||||
|
(cd $PACKAGE; ./configure && make LDFLAGS=-static install)
|
||||||
|
done
|
||||||
|
|
||||||
|
fetch $CONNTRACK
|
||||||
|
(cd $CONNTRACK; ./configure && make LDFLAGS=-static && rm -f src/conntrack && make LDFLAGS=-all-static)
|
||||||
|
cp $CONNTRACK/src/conntrack "$BASEDIR"/bin/
|
||||||
|
|
||||||
|
touch "$BASEDIR"/bin
|
||||||
@@ -5,6 +5,7 @@ SCRIPT_VERSION="(unreleased version)"
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
|
echo "weave setup"
|
||||||
echo "weave launch [-password <password> | -passwordfile <path>] <peer> ..."
|
echo "weave launch [-password <password> | -passwordfile <path>] <peer> ..."
|
||||||
echo "weave launch-dns <cidr>"
|
echo "weave launch-dns <cidr>"
|
||||||
echo "weave connect <peer>"
|
echo "weave connect <peer>"
|
||||||
@@ -33,8 +34,20 @@ usage() {
|
|||||||
|
|
||||||
[ $# -gt 0 ] || usage
|
[ $# -gt 0 ] || usage
|
||||||
|
|
||||||
IMAGE=zettio/weave
|
if [ "$SCRIPT_VERSION" = "(unreleased version)" ] ; then
|
||||||
DNS_IMAGE=zettio/weavedns
|
IMAGE_VERSION=latest
|
||||||
|
else
|
||||||
|
IMAGE_VERSION=$SCRIPT_VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
|
IMAGE_VERSION=${VERSION:-$IMAGE_VERSION}
|
||||||
|
|
||||||
|
BASE_IMAGE=zettio/weave
|
||||||
|
BASE_DNS_IMAGE=zettio/weavedns
|
||||||
|
BASE_TOOLS_IMAGE=zettio/weavetools
|
||||||
|
IMAGE=$BASE_IMAGE:$IMAGE_VERSION
|
||||||
|
DNS_IMAGE=$BASE_DNS_IMAGE:$IMAGE_VERSION
|
||||||
|
TOOLS_IMAGE=$BASE_TOOLS_IMAGE:$IMAGE_VERSION
|
||||||
CONTAINER_NAME=weave
|
CONTAINER_NAME=weave
|
||||||
DNS_CONTAINER_NAME=weavedns
|
DNS_CONTAINER_NAME=weavedns
|
||||||
BRIDGE=weave
|
BRIDGE=weave
|
||||||
@@ -55,11 +68,11 @@ command_exists () {
|
|||||||
command -v $1 >/dev/null 2>&1
|
command -v $1 >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
command_exists_or_warn () {
|
run_tool() {
|
||||||
if ! command_exists $1 ; then
|
TOOL_NET=$1
|
||||||
echo "Cannot find $1; please install it. Continuing without it." >&2
|
TOOL_COMMAND=$2
|
||||||
return 1
|
shift 2
|
||||||
fi
|
docker run --rm --privileged --net=$TOOL_NET $TOOLS_IMAGE /bin/$TOOL_COMMAND "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_cidr() {
|
is_cidr() {
|
||||||
@@ -119,7 +132,7 @@ create_bridge() {
|
|||||||
ip link set dev v${CONTAINER_IFNAME}du master $BRIDGE
|
ip link set dev v${CONTAINER_IFNAME}du master $BRIDGE
|
||||||
ip link del dev v${CONTAINER_IFNAME}du
|
ip link del dev v${CONTAINER_IFNAME}du
|
||||||
# disable offloading
|
# disable offloading
|
||||||
if command_exists_or_warn ethtool; then ethtool -K $BRIDGE tx off >/dev/null; fi
|
run_tool host ethtool -K $BRIDGE tx off >/dev/null
|
||||||
# Work around the situation where there are no rules allowing traffic
|
# Work around the situation where there are no rules allowing traffic
|
||||||
# across our bridge. E.g. ufw
|
# across our bridge. E.g. ufw
|
||||||
add_iptables_rule filter FORWARD -i $BRIDGE -o $BRIDGE -j ACCEPT
|
add_iptables_rule filter FORWARD -i $BRIDGE -o $BRIDGE -j ACCEPT
|
||||||
@@ -205,7 +218,7 @@ connect_container_to_bridge() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if { if command_exists_or_warn ethtool; then ethtool -K $GUEST_IFNAME tx off >/dev/null; fi } &&
|
if run_tool host ethtool -K $GUEST_IFNAME tx off >/dev/null &&
|
||||||
ip link set $LOCAL_IFNAME master $BRIDGE &&
|
ip link set $LOCAL_IFNAME master $BRIDGE &&
|
||||||
ip link set $LOCAL_IFNAME up &&
|
ip link set $LOCAL_IFNAME up &&
|
||||||
ip link set $GUEST_IFNAME netns $NETNS ; then
|
ip link set $GUEST_IFNAME netns $NETNS ; then
|
||||||
@@ -224,7 +237,7 @@ launch() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
connect_container_to_bridge &&
|
connect_container_to_bridge &&
|
||||||
{ if command_exists_or_warn ethtool ; then ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null; fi } &&
|
run_tool container:$CONTAINER ethtool -K eth0 tx off >/dev/null &&
|
||||||
ip netns exec $NETNS ip link set $CONTAINER_IFNAME up
|
ip netns exec $NETNS ip link set $CONTAINER_IFNAME up
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,9 +371,16 @@ check_not_running() {
|
|||||||
echo "$1 is already running." >&2
|
echo "$1 is already running." >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
"true $2:"*)
|
||||||
|
echo "$1 is already running." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
"false $2")
|
"false $2")
|
||||||
docker rm $1 >/dev/null
|
docker rm $1 >/dev/null
|
||||||
;;
|
;;
|
||||||
|
"false $2:"*)
|
||||||
|
docker rm $1 >/dev/null
|
||||||
|
;;
|
||||||
true*)
|
true*)
|
||||||
echo "Found another running container named '$1'. Aborting." >&2
|
echo "Found another running container named '$1'. Aborting." >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -428,8 +448,13 @@ DOCKER_VERSION_MINOR=$(echo "$DOCKER_VERSION" | cut -d. -f 2)
|
|||||||
DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
|
DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
|
||||||
|
|
||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
|
setup)
|
||||||
|
for img in $IMAGE $DNS_IMAGE $TOOLS_IMAGE ; do
|
||||||
|
docker pull $img
|
||||||
|
done
|
||||||
|
;;
|
||||||
launch)
|
launch)
|
||||||
check_not_running $CONTAINER_NAME $IMAGE
|
check_not_running $CONTAINER_NAME $BASE_IMAGE
|
||||||
create_bridge
|
create_bridge
|
||||||
# We set the router name to the bridge mac since that is
|
# We set the router name to the bridge mac since that is
|
||||||
# stable across re-creations of the containers.
|
# stable across re-creations of the containers.
|
||||||
@@ -466,7 +491,7 @@ case "$COMMAND" in
|
|||||||
[ $# -gt 0 ] || usage
|
[ $# -gt 0 ] || usage
|
||||||
CIDR=$1
|
CIDR=$1
|
||||||
shift 1
|
shift 1
|
||||||
check_not_running $DNS_CONTAINER_NAME $DNS_IMAGE
|
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
|
||||||
create_bridge
|
create_bridge
|
||||||
docker_bridge_ip
|
docker_bridge_ip
|
||||||
DNS_CONTAINER=$(docker run --privileged -d --name=$DNS_CONTAINER_NAME \
|
DNS_CONTAINER=$(docker run --privileged -d --name=$DNS_CONTAINER_NAME \
|
||||||
@@ -498,6 +523,16 @@ case "$COMMAND" in
|
|||||||
echo weave script $SCRIPT_VERSION
|
echo weave script $SCRIPT_VERSION
|
||||||
ask_version $CONTAINER_NAME $IMAGE
|
ask_version $CONTAINER_NAME $IMAGE
|
||||||
ask_version $DNS_CONTAINER_NAME $DNS_IMAGE
|
ask_version $DNS_CONTAINER_NAME $DNS_IMAGE
|
||||||
|
if ! TOOLS_IMAGE_ID=$(docker inspect --format='{{ .Id }}' $TOOLS_IMAGE 2>/dev/null) ; then
|
||||||
|
echo "Unable to find $TOOLS_IMAGE image." >&2
|
||||||
|
else
|
||||||
|
TOOLS_VERSION=$(docker images --no-trunc | grep $TOOLS_IMAGE_ID | grep -v latest | tr -s ' ' | cut -d ' ' -f 2 | tr "\n" ' ')
|
||||||
|
if [ -n "$TOOLS_VERSION" ] ; then
|
||||||
|
echo "weave tools $TOOLS_VERSION"
|
||||||
|
else
|
||||||
|
echo "weave tools (unreleased version)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
run)
|
run)
|
||||||
[ $# -gt 0 ] || usage
|
[ $# -gt 0 ] || usage
|
||||||
@@ -581,9 +616,7 @@ case "$COMMAND" in
|
|||||||
echo "Weave is not running." >&2
|
echo "Weave is not running." >&2
|
||||||
fi
|
fi
|
||||||
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
|
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
|
||||||
if command_exists_or_warn conntrack; then
|
run_tool host conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
|
||||||
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop-dns)
|
stop-dns)
|
||||||
[ $# -eq 0 ] || usage
|
[ $# -eq 0 ] || usage
|
||||||
@@ -598,9 +631,7 @@ case "$COMMAND" in
|
|||||||
docker kill $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
|
docker kill $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
|
||||||
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
|
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
|
||||||
docker rm -f $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
|
docker rm -f $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
|
||||||
if command_exists_or_warn conntrack; then
|
run_tool host conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
|
||||||
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
destroy_bridge
|
destroy_bridge
|
||||||
for LOCAL_IFNAME in $(ip link show | grep v${CONTAINER_IFNAME}pl | cut -d ' ' -f 2 | tr -d ':') ; do
|
for LOCAL_IFNAME in $(ip link show | grep v${CONTAINER_IFNAME}pl | cut -d ' ' -f 2 | tr -d ':') ; do
|
||||||
ip link del $LOCAL_IFNAME
|
ip link del $LOCAL_IFNAME
|
||||||
|
|||||||
+7
-11
@@ -3,10 +3,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
. "github.com/zettio/weave/common"
|
||||||
weavedns "github.com/zettio/weave/nameserver"
|
weavedns "github.com/zettio/weave/nameserver"
|
||||||
weavenet "github.com/zettio/weave/net"
|
weavenet "github.com/zettio/weave/net"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
@@ -40,35 +40,31 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
debugOut := ioutil.Discard
|
InitDefaultLogging(debug)
|
||||||
if debug {
|
|
||||||
debugOut = os.Stderr
|
|
||||||
}
|
|
||||||
weavedns.InitLogging(debugOut, os.Stdout, os.Stdout, os.Stderr)
|
|
||||||
|
|
||||||
var zone = new(weavedns.ZoneDb)
|
var zone = new(weavedns.ZoneDb)
|
||||||
|
|
||||||
if watch {
|
if watch {
|
||||||
err := weavedns.StartUpdater(apiPath, zone)
|
err := weavedns.StartUpdater(apiPath, zone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
weavedns.Error.Fatal("Unable to start watcher", err)
|
Error.Fatal("Unable to start watcher", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var iface *net.Interface = nil
|
var iface *net.Interface = nil
|
||||||
if ifaceName != "" {
|
if ifaceName != "" {
|
||||||
var err error
|
var err error
|
||||||
weavedns.Info.Println("Waiting for interface", ifaceName, "to come up")
|
Info.Println("Waiting for interface", ifaceName, "to come up")
|
||||||
iface, err = weavenet.EnsureInterface(ifaceName, wait)
|
iface, err = weavenet.EnsureInterface(ifaceName, wait)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
weavedns.Error.Fatal(err)
|
Error.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
weavedns.Info.Println("Interface", ifaceName, "is up")
|
Info.Println("Interface", ifaceName, "is up")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := weavedns.StartServer(zone, iface, dnsPort, httpPort, wait)
|
err := weavedns.StartServer(zone, iface, dnsPort, httpPort, wait)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
weavedns.Error.Fatal("Failed to start server", err)
|
Error.Fatal("Failed to start server", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
weaver
|
|
||||||
Reference in new issue
Block a user