Compare commits

...
61 Commits
Author SHA1 Message Date
Bryan Boreham 2884b6deca Add release v1.1.2 2015-10-20 17:06:14 +01:00
Matthias Radestock 44255862a9 prevent spurious errors from showing up
silly mistake
2015-10-15 18:12:56 +01:00
Matthias Radestock 379048d8fc make test/setup.sh work under go 1.5
Fixes #1543.
2015-10-15 17:40:51 +01:00
Adam Harrison dea1405d71 Remove hardcoded docker bridge IP from proxy test 2015-10-15 14:39:56 +01:00
David Wragg 6edd430538 Use consistent options for all "go get"/"go build" invocations
Without this, building with go-1.5 fails with

    go get ./prog/weavewait
    go install net: open /usr/local/go/pkg/linux_amd64/net.a: permission denied

This makes the options passed too "go get"/"go build" consistent for
all executables. So it should be safe with go-1.4.

Conflicts:
	Makefile
2015-10-15 14:16:33 +01:00
Matthias Radestock 0d2ff55c07 Merge pull request #1535 from weaveworks/1523-rewrite-inspect-failure
[proxy] only attempt to rewrite successful inspects

Fixes #1523.
2015-10-15 13:04:34 +01:00
Paul Bellamy 36de840c91 [proxy] only attempt to rewrite successful inspects 2015-10-14 11:28:43 +01:00
Matthias Radestock 0ef548b9c9 prevent dropping of large multicast packets
Fixes #1507.
2015-10-06 16:25:02 +01:00
Ilya Dmitrichenko 7743f0e05f Merge branch 'latest_release_doc_updates' into 1.1 2015-10-06 15:26:50 +01:00
Ilya Dmitrichenko a1581ed5b5 Remove stale/invalid flag 2015-10-06 15:26:14 +01:00
Ilya Dmitrichenko a6c30088ab Merge branch 'latest_release_doc_updates' into 1.1 2015-10-06 15:24:08 +01:00
Ilya Dmitrichenko fdbe950483 Fix #1509 2015-10-06 15:21:24 +01:00
Matthias Radestock 2f86326405 Merge tag 'v1.1.1' into latest_release_doc_updates
Release v1.1.1
2015-10-06 15:13:50 +01:00
Matthias Radestock 6c4ea7a957 unswap src and dst ip in "too big DF broadcast" warning
and some whitespace cosmetics.

