From 69c935a6e8ef0f738bc9d4f2cab95e1a97dc4cb0 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 9 Sep 2015 19:52:08 +0100 Subject: [PATCH 01/29] Make latest_release description link to real release Closes #1399. --- bin/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/release b/bin/release index 24e8f265..c75169b4 100755 --- a/bin/release +++ b/bin/release @@ -223,7 +223,7 @@ publish() { --repo weave \ --tag latest_release \ --name "$RELEASE_NAME latest ($VERSION)" \ - --description "$RELEASE_DESCRIPTION" + --description "[Release Notes](https://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG)" github-release upload \ --user $GITHUB_USER \ From ac145052d61a46f0a4a01a32d24f3fea2c75b3d5 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 10 Sep 2015 17:23:05 +0100 Subject: [PATCH 02/29] Correct `weave stop` advice Fixes #1408. --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index 4df919a6..684f8795 100755 --- a/weave +++ b/weave @@ -1074,7 +1074,7 @@ proxy_addr() { warn_if_stopping_proxy_in_env() { 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 } From f7dfe9dd2394c17ac8bcdf61e239351355c12fe7 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 10 Sep 2015 17:58:28 +0100 Subject: [PATCH 03/29] 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. --- test/170_ip_reuse_test.sh | 31 +++++++++++++++++++++++++++++++ weave | 30 +++++++++++++----------------- 2 files changed, 44 insertions(+), 17 deletions(-) create mode 100755 test/170_ip_reuse_test.sh diff --git a/test/170_ip_reuse_test.sh b/test/170_ip_reuse_test.sh new file mode 100755 index 00000000..324108c6 --- /dev/null +++ b/test/170_ip_reuse_test.sh @@ -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 diff --git a/weave b/weave index 684f8795..6f0fa409 100755 --- a/weave +++ b/weave @@ -520,31 +520,27 @@ launch() { } attach() { - if netnsenter ip link show $CONTAINER_IFNAME >/dev/null 2>&1 ; then - for ADDR in "$@" ; do - # 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 + if ! netnsenter ip link show $CONTAINER_IFNAME >/dev/null 2>&1 ; then + connect_container_to_bridge || return 1 fi - connect_container_to_bridge || return 1 - + NEW_ADDRS= 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 + NEW_ADDRS="$NEW_ADDRS $ADDR" done netnsenter ip link set $CONTAINER_IFNAME up || return 1 - for ADDR in "$@" ; do - arp_update $CONTAINER_IFNAME $ADDR "netnsenter" - done + if [ -n "$NEW_ADDRS" ] ; then + for ADDR in "$NEW_ADDRS" ; do + arp_update $CONTAINER_IFNAME $ADDR "netnsenter" + done + fi # Route multicast packets across the weave network. # This must come last in 'attach'. If you change this, change weavewait to match. From 83ef93f3fbea670a83e609dbfe6acc5dd3ab6c0b Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Fri, 11 Sep 2015 14:06:44 +0100 Subject: [PATCH 04/29] detect running proxy regardless of version Fixes #1413. --- weave | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weave b/weave index 684f8795..f3220ff2 100755 --- a/weave +++ b/weave @@ -1350,7 +1350,7 @@ case "$COMMAND" in launch) deprecation_warnings "$@" 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 "$@") launch_router "$@" launch_proxy $COMMON_ARGS @@ -1363,7 +1363,7 @@ case "$COMMAND" in ;; launch-proxy) deprecation_warnings "$@" - check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE + check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE launch_proxy "$@" echo $PROXY_CONTAINER ;; From 5635ba1fd0436fbf3c80933e642d56667ab978b5 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 14 Sep 2015 16:31:37 +0100 Subject: [PATCH 05/29] Update out-dated error message --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index 530887e0..7c8bd412 100755 --- a/weave +++ b/weave @@ -913,7 +913,7 @@ ipam_cidrs() { # If no addresses passed in, get one in the default subnet IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID$CHECK_ALIVE) || return 1 if [ "$IPAM_CIDRS" = "404 page not found" ] ; then - echo "No IP address supplied (use the -iprange option on 'weave launch' to enable IP address allocation)" >&2 + echo "No IP address supplied and IP address allocation is disabled" >&2 return 1 fi ALL_CIDRS="$IPAM_CIDRS" From a7e0f036474c9c7da1329ab861c7d2c9dadea8a9 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 14 Sep 2015 17:02:35 +0100 Subject: [PATCH 06/29] Use explicit index into operations slice in cancelOpsFor() to avoid mis-indexing when more than one op is removed --- ipam/allocator.go | 6 ++++-- ipam/allocator_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index 28f2e449..4f692f84 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -126,12 +126,14 @@ func (alloc *Allocator) cancelOps(ops *[]operation) { // if we found any. func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool { var found bool - for i, op := range *ops { - if op.ForContainer(ident) { + for i := 0; i < len(*ops); { + if op := (*ops)[i]; op.ForContainer(ident) { found = true op.Cancel() *ops = append((*ops)[:i], (*ops)[i+1:]...) + continue } + i++ } return found } diff --git a/ipam/allocator_test.go b/ipam/allocator_test.go index fd444190..309de81c 100644 --- a/ipam/allocator_test.go +++ b/ipam/allocator_test.go @@ -240,6 +240,42 @@ 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) + go func() { + _, ok := alloc1.Allocate(container1, subnet, nil) + doneChan <- ok == nil + }() + + // Do another allocation in parallel, to check that is handled correctly + go func() { + _, ok := alloc1.Allocate(container1, subnet, nil) + doneChan <- ok == nil + }() + + AssertNothingSent(t, doneChan) + time.Sleep(100 * time.Millisecond) + AssertNothingSent(t, doneChan) + + alloc1.ContainerDied(container1) + + if <-doneChan || <-doneChan { + require.FailNow(t, "Error: got result from Allocate") + } +} + func TestGossipShutdown(t *testing.T) { const ( container1 = "abcdef" From 3039046a6d0c83a75cf96d3b5dec788496da32a0 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 15 Sep 2015 10:41:24 +0100 Subject: [PATCH 07/29] Strip v prefix for mainline and branch releases --- bin/release | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/release b/bin/release index c75169b4..e4422a1a 100755 --- a/bin/release +++ b/bin/release @@ -52,7 +52,11 @@ setup() { LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG) LATEST_RELEASE_SHA=$(git rev-parse 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 RELEASE_DIR=./releases/$LATEST_TAG } From 44c2861aba757e4bed2d59fe53b065f919232ab9 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 15 Sep 2015 10:41:41 +0100 Subject: [PATCH 08/29] Update release process doc --- docs/release-process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-process.md b/docs/release-process.md index 3f00d751..10c2f2ac 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -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`. * 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 - $TAG` + $TAG` for **Prerelease** builds, `## Release ${TAG#v}` otherwise. Commit the changelog update: From 6dfefb95e8ccc70489174174554f05b52adfb06b Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 15 Sep 2015 10:43:00 +0100 Subject: [PATCH 09/29] Advise installation of weaveworks github-release fork --- bin/release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/release b/bin/release index e4422a1a..efe43fe3 100755 --- a/bin/release +++ b/bin/release @@ -256,8 +256,8 @@ usage() { # Ensure required tooling is installed if ! which github-release >/dev/null; then echo "Please install git-release:" >&2 - echo -e "\tgo get github.com/aktau/github-release" >&2 - echo "and create a git token per https://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/weaveworks/github-release" >&2 exit 1 fi From bbf7646751329178dcdaf5100380ea2b59614470 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Mon, 14 Sep 2015 15:08:25 +0100 Subject: [PATCH 10/29] Update docker repo, keys and package name --- Vagrantfile | 2 +- test/Vagrantfile | 6 +++--- vagrant-common.rb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 55e3b54d..28f742f9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,7 +5,7 @@ require './vagrant-common.rb' vm_ip = "172.16.0.3" # arbitrary private IP pkgs = %w( - lxc-docker + docker-engine aufs-tools build-essential ethtool diff --git a/test/Vagrantfile b/test/Vagrantfile index 750f4c7f..1080bfdd 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -12,7 +12,7 @@ ip_suffix_base = 10 require '../vagrant-common.rb' 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_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.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" - 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 => "sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D" + 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 tweak_docker_daemon host.vm diff --git a/vagrant-common.rb b/vagrant-common.rb index 8b5557a1..2662565e 100644 --- a/vagrant-common.rb +++ b/vagrant-common.rb @@ -13,9 +13,9 @@ def install_build_deps(vm, pkgs) vm.provision :shell, :inline => <