Fixes #1508.
2015-10-05 19:56:59 +01:00
Matthias Radestock de95859e0d add release v1.1.1 2015-10-05 11:26:24 +01:00
David Wragg 8fe0228d4d Merge 1364-ip-link-kernel-4.2 (PR #1504)
strip off @... from interface names returned by `ip link show`
2015-10-04 20:23:43 +01:00
Matthias Radestock 37ea8a28ad strip off @... from interface names returned by ip link show
Apparently kernel 4.2 adds these, which breaks `weave reset` when we
pass the names to `ip link del'.

Fixes #1364.
2015-10-04 15:43:55 +01:00
Matthias Radestock dac932f553 fix multi-ip attach
This got broken in f7dfe9d
2015-10-03 17:09:25 +01:00
Matthias Radestock d798b0cabb Merge pull request #1476 from weaveworks/1455-mount-var-run
unmount /var/run after boot, so the kernel can GC veth pairs

Fixes #1455.
2015-10-01 11:55:24 +01:00
Paul Bellamy 29bfd77855 [proxy] don't mount /var/run into the proxy, so the kernel can GC veth pairs 2015-10-01 11:43:13 +01:00
Tom Wilkie 0b7af28c86 Typo in Makefile. 2015-10-01 08:21:55 +00:00
Matthias Radestock 526259ef8e Merge pull request #1487 from weaveworks/1480-dns-test-race
Fix races in TestRecursiveCompress

Fixes #1480.
2015-10-01 08:11:48 +01:00
Matthias Radestock 3795c14931 better 2015-09-30 22:57:10 +01:00
Matthias Radestock 3e5cdd8bf2 refactor: remove pointless NXDOMAIN tests 2015-09-30 22:42:27 +01:00
Matthias Radestock 35058a1dde refactor: put negative DNS queries in one test suite 2015-09-30 22:38:48 +01:00
Tom Wilkie 11d93b1883 Fix races in TestRecursiveCompress 2015-09-30 15:51:07 +00:00
Tom Wilkie f86f392641 Merge pull request #1486 from weaveworks/1482-disable-160
Disable 160_claim test.
2015-09-30 16:20:34 +01:00
Matthias Radestock cd8befe43e Merge pull request #1485 from weaveworks/1450-check-slice
Sanity-check gossip messages
2015-09-30 15:41:21 +01:00
Tom Wilkie db46204ff9 Disable 160_claim test. 2015-09-30 14:22:24 +00:00
Bryan Boreham d2290cc82c Sanity-check gossip messages 2015-09-30 14:39:27 +01:00
Matthias Radestock 63e3f441d8 cosmetic: link to relevant RFC section for ARP announcements 2015-09-24 12:07:12 +01:00
Tom Wilkie 99ae38c9a6 Merge pull request #1467 from weaveworks/docker-machine
Update for docker/machine PR #1729
2015-09-24 11:53:21 +08:00
Tom Wilkie 011f96c6a7 New test image using docker 1.8 2015-09-24 03:42:44 +00:00
Tom Wilkie c7b4136d31 Update for docker/machine PR #1729 2015-09-24 03:25:30 +00:00
Matthias Radestock b1d453a0c2 Merge pull request #1460 from weaveworks/simplify-ipam-cidrs
Simplify ipam_cidrs function in weave script
2015-09-22 21:17:42 +01:00
Bryan Boreham a51f63267a Merge 0-args case in ipam_cidrs() and simplify loop 2015-09-22 21:06:12 +01:00
Matthias Radestock 7f74ae7912 Merge pull request #1426 from weaveworks/1418-clean-cancel
Handle cancelled allocation in 'weave attach'

Fixes #1418.
2015-09-22 16:27:27 +01:00
Bryan Boreham abf13c7026 Simplify detection of issues 2015-09-22 16:14:14 +01:00
Bryan Boreham 98b80c59d9 Detect cancelled allocation more cleanly
to avoid the weave script trying to parse an error message as a CIDR
2015-09-16 14:14:40 +01:00
Bryan Boreham 1beaf79e47 Refactor: extract duplicated code into helper functions 2015-09-16 14:14:30 +01:00
Matthias Radestock 8e656c1fd7 Merge pull request #1429 from weaveworks/1424-fix-cancel
Use explicit index into operations slice in cancelOpsFor()

Fixes #1424
2015-09-15 16:45:11 +01:00
Bryan Boreham d55c68c248 Review feedback 2015-09-15 16:18:37 +01:00
Matthias Radestock 8ec3ab5e28 Merge pull request #1435 from weaveworks/update-vagrantfile-docker-repos
Update docker repo, keys and package name
2015-09-15 15:49:33 +01:00
Matthias Radestock 58a30f7282 Merge branch 'latest_release_doc_updates' into 1.1 2015-09-15 15:44:15 +01:00
Matthias Radestock 2b5c2874ab remove 'lxc-docker' reference from build-on-ubuntu instructions
...since the Docker docs have been updated to install docker-engine.
2015-09-15 15:34:44 +01:00
Matthias Radestock bed11f4214 Merge pull request #1431 from weaveworks/issues/1397-strip-version-prefix
Automatically strip 'v' prefix for mainline and branch releases

Fixes #1397.
2015-09-15 13:15:49 +01:00
Adam Harrison bbf7646751 Update docker repo, keys and package name 2015-09-15 11:33:53 +01:00
Adam Harrison 6dfefb95e8 Advise installation of weaveworks github-release fork 2015-09-15 10:47:43 +01:00
Adam Harrison 44c2861aba Update release process doc 2015-09-15 10:41:41 +01:00
Adam Harrison 3039046a6d Strip v prefix for mainline and branch releases 2015-09-15 10:41:24 +01:00
Bryan Boreham a7e0f03647 Use explicit index into operations slice in cancelOpsFor()
to avoid mis-indexing when more than one op is removed
2015-09-14 17:02:35 +01:00
Bryan Boreham 5635ba1fd0 Update out-dated error message 2015-09-14 16:31:37 +01:00
Adam Harrison dd0eee6418 Merge pull request #1411 from weaveworks/1405-arping-dynamic-attach-1
always arp_update new addresses in 'attach'
2015-09-14 14:20:21 +01:00
Matthias Radestock 83ef93f3fb detect running proxy regardless of version
Fixes #1413.
2015-09-11 14:06:44 +01:00
Matthias Radestock f7dfe9dd23 always arp_update new addresses in 'attach'
Previously we'd only do that when the container had no ethwe at the
start. Therefore adding a recycled IP address to an already attached
container would not send out an arp update for that IP, which would
break connectivity to that IP for containers which had previously
accessed that IP.

Fixes #1405.
2015-09-10 18:43:49 +01:00
Adam Harrison ac145052d6 Correct weave stop advice
Fixes #1408.
2015-09-10 17:23:33 +01:00
Matthias Radestock 7a41337d17 Merge branch 'latest_release_doc_updates' into 1.1 2015-09-09 20:06:14 +01:00
Matthias Radestock 2d006dffaf add link to latest release to docs homepage
Closes #1400.
2015-09-09 20:04:37 +01:00
Matthias Radestock 69c935a6e8 Make latest_release description link to real release
Closes #1399.
2015-09-09 19:52:08 +01:00
Adam Harrison 676127893f Escape double curly braces eaten by Jekyll/Liquid 2015-09-09 14:21:31 +01:00
Adam Harrison df62d512cd Correct weave report example in troubleshooting guide 2015-09-09 14:00:53 +01:00
35 changed files with 269 additions and 151 deletions

No files matched your search

+21
View File
@@ -1,3 +1,24 @@
## Release 1.1.2
This release contains a small number of bug fixes. More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.1.2).
The release is fully compatible with 1.1.0 versions, so existing
clusters can be upgraded incrementally. When upgrading from 1.0.x,
note the compatibility information in the
[Installation & Upgrading instructions for Weave 1.1.0](https://github.com/weaveworks/weave/releases/tag/v1.1.0).
## Release 1.1.1
This release contains a number of bug fixes and minor
enhancements. More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.1.1).
The release is fully compatible with 1.1.0 versions, so existing
clusters can be upgraded incrementally. When upgrading from 1.0.x,
note the compatibility information in the
[Installation & Upgrading instructions for Weave 1.1.0](https://github.com/weaveworks/weave/releases/tag/v1.1.0).
## Release v1.1.0 ## Release v1.1.0
**Highlights**: **Highlights**:
+3 -3
View File
@@ -50,7 +50,7 @@ all: $(WEAVE_EXPORT) $(COVER_EXE) $(RUNNER_EXE)
travis: $(EXES) travis: $(EXES)
update: update:
go get -u -f -v -tags -netgo $(addprefix ./,$(dir $(EXES))) go get -u -f -v -tags netgo $(addprefix ./,$(dir $(EXES)))
$(WEAVER_EXE) $(WEAVEPROXY_EXE): common/*.go common/*/*.go net/*.go $(WEAVER_EXE) $(WEAVEPROXY_EXE): common/*.go common/*/*.go net/*.go
ifeq ($(COVERAGE),true) ifeq ($(COVERAGE),true)
@@ -81,8 +81,8 @@ $(COVER_EXE): testing/cover/cover.go
$(RUNNER_EXE): testing/runner/runner.go $(RUNNER_EXE): testing/runner/runner.go
$(WEAVEWAIT_EXE) $(SIGPROXY_EXE) $(WEAVEHOSTS_EXE) $(COVER_EXE) $(RUNNER_EXE): $(WEAVEWAIT_EXE) $(SIGPROXY_EXE) $(WEAVEHOSTS_EXE) $(COVER_EXE) $(RUNNER_EXE):
go get ./$(@D) go get -tags netgo ./$(@D)
go build -o $@ ./$(@D) go build $(BUILD_FLAGS) -o $@ ./$(@D)
$(WEAVER_UPTODATE): prog/weaver/Dockerfile $(WEAVER_EXE) $(WEAVER_UPTODATE): prog/weaver/Dockerfile $(WEAVER_EXE)
$(SUDO) docker build -t $(WEAVER_IMAGE) prog/weaver $(SUDO) docker build -t $(WEAVER_IMAGE) prog/weaver
Vendored
+1 -1
View File
@@ -5,7 +5,7 @@ require './vagrant-common.rb'
vm_ip = "172.16.0.3" # arbitrary private IP vm_ip = "172.16.0.3" # arbitrary private IP
pkgs = %w( pkgs = %w(
lxc-docker docker-engine
aufs-tools aufs-tools
build-essential build-essential
ethtool ethtool
+8 -4
View File
@@ -52,7 +52,11 @@ setup() {
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG) LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG)
LATEST_RELEASE_SHA=$(git rev-parse latest_release) LATEST_RELEASE_SHA=$(git rev-parse latest_release)
LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release) LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release)
VERSION=${LATEST_TAG} if [ "$RELEASE_TYPE" != 'PRERELEASE' ] ; then
VERSION=${LATEST_TAG#v}
else
VERSION=${LATEST_TAG}
fi
# NB does not check that this tag is on master # NB does not check that this tag is on master
RELEASE_DIR=./releases/$LATEST_TAG RELEASE_DIR=./releases/$LATEST_TAG
} }
@@ -223,7 +227,7 @@ publish() {
--repo weave \ --repo weave \
--tag latest_release \ --tag latest_release \
--name "$RELEASE_NAME latest ($VERSION)" \ --name "$RELEASE_NAME latest ($VERSION)" \
--description "$RELEASE_DESCRIPTION" --description "[Release Notes](https://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG)"
github-release upload \ github-release upload \
--user $GITHUB_USER \ --user $GITHUB_USER \
@@ -252,8 +256,8 @@ usage() {
# Ensure required tooling is installed # Ensure required tooling is installed
if ! which github-release >/dev/null; then if ! which github-release >/dev/null; then
echo "Please install git-release:" >&2 echo "Please install git-release:" >&2
echo -e "\tgo get github.com/aktau/github-release" >&2 echo -e "\tgo get github.com/weaveworks/github-release" >&2
echo "and create a git token per https://github.com/aktau/github-release" >&2 echo "and create a git token per https://github.com/weaveworks/github-release" >&2
exit 1 exit 1
fi fi
+1 -1
View File
@@ -31,7 +31,7 @@ behaviours for that type of release will be obtained from the script.
* Choose a version tag (see above) henceforth referred to as `$TAG`. * Choose a version tag (see above) henceforth referred to as `$TAG`.
* Add a changelog entry for the new tag at the top of `CHANGELOG.md`. * Add a changelog entry for the new tag at the top of `CHANGELOG.md`.
The first line must be a markdown header of the form `## Release The first line must be a markdown header of the form `## Release
$TAG` $TAG` for **Prerelease** builds, `## Release ${TAG#v}` otherwise.
Commit the changelog update: Commit the changelog update:
+1 -1
View File
@@ -59,7 +59,7 @@ func (g *allocate) Try(alloc *Allocator) bool {
} }
func (g *allocate) Cancel() { func (g *allocate) Cancel() {
g.resultChan <- allocateResult{0, fmt.Errorf("Allocate request for %s cancelled", g.ident)} g.resultChan <- allocateResult{0, &errorCancelled{"Allocate", g.ident}}
} }
func (g *allocate) ForContainer(ident string) bool { func (g *allocate) ForContainer(ident string) bool {
+13 -2
View File
@@ -126,11 +126,13 @@ func (alloc *Allocator) cancelOps(ops *[]operation) {
// if we found any. // if we found any.
func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool { func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool {
var found bool var found bool
for i, op := range *ops { for i := 0; i < len(*ops); {
if op.ForContainer(ident) { if op := (*ops)[i]; op.ForContainer(ident) {
found = true found = true
op.Cancel() op.Cancel()
*ops = append((*ops)[:i], (*ops)[i+1:]...) *ops = append((*ops)[:i], (*ops)[i+1:]...)
} else {
i++
} }
} }
return found return found
@@ -184,6 +186,15 @@ func hasBeenCancelled(cancelChan <-chan bool) func() bool {
} }
} }
type errorCancelled struct {
kind string
ident string
}
func (e *errorCancelled) Error() string {
return fmt.Sprintf("%s request for %s cancelled", e.kind, e.ident)
}
// Actor client API // Actor client API
// Allocate (Sync) - get new IP address for container with given name in range // Allocate (Sync) - get new IP address for container with given name in range
+33 -1
View File
@@ -229,7 +229,6 @@ func TestCancel(t *testing.T) {
doneChan <- ok == nil doneChan <- ok == nil
}() }()
AssertNothingSent(t, doneChan)
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
AssertNothingSent(t, doneChan) AssertNothingSent(t, doneChan)
@@ -240,6 +239,39 @@ func TestCancel(t *testing.T) {
} }
} }
func TestCancelOnDied(t *testing.T) {
const (
CIDR = "10.0.1.7/26"
container1 = "abcdef"
)
router := gossip.NewTestRouter(0.0)
alloc1, subnet := makeAllocator("01:00:00:02:00:00", CIDR, 2)
alloc1.SetInterfaces(router.Connect(alloc1.ourName, alloc1))
alloc1.Start()
doneChan := make(chan bool)
f := func() {
_, ok := alloc1.Allocate(container1, subnet, nil)
doneChan <- ok == nil
}
// Attempt two allocations in parallel, to check that this is handled correctly
go f()
go f()
// Nothing should happen, because we declared the quorum as 2
time.Sleep(100 * time.Millisecond)
AssertNothingSent(t, doneChan)
alloc1.ContainerDied(container1)
// Check that the two allocations both exit with an error
if <-doneChan || <-doneChan {
require.FailNow(t, "Error: got result from Allocate")
}
}
func TestGossipShutdown(t *testing.T) { func TestGossipShutdown(t *testing.T) {
const ( const (
container1 = "abcdef" container1 = "abcdef"
+1 -1
View File
@@ -95,7 +95,7 @@ func (c *claim) deniedBy(alloc *Allocator, owner router.PeerName) {
} }
func (c *claim) Cancel() { func (c *claim) Cancel() {
c.sendResult(fmt.Errorf("Operation cancelled.")) c.sendResult(&errorCancelled{"Claim", c.ident})
} }
func (c *claim) ForContainer(ident string) bool { func (c *claim) ForContainer(ident string) bool {
+46 -48
View File
@@ -16,6 +16,41 @@ func badRequest(w http.ResponseWriter, err error) {
common.Log.Warningln("[allocator]:", err.Error()) common.Log.Warningln("[allocator]:", err.Error())
} }
func parseCIDR(w http.ResponseWriter, cidrStr string) (address.CIDR, bool) {
subnetAddr, cidr, err := address.ParseCIDR(cidrStr)
if err != nil {
badRequest(w, err)
return address.CIDR{}, false
}
if cidr.Start != subnetAddr {
badRequest(w, fmt.Errorf("Invalid subnet %s - bits after network prefix are not all zero", cidrStr))
return address.CIDR{}, false
}
return cidr, true
}
func (alloc *Allocator) handleHTTPAllocate(dockerCli *docker.Client, w http.ResponseWriter, ident string, checkAlive bool, subnet address.CIDR) {
closedChan := w.(http.CloseNotifier).CloseNotify()
addr, err := alloc.Allocate(ident, subnet.HostRange(), closedChan)
if err != nil {
if _, ok := err.(*errorCancelled); ok { // cancellation is not really an error
common.Log.Infoln("[allocator]:", err.Error())
fmt.Fprint(w, "cancelled")
return
}
badRequest(w, err)
return
}
if checkAlive && dockerCli != nil && dockerCli.IsContainerNotRunning(ident) {
common.Log.Infof("[allocator] '%s' is not running: freeing %s", ident, addr)
alloc.Free(ident, addr)
fmt.Fprint(w, "cancelled")
return
}
fmt.Fprintf(w, "%s/%d", addr, subnet.PrefixLen)
}
// HandleHTTP wires up ipams HTTP endpoints to the provided mux. // HandleHTTP wires up ipams HTTP endpoints to the provided mux.
func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CIDR, dockerCli *docker.Client) { func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CIDR, dockerCli *docker.Client) {
router.Methods("PUT").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("PUT").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -36,18 +71,14 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CID
router.Methods("GET").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("GET").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
cidr := vars["ip"] + "/" + vars["prefixlen"] if subnet, ok := parseCIDR(w, vars["ip"]+"/"+vars["prefixlen"]); ok {
_, subnet, err := address.ParseCIDR(cidr) addr, err := alloc.Lookup(vars["id"], subnet.HostRange())
if err != nil { if err != nil {
badRequest(w, err) http.NotFound(w, r)
return return
}
fmt.Fprintf(w, "%s/%d", addr, subnet.PrefixLen)
} }
addr, err := alloc.Lookup(vars["id"], subnet.HostRange())
if err != nil {
http.NotFound(w, r)
return
}
fmt.Fprintf(w, "%s/%d", addr, subnet.PrefixLen)
}) })
router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -60,48 +91,15 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CID
}) })
router.Methods("POST").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("POST").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
closedChan := w.(http.CloseNotifier).CloseNotify()
vars := mux.Vars(r) vars := mux.Vars(r)
ident := vars["id"] if subnet, ok := parseCIDR(w, vars["ip"]+"/"+vars["prefixlen"]); ok {
cidrStr := vars["ip"] + "/" + vars["prefixlen"] alloc.handleHTTPAllocate(dockerCli, w, vars["id"], r.FormValue("check-alive") == "true", subnet)
subnetAddr, cidr, err := address.ParseCIDR(cidrStr)
if err != nil {
badRequest(w, err)
return
} }
if cidr.Start != subnetAddr {
badRequest(w, fmt.Errorf("Invalid subnet %s - bits after network prefix are not all zero", cidrStr))
return
}
addr, err := alloc.Allocate(ident, cidr.HostRange(), closedChan)
if err != nil {
badRequest(w, fmt.Errorf("Unable to allocate: %s", err))
return
}
if r.FormValue("check-alive") == "true" && dockerCli != nil && dockerCli.IsContainerNotRunning(ident) {
common.Log.Infof("[allocator] '%s' is not running: freeing %s", ident, addr)
alloc.Free(ident, addr)
return
}
fmt.Fprintf(w, "%s/%d", addr, cidr.PrefixLen)
}) })
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
closedChan := w.(http.CloseNotifier).CloseNotify() vars := mux.Vars(r)
ident := mux.Vars(r)["id"] alloc.handleHTTPAllocate(dockerCli, w, vars["id"], r.FormValue("check-alive") == "true", defaultSubnet)
newAddr, err := alloc.Allocate(ident, defaultSubnet.HostRange(), closedChan)
if err != nil {
badRequest(w, err)
return
}
if r.FormValue("check-alive") == "true" && dockerCli != nil && dockerCli.IsContainerNotRunning(ident) {
common.Log.Infof("[allocator] '%s' is not running: freeing %s", ident, newAddr)
alloc.Free(ident, newAddr)
return
}
fmt.Fprintf(w, "%s/%d", newAddr, defaultSubnet.PrefixLen)
}) })
router.Methods("DELETE").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { router.Methods("DELETE").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+10 -8
View File
@@ -15,7 +15,7 @@ import (
"github.com/weaveworks/weave/router" "github.com/weaveworks/weave/router"
) )
func startServer(t *testing.T) (*DNSServer, *Nameserver, int, int) { func startServer(t *testing.T, upstream *dns.ClientConfig) (*DNSServer, *Nameserver, int, int) {
peername, err := router.PeerNameFromString("00:00:00:02:00:00") peername, err := router.PeerNameFromString("00:00:00:02:00:00")
require.Nil(t, err) require.Nil(t, err)
nameserver := New(peername, nil, nil, "") nameserver := New(peername, nil, nil, "")
@@ -23,13 +23,16 @@ func startServer(t *testing.T) (*DNSServer, *Nameserver, int, int) {
require.Nil(t, err) require.Nil(t, err)
udpPort := dnsserver.servers[0].PacketConn.LocalAddr().(*net.UDPAddr).Port udpPort := dnsserver.servers[0].PacketConn.LocalAddr().(*net.UDPAddr).Port
tcpPort := dnsserver.servers[1].Listener.Addr().(*net.TCPAddr).Port tcpPort := dnsserver.servers[1].Listener.Addr().(*net.TCPAddr).Port
if upstream != nil {
dnsserver.upstream = upstream
}
go dnsserver.ActivateAndServe() go dnsserver.ActivateAndServe()
return dnsserver, nameserver, udpPort, tcpPort return dnsserver, nameserver, udpPort, tcpPort
} }
func TestTruncation(t *testing.T) { func TestTruncation(t *testing.T) {
//common.SetLogLevel("debug") //common.SetLogLevel("debug")
dnsserver, nameserver, udpPort, tcpPort := startServer(t) dnsserver, nameserver, udpPort, tcpPort := startServer(t, nil)
defer dnsserver.Stop() defer dnsserver.Stop()
// Add 100 mappings to nameserver // Add 100 mappings to nameserver
@@ -122,9 +125,9 @@ func TestRecursiveCompress(t *testing.T) {
require.True(t, response.Len() <= maxSize) require.True(t, response.Len() <= maxSize)
// A dns server that returns the above response // A dns server that returns the above response
var gotRequest = false var gotRequest = make(chan struct{}, 1)
handleRecursive := func(w dns.ResponseWriter, req *dns.Msg) { handleRecursive := func(w dns.ResponseWriter, req *dns.Msg) {
gotRequest = true gotRequest <- struct{}{}
require.Equal(t, req.Question[0].Name, hostname) require.Equal(t, req.Question[0].Name, hostname)
response.SetReply(req) response.SetReply(req)
err := w.WriteMsg(&response) err := w.WriteMsg(&response)
@@ -140,14 +143,13 @@ func TestRecursiveCompress(t *testing.T) {
defer udpServer.Shutdown() defer udpServer.Shutdown()
// The weavedns server, pointed at the above server // The weavedns server, pointed at the above server
dnsserver, _, udpPort, _ := startServer(t) dnsserver, _, udpPort, _ := startServer(t, &dns.ClientConfig{
dnsserver.upstream = &dns.ClientConfig{
Servers: []string{"127.0.0.1"}, Servers: []string{"127.0.0.1"},
Port: strconv.Itoa(udpServerPort), Port: strconv.Itoa(udpServerPort),
Ndots: 1, Ndots: 1,
Timeout: 5, Timeout: 5,
Attempts: 2, Attempts: 2,
} })
defer dnsserver.Stop() defer dnsserver.Stop()
// Now do lookup, check its what we expected. // Now do lookup, check its what we expected.
@@ -165,6 +167,6 @@ func TestRecursiveCompress(t *testing.T) {
c := new(dns.Client) c := new(dns.Client)
res, _, err := c.Exchange(req, fmt.Sprintf("127.0.0.1:%d", udpPort)) res, _, err := c.Exchange(req, fmt.Sprintf("127.0.0.1:%d", udpPort))
require.Nil(t, err) require.Nil(t, err)
require.True(t, gotRequest) require.True(t, len(gotRequest) > 0)
require.True(t, res.Len() > maxSize) require.True(t, res.Len() > maxSize)
} }
+1 -1
View File
@@ -13,7 +13,7 @@ func (i *inspectContainerInterceptor) InterceptRequest(r *http.Request) error {
} }
func (i *inspectContainerInterceptor) InterceptResponse(r *http.Response) error { func (i *inspectContainerInterceptor) InterceptResponse(r *http.Response) error {
if !i.proxy.RewriteInspect { if !i.proxy.RewriteInspect || r.StatusCode != 200 {
return nil return nil
} }
+1 -1
View File
@@ -60,7 +60,7 @@ func (dec *EthernetDecoder) sendICMPFragNeeded(mtu int, sendFrame func([]byte) e
return err return err
} }
log.Printf("Sending ICMP 3,4 (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, mtu) log.Printf("Sending ICMP 3,4 (%v -> %v): PMTU=%v", dec.IP.DstIP, dec.IP.SrcIP, mtu)
return sendFrame(buf.Bytes()) return sendFrame(buf.Bytes())
} }
+7
View File
@@ -148,11 +148,18 @@ func (c *GossipChannel) gcSenders(connections ConnectionSet) {
} }
} }
// We have seen a couple of failures which suggest a >128GB slice was encountered.
// 100MB should be enough for anyone.
const maxFeasibleMessageLen = 100 * 1024 * 1024
func (c *GossipChannel) sendDown(conn Connection, data GossipData) { func (c *GossipChannel) sendDown(conn Connection, data GossipData) {
sender, found := c.senders[conn] sender, found := c.senders[conn]
if !found { if !found {
sender = NewGossipSender(func(pending GossipData) { sender = NewGossipSender(func(pending GossipData) {
for _, msg := range pending.Encode() { for _, msg := range pending.Encode() {
if len(msg) > maxFeasibleMessageLen {
panic(fmt.Sprintf("Gossip message too large: len=%d bytes; on channel '%s' from %+v", len(msg), c.name, pending))
}
protocolMsg := ProtocolMsg{ProtocolGossip, GobEncode(c.name, c.ourself.Name, msg)} protocolMsg := ProtocolMsg{ProtocolGossip, GobEncode(c.name, c.ourself.Name, msg)}
conn.(ProtocolSender).SendProtocolMsg(protocolMsg) conn.(ProtocolSender).SendProtocolMsg(protocolMsg)
} }
+1 -1
View File
@@ -69,7 +69,7 @@ func (peer *LocalPeer) RelayBroadcast(srcPeer *Peer, frame []byte, dec *Ethernet
dec) dec)
if err != nil { if err != nil {
if ftbe, ok := err.(FrameTooBigError); ok { if ftbe, ok := err.(FrameTooBigError); ok {
log.Warningf("dropping too big DF broadcast frame (%v -> %v): PMTU= %v", dec.IP.DstIP, dec.IP.SrcIP, ftbe.EPMTU) log.Warningf("dropping too big DF broadcast frame (%v -> %v): PMTU=%v", dec.IP.SrcIP, dec.IP.DstIP, ftbe.EPMTU)
} else { } else {
log.Errorln(err) log.Errorln(err)
} }
+1 -4
View File
@@ -37,10 +37,7 @@ Some prerequisites are needed to build weave:
* Install Docker if you haven't already, by following the instructions * Install Docker if you haven't already, by following the instructions
[on the Docker [on the Docker
site](https://docs.docker.com/installation/ubuntulinux/). Note that site](https://docs.docker.com/installation/ubuntulinux/).
we recommend using the Docker-maintained `lxc-docker` package, rather
than the `docker.io` package which contains a very old version. Then
install the other prerequisites for building with:
* Building weave requires Go 1.4.2, and the `golang` package in Ubuntu * Building weave requires Go 1.4.2, and the `golang` package in Ubuntu
14.04 LTS is too old. So you may need to [install the tarball from 14.04 LTS is too old. So you may need to [install the tarball from
golang.org](http://golang.org/doc/install). golang.org](http://golang.org/doc/install).
+1
View File
@@ -11,3 +11,4 @@ layout: default
* [Troubleshooting](troubleshooting.html) * [Troubleshooting](troubleshooting.html)
* [Building](building.html) * [Building](building.html)
* [How it works](how-it-works.html) * [How it works](how-it-works.html)
* [Latest release](https://github.com/weaveworks/weave/releases/tag/latest_release)
+1 -2
View File
@@ -23,8 +23,7 @@ normally place it in `/etc/systemd/system/weave.service`.
[Service] [Service]
EnvironmentFile=-/etc/sysconfig/weave EnvironmentFile=-/etc/sysconfig/weave
ExecStartPre=/usr/local/bin/weave launch $PEERS ExecStartPre=/usr/local/bin/weave launch $PEERS
ExecStart=/usr/bin/docker logs -f weave ExecStart=/usr/bin/docker attach weave
SuccessExitStatus=2
ExecStop=/usr/local/bin/weave stop ExecStop=/usr/local/bin/weave stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
+1 -1
View File
@@ -224,7 +224,7 @@ available from the `weave status` commands. You can also supply a
Golang text template to `weave report` in a similar fashion to `docker Golang text template to `weave report` in a similar fashion to `docker
inspect`: inspect`:
$ weave report -f '{{{.DNS.Domain}}' $ weave report -f {% raw %}'{{.DNS.Domain}}'{% endraw %}
weave.local. weave.local.
### <a name="list-attached-containers"></a>List attached containers ### <a name="list-attached-containers"></a>List attached containers
+1 -1
View File
@@ -25,7 +25,7 @@ sleep 35 # give weave time to discover the PMTU
# Check large packets get through. The first attempt typically fails, # Check large packets get through. The first attempt typically fails,
# since the sending container hasn't discovered the PMTU yet. The 2nd # since the sending container hasn't discovered the PMTU yet. The 2nd
# attempt should succeed. # attempt should succeed.
exec_on $HOST2 c2 $PING -s 10000 $C1 2>&1 1>/dev/null || true exec_on $HOST2 c2 $PING -s 10000 $C1 1>/dev/null 2>&1 || true
assert_raises "exec_on $HOST2 c2 $PING -s 10000 $C1" assert_raises "exec_on $HOST2 c2 $PING -s 10000 $C1"
run_on $HOST2 "sudo iptables -D $drop_large_udp_packets" run_on $HOST2 "sudo iptables -D $drop_large_udp_packets"
File renamed without changes.
+31
View File
@@ -0,0 +1,31 @@
#! /bin/bash
. ./config.sh
C1=10.2.1.43
C2=10.2.1.44
C3=10.2.1.45
start_suite "re-using IP addresses (arp cache updating)"
weave_on $HOST1 launch
check() {
assert_raises "exec_on $HOST1 c1 $PING $C2"
}
start_container $HOST1 $C1/24 --name=c1
start_container $HOST1 $C2/24 --name=c2
check
docker_on $HOST1 stop c2
start_container $HOST1 $C2/24 --name=c3
check
docker_on $HOST1 stop c3
start_container $HOST1 $C3/24 --name=c4
weave_on $HOST1 attach $C2/24 c4
check
end_suite
-2
View File
@@ -15,6 +15,4 @@ start_container_with_dns $HOST1 $C1/24 --name=c1
assert_dns_record $HOST1 c1 $NAME $C2 assert_dns_record $HOST1 c1 $NAME $C2
assert_raises "exec_on $HOST1 c1 dig MX $NAME | grep -q 'status: NXDOMAIN'"
end_suite end_suite
+6 -2
View File
@@ -6,7 +6,11 @@ start_suite "Negative DNS queries"
weave_on $HOST1 launch weave_on $HOST1 launch
start_container_with_dns $HOST1 --name c1 start_container_with_dns $HOST1 --name c1
assert_raises "exec_on $HOST1 c1 dig A foo.weave.local | grep 'status: NXDOMAIN'"
assert_raises "exec_on $HOST1 c1 dig A foo.invalid | grep 'status: NXDOMAIN'" # unsupported query types, unknown names, and unknown domains should
# all trigger NXDOMAIN
assert_raises "exec_on $HOST1 c1 dig MX c1.weave.local | grep -q 'status: NXDOMAIN'"
assert_raises "exec_on $HOST1 c1 dig A xx.weave.local | grep -q 'status: NXDOMAIN'"
assert_raises "exec_on $HOST1 c1 dig A xx.invalid | grep -q 'status: NXDOMAIN'"
end_suite end_suite
-2
View File
@@ -14,12 +14,10 @@ start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1 start_container_with_dns $HOST1 $C1/24 --name=c1
assert_dns_record $HOST1 c1 $NAME $C2 assert_dns_record $HOST1 c1 $NAME $C2
assert_raises "exec_on $HOST1 c1 dig MX $NAME | grep -q 'status: NXDOMAIN'"
weave_on $HOST1 stop weave_on $HOST1 stop
weave_on $HOST1 launch weave_on $HOST1 launch
assert_dns_record $HOST1 c1 $NAME $C2 assert_dns_record $HOST1 c1 $NAME $C2
assert_raises "exec_on $HOST1 c1 dig MX $NAME | grep -q 'status: NXDOMAIN'"
end_suite end_suite
-2
View File
@@ -16,8 +16,6 @@ for i in $(seq $N); do
done done
weave_on $HOST1 dns-add $IPS $CID -h $NAME weave_on $HOST1 dns-add $IPS $CID -h $NAME
assert_raises "exec_on $HOST1 c0 dig MX $NAME | grep -q 'status: NXDOMAIN'"
check() { check() {
assert "exec_on $HOST1 c0 dig +short $* $NAME A | grep -v ';;' | wc -l" $N assert "exec_on $HOST1 c0 dig +short $* $NAME A | grep -v ';;' | wc -l" $N
} }
+3 -1
View File
@@ -29,9 +29,11 @@ docker_py_test() {
weave_on $HOST1 launch-proxy --no-default-ipalloc weave_on $HOST1 launch-proxy --no-default-ipalloc
DOCKER_BRIDGE_IP=$(weave_on $HOST1 docker-bridge-ip)
if docker_on $HOST1 run \ if docker_on $HOST1 run \
-e NOT_ON_HOST=true \ -e NOT_ON_HOST=true \
-e DOCKER_HOST=tcp://172.17.42.1:12375 \ -e DOCKER_HOST=tcp://$DOCKER_BRIDGE_IP:12375 \
-v /tmp:/tmp \ -v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
joffrey/docker-py py.test $TESTS ; then joffrey/docker-py py.test $TESTS ; then
+2 -2
View File
@@ -28,8 +28,8 @@ assert_raises "DOCKER_CLIENT_ARGS='--tls' weave_on $HOST1 launch-proxy" 1
assert_raises "DOCKER_CERT_PATH='./tls' DOCKER_TLS_VERIFY=1 weave_on $HOST1 launch-proxy" 1 assert_raises "DOCKER_CERT_PATH='./tls' DOCKER_TLS_VERIFY=1 weave_on $HOST1 launch-proxy" 1
# Booting it with a specific -H overrides defaults # Booting it with a specific -H overrides defaults
weave_on $HOST1 launch-proxy -H unix:///var/run/weave2.sock weave_on $HOST1 launch-proxy -H tcp://0.0.0.0:12345
assert_raises "run_on $HOST1 sudo docker -H unix:///var/run/weave2.sock ps" assert_raises "run_on $HOST1 sudo docker -H tcp://$HOST1:12345 ps"
assert_raises "proxy docker_on $HOST1 ps" 1 assert_raises "proxy docker_on $HOST1 ps" 1
weave_on $HOST1 stop-proxy weave_on $HOST1 stop-proxy
+20
View File
@@ -57,3 +57,23 @@ DOCKER_OPTS="--host unix:///var/run/docker.sock --host tcp://0.0.0.0:2375"
``` ```
to the file `/etc/default/docker`, then restart docker. to the file `/etc/default/docker`, then restart docker.
## Updating the GCE test image
When a new version of Docker is released, you'll need to update the GCE test image.
To do this, pick a fresh ```TEMPLATE_NAME``` and update any commands in
```function make_template``` in gce.sh, then run:
```
./gce.sh make_template
```
For this you'll need the GCE credentials, which can be found in ```bin/setup-circleci-secrets```,
which you'll need to decrypt and run (its echos the secrets into know locations):
```
./bin/setup-circleci-secrets "$SECRET_PASSWORD"
```
If you don't know the password, ask tom@weave.works.
+3 -3
View File
@@ -12,7 +12,7 @@ ip_suffix_base = 10
require '../vagrant-common.rb' require '../vagrant-common.rb'
def configure_docker(host, hostname, ip) def configure_docker(host, hostname, ip)
pkgs = %w(lxc-docker ethtool) pkgs = %w(docker-engine ethtool)
host.vm.box = "ubuntu/ubuntu-15.04-amd64" host.vm.box = "ubuntu/ubuntu-15.04-amd64"
host.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/vivid/current/vivid-server-cloudimg-amd64-vagrant-disk1.box" host.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/vivid/current/vivid-server-cloudimg-amd64-vagrant-disk1.box"
@@ -22,8 +22,8 @@ def configure_docker(host, hostname, ip)
host.vm.synced_folder ".", "/vagrant", disabled: true host.vm.synced_folder ".", "/vagrant", disabled: true
host.vm.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" host.vm.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D"
host.vm.provision :shell, :inline => "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" host.vm.provision :shell, :inline => "echo deb https://apt.dockerproject.org/repo ubuntu-vivid main > /etc/apt/sources.list.d/docker.list"
install_packages host.vm, pkgs install_packages host.vm, pkgs
tweak_docker_daemon host.vm tweak_docker_daemon host.vm
+4 -4
View File
@@ -11,7 +11,7 @@ set -e
: ${SSH_KEY_FILE:=$HOME/.ssh/gce_ssh_key} : ${SSH_KEY_FILE:=$HOME/.ssh/gce_ssh_key}
: ${PROJECT:=positive-cocoa-90213} : ${PROJECT:=positive-cocoa-90213}
: ${IMAGE:=ubuntu-14-04} : ${IMAGE:=ubuntu-14-04}
: ${TEMPLATE_NAME:=test-template-3} : ${TEMPLATE_NAME:=test-template-4}
: ${ZONE:=us-central1-a} : ${ZONE:=us-central1-a}
: ${NUM_HOSTS:=5} : ${NUM_HOSTS:=5}
SUFFIX="" SUFFIX=""
@@ -68,10 +68,10 @@ function try_connect {
function install_docker_on { function install_docker_on {
name=$1 name=$1
ssh -t $name sudo bash -x -s <<EOF ssh -t $name sudo bash -x -s <<EOF
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9; curl -sSL https://get.docker.com/gpg | sudo apt-key add -
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list; curl -sSL https://get.docker.com/ | sh
apt-get update -qq; apt-get update -qq;
apt-get install -q -y --force-yes --no-install-recommends lxc-docker ethtool; apt-get install -q -y --force-yes --no-install-recommends ethtool;
usermod -a -G docker vagrant; usermod -a -G docker vagrant;
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"' >> /etc/default/docker; echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"' >> /etc/default/docker;
service docker restart service docker restart
+1 -1
View File
@@ -6,7 +6,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
. ./config.sh . ./config.sh
(cd ./tls && go get ./... && go run generate_certs.go $HOSTS) (cd ./tls && go get -tags netgo ./... && go run generate_certs.go $HOSTS)
echo "Copying weave images, scripts, and certificates to hosts, and" echo "Copying weave images, scripts, and certificates to hosts, and"
echo " prefetch test images" echo " prefetch test images"
+4 -4
View File
@@ -5,7 +5,7 @@ import (
"log" "log"
"os" "os"
"github.com/docker/machine/utils" "github.com/docker/machine/libmachine/cert"
) )
const ( const (
@@ -28,7 +28,7 @@ func main() {
log.Fatalf("The CA key already exists. Please remove it or specify a different key/cert.") log.Fatalf("The CA key already exists. Please remove it or specify a different key/cert.")
} }
if err := utils.GenerateCACertificate(caCertPath, caKeyPath, org, bits); err != nil { if err := cert.GenerateCACertificate(caCertPath, caKeyPath, org, bits); err != nil {
log.Printf("Error generating CA certificate: %s", err) log.Printf("Error generating CA certificate: %s", err)
} }
} }
@@ -41,7 +41,7 @@ func main() {
log.Fatalf("The client key already exists. Please remove it or specify a different key/cert.") log.Fatalf("The client key already exists. Please remove it or specify a different key/cert.")
} }
err = utils.GenerateCert( err = cert.GenerateCert(
[]string{""}, []string{""},
clientCertPath, clientCertPath,
clientKeyPath, clientKeyPath,
@@ -64,7 +64,7 @@ func main() {
if _, err := os.Stat(serverCertPath); os.IsNotExist(err) { if _, err := os.Stat(serverCertPath); os.IsNotExist(err) {
log.Printf("Creating server certificate: %s", serverCertPath) log.Printf("Creating server certificate: %s", serverCertPath)
err = utils.GenerateCert( err = cert.GenerateCert(
[]string{ip}, []string{ip},
serverCertPath, serverCertPath,
serverKeyPath, serverKeyPath,
+3 -3
View File
@@ -13,9 +13,9 @@ def install_build_deps(vm, pkgs)
vm.provision :shell, :inline => <<SCRIPT vm.provision :shell, :inline => <<SCRIPT
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
apt-key adv \ apt-key adv \
--keyserver hkp://keyserver.ubuntu.com:80 \ --keyserver hkp://p80.pool.sks-keyservers.net:80 \
--recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://get.docker.io/ubuntu docker main' \ echo 'deb https://apt.dockerproject.org/repo ubuntu-vivid main' \
> /etc/apt/sources.list.d/docker.list > /etc/apt/sources.list.d/docker.list
SCRIPT SCRIPT
install_packages(vm, pkgs) install_packages(vm, pkgs)
+39 -44
View File
@@ -96,7 +96,7 @@ usage() {
exec_remote() { exec_remote() {
docker $DOCKER_CLIENT_ARGS run --rm --privileged --net=host \ docker $DOCKER_CLIENT_ARGS run --rm --privileged --net=host \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run:/var/run \
-v /proc:/hostproc \ -v /proc:/hostproc \
-e PROCFS=/hostproc \ -e PROCFS=/hostproc \
-e DOCKERHUB_USER="$DOCKERHUB_USER" \ -e DOCKERHUB_USER="$DOCKERHUB_USER" \
@@ -332,8 +332,9 @@ configure_arp_cache() {
echo 1 >/proc/sys/net/ipv4/neigh/$1/ucast_solicit" echo 1 >/proc/sys/net/ipv4/neigh/$1/ucast_solicit"
} }
# Send out an unsolicated ARP response to update ARP cache entries # Send out an ARP announcement
# across the weave network. We do this in addition to # (https://tools.ietf.org/html/rfc5227#page-15) to update ARP cache
# entries across the weave network. We do this in addition to
# configure_arp_cache because a) with those ARP cache settings it # configure_arp_cache because a) with those ARP cache settings it
# still takes a few seconds to correct a stale ARP mapping, and b) # still takes a few seconds to correct a stale ARP mapping, and b)
# there is a kernel bug that means that the base_reachable_time # there is a kernel bug that means that the base_reachable_time
@@ -520,36 +521,36 @@ launch() {
} }
attach() { attach() {
if netnsenter ip link show $CONTAINER_IFNAME >/dev/null 2>&1 ; then if ! netnsenter ip link show $CONTAINER_IFNAME >/dev/null 2>&1 ; then
for ADDR in "$@" ; do connect_container_to_bridge || return 1
# container already has the expected network interface, so assume we set it up already;
# just add the IP address.
if netnsenter ip addr show dev $CONTAINER_IFNAME | grep -F $ADDR >/dev/null ; then
# address was there already
continue
fi
netnsenter ip addr add $ADDR dev $CONTAINER_IFNAME || return 1
done
return 0
fi fi
connect_container_to_bridge || return 1 NEW_ADDRS=
for ADDR in "$@" ; do for ADDR in "$@" ; do
if netnsenter ip addr show dev $CONTAINER_IFNAME | grep -F $ADDR >/dev/null ; then
# address was there already
continue
fi
netnsenter ip addr add $ADDR dev $CONTAINER_IFNAME || return 1 netnsenter ip addr add $ADDR dev $CONTAINER_IFNAME || return 1
NEW_ADDRS="$NEW_ADDRS $ADDR"
done done
netnsenter ip link set $CONTAINER_IFNAME up || return 1 netnsenter ip link set $CONTAINER_IFNAME up || return 1
for ADDR in "$@" ; do for ADDR in $NEW_ADDRS ; do
arp_update $CONTAINER_IFNAME $ADDR "netnsenter" arp_update $CONTAINER_IFNAME $ADDR "netnsenter"
done done
# Route multicast packets across the weave network. # Route multicast packets across the weave network.
# This must come last in 'attach'. If you change this, change weavewait to match. # This must come last in 'attach'. If you change this, change weavewait to match.
#
# The MTU lock prevents PMTU discovery for multicast
# destinations. Without that, the kernel sets the DF flag on
# multicast packets. Since RFC1122 prohibits sending of ICMP
# errors for packets with multicast destinations, that causes
# packets larger than the PMTU to be dropped silently.
if ! netnsenter ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then if ! netnsenter ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then
netnsenter ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME netnsenter ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME mtu lock $MTU
fi fi
} }
@@ -913,28 +914,20 @@ ipam_cidrs() {
shift 1 shift 1
ALL_CIDRS="" ALL_CIDRS=""
IPAM_CIDRs="" IPAM_CIDRs=""
if [ $# -eq 0 ] ; then # If no addresses passed in, get one in the default subnet
# If no addresses passed in, get one in the default subnet [ $# -gt 0 ] || set -- net:default
IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID$CHECK_ALIVE) || return 1 for arg in "$@" ; do
if [ "$IPAM_CIDRS" = "404 page not found" ] ; then if [ "${arg%:*}" = "net" ] ; then
echo "No IP address supplied (use the -iprange option on 'weave launch' to enable IP address allocation)" >&2 if [ "$arg" = "net:default" ] ; then
return 1
fi
ALL_CIDRS="$IPAM_CIDRS"
fi
while [ $# -gt 0 ] ; do
if [ "${1%:*}" = "net" ] ; then
if [ "$1" = "net:default" ] ; then
IPAM_URL=/ip/$CONTAINER_ID IPAM_URL=/ip/$CONTAINER_ID
else else
IPAM_URL=/ip/$CONTAINER_ID/"${1#net:}" IPAM_URL=/ip/$CONTAINER_ID/"${arg#net:}"
fi fi
CIDR=$(call_weave POST $IPAM_URL$CHECK_ALIVE) || return 1 CIDR=$(call_weave POST $IPAM_URL$CHECK_ALIVE) || return 1
if [ "$CIDR" = "404 page not found" ] ; then if [ "$CIDR" = "404 page not found" ] ; then
echo "IP address allocation must be enabled to use 'net:'" >&2 echo "IP address allocation must be enabled to use 'net:'" >&2
return 1 return 1
fi elif ! is_cidr "$CIDR" ; then
if ! is_cidr "$CIDR" ; then
echo "$CIDR" >&2 echo "$CIDR" >&2
return 1 return 1
fi fi
@@ -942,13 +935,12 @@ ipam_cidrs() {
ALL_CIDRS="$ALL_CIDRS $CIDR" ALL_CIDRS="$ALL_CIDRS $CIDR"
else else
# This is a plain IP address; warn if it clashes but carry on # This is a plain IP address; warn if it clashes but carry on
command_exists netcheck && netcheck --ignore-iface=$BRIDGE $1 || true command_exists netcheck && netcheck --ignore-iface=$BRIDGE $arg || true
if container_ip $CONTAINER_NAME 2>/dev/null ; then if container_ip $CONTAINER_NAME 2>/dev/null ; then
http_call_ip $CONTAINER_IP $HTTP_PORT PUT /ip/$CONTAINER_ID/${1%/*} >&2 http_call_ip $CONTAINER_IP $HTTP_PORT PUT /ip/$CONTAINER_ID/${arg%/*} >&2
fi fi
ALL_CIDRS="$ALL_CIDRS $1" ALL_CIDRS="$ALL_CIDRS $arg"
fi fi
shift 1
done done
} }
@@ -1053,7 +1045,7 @@ proxy_args() {
if [ -z "$PROXY_HOST" ] ; then if [ -z "$PROXY_HOST" ] ; then
case "$DOCKER_CLIENT_HOST" in case "$DOCKER_CLIENT_HOST" in
""|unix://*) ""|unix://*)
PROXY_HOST="unix:///var/run/weave.sock" PROXY_HOST="unix:///var/run/weave/weave.sock"
;; ;;
*) *)
PROXY_HOST="tcp://0.0.0.0:12375" PROXY_HOST="tcp://0.0.0.0:12375"
@@ -1074,7 +1066,7 @@ proxy_addr() {
warn_if_stopping_proxy_in_env() { warn_if_stopping_proxy_in_env() {
if PROXY_ADDR=$(proxy_addr 2>/dev/null) ; then if PROXY_ADDR=$(proxy_addr 2>/dev/null) ; then
[ "$PROXY_ADDR" != "$DOCKER_CLIENT_HOST" ] || echo "WARNING: It appears that your environment is configured to use the Weave Docker API proxy. Stopping it will break this and subsequent docker invocations. To restore your environment, run '\$(eval weave env --restore)'." [ "$PROXY_ADDR" != "$DOCKER_CLIENT_HOST" ] || echo "WARNING: It appears that your environment is configured to use the Weave Docker API proxy. Stopping it will break this and subsequent docker invocations. To restore your environment, run 'eval \$(weave env --restore)'."
fi fi
} }
@@ -1215,7 +1207,8 @@ launch_proxy() {
PROXY_CONTAINER=$(docker run --privileged -d --name=$PROXY_CONTAINER_NAME --net=host \ PROXY_CONTAINER=$(docker run --privileged -d --name=$PROXY_CONTAINER_NAME --net=host \
$PROXY_VOLUMES \ $PROXY_VOLUMES \
-v "$CONTAINERS_PATH":"$CONTAINERS_PATH" \ -v "$CONTAINERS_PATH":"$CONTAINERS_PATH" \
-v /var/run:/var/run \ -v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/weave:/var/run/weave \
-v /proc:/hostproc \ -v /proc:/hostproc \
-e PROCFS=/hostproc \ -e PROCFS=/hostproc \
-e WEAVE_CIDR=none \ -e WEAVE_CIDR=none \
@@ -1223,6 +1216,8 @@ launch_proxy() {
--entrypoint=/home/weave/weaveproxy \ --entrypoint=/home/weave/weaveproxy \
$WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $COVERAGE_ARGS $PROXY_ARGS) $WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $COVERAGE_ARGS $PROXY_ARGS)
wait_for_log $PROXY_CONTAINER_NAME "proxy listening" wait_for_log $PROXY_CONTAINER_NAME "proxy listening"
# backward compatibility
ln -sf -T /var/run/weave/weave.sock /var/run/weave.sock
} }
########################################################################################## ##########################################################################################
@@ -1350,7 +1345,7 @@ case "$COMMAND" in
launch) launch)
deprecation_warnings "$@" deprecation_warnings "$@"
check_not_running $CONTAINER_NAME $BASE_IMAGE check_not_running $CONTAINER_NAME $BASE_IMAGE
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
COMMON_ARGS=$(common_launch_args "$@") COMMON_ARGS=$(common_launch_args "$@")
launch_router "$@" launch_router "$@"
launch_proxy $COMMON_ARGS launch_proxy $COMMON_ARGS
@@ -1363,7 +1358,7 @@ case "$COMMAND" in
;; ;;
launch-proxy) launch-proxy)
deprecation_warnings "$@" deprecation_warnings "$@"
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
launch_proxy "$@" launch_proxy "$@"
echo $PROXY_CONTAINER echo $PROXY_CONTAINER
;; ;;
@@ -1616,7 +1611,7 @@ case "$COMMAND" in
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
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 >/dev/null 2>&1 || true ip link del ${LOCAL_IFNAME%@*} >/dev/null 2>&1 || true
done done
;; ;;
rmpeer) rmpeer)