Compare commits

...
3730 Commits
Author SHA1 Message Date
Martynas Pumputis 125f3cf6f6 Add release v1.9.2 2017-03-01 14:11:20 +00:00
Bryan Boreham b2ffe77029 Merge pull request #2821 from weaveworks/issues/2820-busybox-modprobe
Ignore modprobe errors in weave-kube/launch.sh
2017-03-01 11:32:52 +00:00
Martynas Pumputis 3607cf2d7a Add check for xt_set module
The check is based on actually trying to install an iptables rule
which uses the module.
2017-03-01 10:37:43 +00:00
Martynas Pumputis a57cf4bc83 Ignore modprobe errors in weave-kube/launch.sh
weave-kube is run by alpine image which uses busybox. modprobe of
busybox will return the "module not found" error [1], if a module is
built-in, which is an opposite behavior to modprobe distributed in
mainstream distros (e.g. ubuntu).

[1]: https://bugs.busybox.net/show_bug.cgi?id=5270
2017-02-28 11:26:40 +00:00
Bryan Boreham 6036037817 Added kops update to the release instructions 2017-02-27 18:10:13 +00:00
Bryan Boreham 242b8907bf Add release v1.9.1 2017-02-27 16:20:02 +00:00
Bryan Boreham 9db22c3cd6 Merge pull request #2818 from 'tobowers-fix-reverse-dns'
Lowercase the request before comparing it

Fix #2817
2017-02-27 16:15:18 +00:00
Bryan Boreham e57d79bd70 Test reverse DNS using dig
so that we can check it works with upper and lower case IN-ADDR.ARPA
2017-02-27 14:56:25 +00:00
Martynas Pumputis 589ab4f01d Merge pull request #2819 from weaveworks/issues/2726-modprobe
Ensure we have the right modules loaded for weave-npc

Fix #2726
2017-02-27 14:23:12 +00:00
Bryan Boreham 01fe09065c Add weave-npc required kernel modules to docs 2017-02-27 14:25:43 +00:00
Topper Bowers 83958561f7 some DNS clients send reverse lookups with uppercase suffixes. This lowercases the request before trimming the lowercase suffix. Problem discovered and discussed here: https://github.com/weaveworks/weave/issues/2817 2017-02-27 14:19:31 +01:00
Bryan Boreham cb73cf3f51 Ensure we have the kernel modules loaded for weave-npc 2017-02-27 12:32:57 +00:00
Martynas Pumputis 7a3e8e64b7 Merge pull request #2810 from ocadotechnology/add-pending-metrics
Add prometheus metrics for pending Allocates and Claims
2017-02-24 15:55:39 +00:00
Bryan Boreham f7ce16cba8 Move detailed warning about rmpeer from FAQ to docs 2017-02-23 13:22:28 +00:00
Bryan Boreham 6ac1fef01d Fix broken link 2017-02-23 13:22:16 +00:00
Bryan Boreham 5c19efae48 Merge pull request #2811 from weaveworks/issues/2223-faq-anchors
Add anchors to faq questions
2017-02-23 13:19:39 +00:00
Bryan Boreham f7c0da3ae1 Merge pull request #2781 from keontang/luanch-update
Add CONN_LIMIT environment var for running container
2017-02-23 12:40:01 +00:00
Bryan Boreham fe0c833cdf Move FAQ to the bottom of the menu 2017-02-23 12:28:51 +00:00
Bryan Boreham 58342f7509 add anchors to faq questions 2017-02-23 12:26:03 +00:00
Mike Bryant fad537cad7 Add prometheus metrics for pending Allocates and Claims 2017-02-23 11:41:07 +00:00
Bryan Boreham 6d5c2ad0fa Merge pull request #2793 from weaveworks/improve-fastdp-crypto-tests
Improve encryption tests
2017-02-22 14:56:14 +00:00
Martynas Pumputis b585e1f4cb Merge pull request #2795 from weaveworks/issues/2792-refcount-ipset
Reference-count ipset entries

Fix #2792
2017-02-22 14:01:26 +00:00
Bryan Boreham 7102bf6d9d Merge pull request #2803 from weaveworks/update-readme
update slack community and weave user group details
2017-02-21 15:38:34 +00:00
Bryan Boreham 77988012ed Merge pull request #2765 from weaveworks/issues/1644-fastdp-crypto-docs
Add fastdp-crypto docs
2017-02-20 17:56:32 +00:00
Bryan Boreham 2989e3cccd Merge pull request #2790 from weaveworks/update-netlink-dep
Update vishvananda/netlink
2017-02-20 17:51:37 +00:00
Bryan Boreham 5a47d1d13f Merge pull request #2796 from weaveworks/versions-manifest
Add versions manifest file for dependencies.
2017-02-20 11:42:30 +00:00
Martynas Pumputis d3795d4e74 Merge pull request #2774 from weaveworks/update-ipam-doc
Update IPAM documentation.
2017-02-16 12:09:08 +00:00
Marc CARRE bc97daf5c0 Update IPAM documentation. 2017-02-15 16:25:12 +00:00
abuehrle 08e4c98172 open new window punctuation 2017-02-14 14:41:25 -06:00
abuehrle ca254e066a changed to pro link for WUOG 2017-02-14 14:28:22 -06:00
abuehrle aea92a3563 update slack community and wuog 2017-02-14 14:16:37 -06:00
Bryan Boreham e9fa655e0e Merge pull request #2802 from weaveworks/issues/2761-build-chown
Make /usr/local/go writable to anyone
2017-02-14 16:55:37 +00:00
Martynas Pumputis 7d178ecee9 Make /usr/local/go writable to anyone
Previous attempt to chown the dir inside build.sh resulted in
a significant increase in a build time, and build.sh is exec'd
once per each build.
2017-02-14 15:45:25 +00:00
Bryan Boreham 201321f390 Remove refcounts on destroy and flush 2017-02-14 10:50:22 +00:00
Bryan Boreham 3afc528c88 Reference-count ipset entries 2017-02-14 10:26:59 +00:00
Marc CARRE 62c9522bf6 Fix bug in get_go_version_from_build_dockerfile.
Previously, the first line of the Dockerfile would have been selected, regardless of its value.
What we want is to actually select the first line matching the regex, and then extract the group corresponding to the Go version out of it.
2017-02-13 19:54:38 +00:00
Marc CARRE 1b45e8662e Add DEPENDENCIES file and source Vagrant and tests versions from it.
- One unique file to list all dependencies and dependencies' versions (except Go, currently defined in `build/Dockerfile`).
- Custom versions can now be injected into Vagrant VMs.
- Vagrant dev VMs, Vagrant test VMs, and `run-integration-tests.sh` all source from `DEPENDENCIES`, to keep things 'DRY'.
- Vagrant versions can be overriden using environment variables, like it was possible in `run-integration-tests.sh`.
2017-02-13 19:54:38 +00:00
Marc CARRE 3ce8aec039 Removed unecessary trailing whitespaces.
Noise on git diff if/when text editors remove them automatically, so might as well proactively remove them.
2017-02-13 19:54:38 +00:00
Martynas Pumputis 32d44e09a1 Merge pull request #2787 from weaveworks/issues/2784-preclaim-addresses
Claim existing IP addresses at startup with no race condition

Fixes #2784
2017-02-13 17:51:38 +00:00
Bryan Boreham 4e37f5ec42 Add explanations of various claim and allocation fields 2017-02-13 17:31:02 +00:00
Bryan Boreham 39f471e9d3 Merge pull request #2773 from weaveworks/issues/2772-check-type-on-delete
Handle cache.DeleteFinalStateUnknown
2017-02-13 15:49:24 +00:00
Bryan Boreham 293abd953e Fix flaky test 320
The intention, per the comments, is that host1 should claim from host2.
But host2 and host3 can carve up the space either way round.  If host1
claims from host3 then there is a race whether anyone finds out about
it.
Adding a 'prime' on host2 ensures the space is all owned by host2 at that point.
2017-02-13 11:30:34 +00:00
Bryan Boreham fde7dcdde9 Stop collecting addresses in weave script now we do it in Go 2017-02-13 11:30:34 +00:00
Bryan Boreham 7075b5d9fd Extend pre-existing address reclaim to docker containers 2017-02-13 11:30:34 +00:00
Bryan Boreham 50b1aa0c74 Merge pull request #2785 from weaveworks/typo-app-isolation-doc
Fix typo in CIDR.
2017-02-13 11:15:17 +00:00
Martynas Pumputis 7f48cc9239 Replace 110_encryption_2_test.sh by 110_sleeve_encryption_2_test.sh 2017-02-10 17:30:30 +00:00
Martynas Pumputis 8211afe5d5 Improve 111_fastdp_encryption_2_test.sh 2017-02-10 17:20:24 +00:00
Bryan Boreham e26dbf11e9 Stop collecting addresses in launch script now we do it in Go 2017-02-10 15:11:14 +00:00
Bryan Boreham 39ac1a0037 Collect existing weave addresses at start-up, to avoid a race when
doing it from the script

Note we need to run weaver in the host pid namespace, so it can search
for existing container IPs. Also now we are firing off sub-processes
it's better to not be PID 1 so Linux doesn't expect us to reap zombies.
2017-02-10 15:10:02 +00:00
Martynas Pumputis 86f716c38c Add fastdp-crypto docs 2017-02-10 14:49:47 +00:00
Marc CARRE d5c7c4476b Fix typo in CIDR. 2017-02-09 20:58:06 +00:00
Martynas Pumputis 2a02883f07 Update vishvananda/netlink 2017-02-09 15:56:02 +00:00
Martynas Pumputis f592e4b70a Merge pull request #2780 from weaveworks/tf-ansi-macos
Upgrade to latest build-tools.
2017-02-09 14:58:43 +00:00
Marc CARRE 968855e0a4 Upgrade to latest build-tools.
Make tools/provisioning/setup.sh behave consistently regardless of whether under Linux or macOS, and whether sourced or executed.
2017-02-09 14:35:54 +00:00
Jiyuan Tang bee031ad70 Add CONN_LIMIT environment for running container 2017-02-09 19:34:16 +08:00
Martynas Pumputis 3378e09b6a Merge pull request #2775 from weaveworks/num-hosts-via-env-var
Remove hard-coded NUM_HOSTS env. var.
2017-02-08 18:17:35 +00:00
Marc CARRE ab37b4a6c4 Remove hard-coded NUM_HOSTS env. var.
Instead of hardcoding this in the code, this should be passed by CircleCI from Settings > weaveworks > weave > Environment Variables.
2017-02-08 17:56:48 +00:00
Martynas Pumputis dff5b6d3f1 Merge pull request #2694 from weaveworks/2647-testing-mvp
Testing MVP

Fixes #2647
2017-02-08 16:25:56 +00:00
Marc CARRE c026579cec Update make lint to cope with latest changes made in build-tools. 2017-02-08 14:15:59 +00:00
Marc CARRE ef8b576742 Default behaviour now is to create a GCP image if missing.
We previously had 'use image' as a default, but not 'create image', which is inconsistent and leads to unexpected failures.
2017-02-08 14:15:59 +00:00
Marc CARRE 69398a9d7e Source config.sh using relative path to the script, regardless of current directory.
Sourcing failed when running make integration-tests.
2017-02-08 14:15:59 +00:00
Marc CARRE 0a2beedad3 Add flag to skip destruction of test VMS.
This should be useful when we just want to type one make integration-tests / ./run-integration-tests command to make/start VMs/configure them/test, but also investigate potential failures afterwards.
2017-02-08 14:15:59 +00:00
Marc CARRE 29d50bbf09 Globally redirect stdout to stderr, except when echo'ing "export HOSTS=...".
This should make development easier by allowing developers to set HOSTS in their calling shell, and re-use the value for this env. var. when calling individual test scripts, e.g.:
```
cd test
eval $(./run-integration-tests.sh setup)
./200_dns_test.sh
```
2017-02-08 14:15:59 +00:00
Marc CARRE 673fc73cd5 Increase number of test machines for CircleCI to 16.
This should speed the build up, and provide faster feedback to developers.
2017-02-08 14:15:59 +00:00
Marc CARRE 1185bed370 Changed default number of test machines to 3.
CircleCI keeps 10 nodes in order to speed up the build, but the default is 3, as this is the minimum required to run any test. This should make more sense as a default for a developer to quickly start an environment and iterate.
2017-02-08 14:15:59 +00:00
Marc CARRE 1176d44044 Run git submodule update --init as the very first step in CircleCI.
Doing so in circle-dependencies-post arrives too late for background provisioning.
2017-02-08 14:15:59 +00:00
Marc CARRE 77649ab81b Relax .lintignore in order for lint to cover newly added scripts. 2017-02-08 14:15:59 +00:00
Marc CARRE a51bc6164c Signal provisioning failures to fail the build fast.
There may be situations when Terraform/Ansible/etc. fail to provision test machines.
In these cases, we want to fail fast instead of waiting until we time out in circle-test-pre and circle-test-smoke.
2017-02-08 14:15:59 +00:00
Marc CARRE dd935b7e9e Provision and destroy test VMs in the background.
This should help speed-up the build by provisioning test VMs while we run unit tests, and destroying them while we generate coverage reports.
2017-02-08 14:15:59 +00:00
Marc CARRE 67dbdd377c Configure Vagrant VMs using Ansible.
This way, Vagrant VMs and cloud-provided VMs are configured in the exact same way, hence avoiding configuration drift and subtle bugs associated to different versions of software.
2017-02-08 14:15:59 +00:00
Marc CARRE e5185e73ce Refactor Vagrant configuration. 2017-02-08 14:15:59 +00:00
Marc CARRE 17ada094f8 Updated and improved testing documentation. 2017-02-08 14:15:59 +00:00
Marc CARRE 3e5593dc4f Add GCP image creation and usage.
Provisioning and configuration being expensive time-wise, we create Google Cloud Platform images for each Docker/Kubernetes/Kubernetes CNI versions triple, and configure these once (instead of for each build), and then re-use these in subsequent builds, effectively implementing a 'cache' of images.
2017-02-08 14:15:59 +00:00
Marc CARRE e647fe6331 Highlight setup and sanity checks in CircleCI's logs. 2017-02-08 14:15:59 +00:00
Marc CARRE a2679794b3 Install Terraform and Ansible in CircleCI's containers.
Terraform and Ansible are now required to run the smoke tests.
2017-02-08 14:15:59 +00:00
Marc CARRE 30f59953d2 Smoke tests are now run using Terraform, Ansible and run-integration-tests.sh. 2017-02-08 14:15:59 +00:00
Marc CARRE acd16881d9 Add make integration-tests based on Terraform/Ansible. 2017-02-08 14:15:59 +00:00
Marc CARRE 2aaa400d62 Add Terraform and Ansible scripts as part of tools submodule. 2017-02-08 14:15:55 +00:00
Marc CARRE 487ebfb514 Increased timeout for test #840.
Reason: test is periodically failing because of the timeout being too aggressive, especially when using Google Cloud Platform together with Terraform and Ansible.
2017-02-08 14:15:02 +00:00
Marc CARRE fde7e88e66 Allow RUNNER_ARGS to be passed by calling script.
This is required in order to be able to dependency-inject values from layers higher up, e.g.: RUNNER_ARGS="-parallel" from the Makefile.
2017-02-08 14:15:02 +00:00
Marc CARRE 9e4ce8c052 Git-ignore Terraform state files. 2017-02-08 14:15:02 +00:00
Adam Harrison defa5cc3d3 Handle cache.DeleteFinalStateUnknown 2017-02-08 12:48:32 +00:00
Martynas Pumputis dea2755161 Merge pull request #2764 from weaveworks/ports-faq
Expand FAQ info about port usage
2017-02-07 14:23:15 +00:00
Bryan Boreham cc8785fdcf Expand info about port usage 2017-02-07 14:06:24 +00:00
Bryan Boreham 7265c6ea03 Move sed of daemonset up next to weave script
For consistency, also for easier unpicking if the 'draft' stage fails
2017-02-03 12:18:48 +00:00
Bryan Boreham 0792f0717d Revert "Temporarily release weave-daemonset.yaml to weave-kube repo"
This reverts commit 23056cbb45.
Explanation: weave-kube has been moved into the weave repo
2017-02-02 11:56:54 +00:00
Bryan Boreham 851b58cca8 Add release v1.9.0 2017-02-02 11:01:34 +00:00
Bryan Boreham cb48ebc399 Bump alpine version to 3.5 for arm64
Since 3.4 doesn't exist, and the package repo seems ok for ulogd now
2017-02-02 10:43:29 +00:00
Martynas Pumputis 5278eb7ebc Merge pull request #2747 from weaveworks/issues/2689-npc-mcast-simple
Add rule to allow multicast at top level
2017-02-01 18:20:38 +00:00
Bryan Boreham 418c256689 Allow traffic to forward off the weave bridge 2017-02-01 15:01:18 +00:00
Bryan Boreham 4eeb846507 Add tests for connectivity to the world 2017-02-01 15:01:18 +00:00
Bryan Boreham 7529f5f9af Raise ping timeout to reduce false negatives 2017-02-01 15:01:18 +00:00
Michal Rostecki 8506e57482 Pin alpine container version
Alpine 3.5 doesn't provide PCAP plugin with ulogd, so until
we investigate the problem upstream, we need to pin to 3.4
version.

Fixes #2732
2017-02-01 12:05:31 +00:00
Adam Harrison b1d09305e4 Merge pull request #2687 from weaveworks/issues/1644-fastdp-crypto
Fastdp crypto
2017-02-01 10:28:24 +00:00
Martynas Pumputis 07892bff7d Reduce the default MTU 2017-01-31 17:21:01 +00:00
Martynas Pumputis 50985dee90 Enable ESN in fastdp-crypto 2017-01-31 17:21:01 +00:00
Martynas Pumputis 60323d0960 Add fastdp crypto 2017-01-31 17:21:01 +00:00
Bryan Boreham a9cef6327f Update information about Weaveworks products 2017-01-31 12:43:53 +00:00
Bryan Boreham fdeb9010ba Merge pull request #2757 from weaveworks/upgrade-build-tools
Upgrade to latest 'common' and 'build-tools'.
2017-01-31 12:17:31 +00:00
Marc CARRE ee659d4033 Replace weave/common/mflagext with common/mflagext.
Removes duplication between weave and common and reduces the amount of sources to compile.
2017-01-31 10:49:29 +00:00
Marc CARRE 8f9b2a36c0 Remove dep. on docker and use mflag from common.
This reduces the number of dependencies, and avoids having docker as a vendored dependency, which should speed the build up.
2017-01-31 10:30:12 +00:00
Bryan Boreham 6a83130685 Document multicast behaviour of weave-npc 2017-01-30 18:14:57 +00:00
Marc CARRE 77e6c6f886 Upgrade to latest 'common' and 'build-tools'.
If building against the latest 'build-tools', you would typically get:
tools/runner/runner.go:18:2: cannot find package github.com/weaveworks/common/mflag
This change fixes the issue by upgrading both dependencies.
2017-01-30 18:05:58 +00:00
Adam Harrison 8a5a15d5e9 Merge pull request #2753 from weaveworks/mv-signal-to-common
Move signal handling loop to common.
2017-01-30 12:38:23 +00:00
Bryan Boreham bcc8c73f59 Fix build of manifest_tool in 'make publish' 2017-01-30 11:02:11 +00:00
Bryan Boreham e22c6375c9 Fix build of manifest_tool 2017-01-27 18:09:22 +00:00
Marc Carré 22ae0d200c Merge pull request #2752 from weaveworks/makefile-cleanup
Makefile cleanup after multiarch merge
2017-01-27 16:51:44 +00:00
Bryan Boreham 7231bd00f8 Remove .weavedb.uptodate file when we remove the weavedb image in 'make clean-bin' 2017-01-27 16:26:05 +00:00
Tom Wilkie 590a151bde Move signal handling loop to common. 2017-01-26 17:55:19 +00:00
Martynas Pumputis f5dfefef75 Merge pull request #2749 from weaveworks/shfmt-ignore
Upgrade Weave Net to latest version of build-tools, skipping bash scripts when lint-ing.
2017-01-26 10:55:36 +00:00
Marc CARRE 8e6cb5e24d Print files we currently do not lint.
Makes what the build does explicitly and helps for potential debugging.
Also reminds us that we are skipping these files, so that we ultimately shfmt them and stop lint-ignoring them.
2017-01-25 17:14:48 +00:00
Marc CARRE ed629d420d Pass additional options to ./tools/test to revert to previous behaviour.
Previous commit upgrades Weave Net to the latest version of `build-tools`.
However, `./tools/test`'s default behaviour has changed, so we need to explicitly pass new options/arguments, in order to keep it behaving like before fd568682c3.
2017-01-25 17:14:05 +00:00
Marc CARRE fd568682c3 Upgrade Weave Net to latest version of build-tools, skipping bash scripts when lint-ing.
Lint-ing all of Weave Net is currently not desirable because:

* it would create conflicts on many branches,
* it would pollute the git history,
* etc.

and because `lint` currently lints all files except `./vendor`, this breaks Weave Net's build.
As a result, Weave Net is not using the latest commit in `build-tools`'s `master` branch, which is also source of problems:

* it limits standardisation of projects across Weaveworks,
* it limits the ability to use the latest features of `build-tools`,
* it complexifies merging changes in `build-tools` (e.g. #53 and weaveworks/weave#2694 for weaveworks/weave#2647),
* etc.

This change:

* brings Weave Net to the latest version of `build-tools` (which now supports `.lintignore` files),
* adds such a `.lintignore` file to skip all bash scripts (in order to avoid breaking the build).

`GLOB`s in `.lintignore` can then, over time and as scripts are `shfmt`-ed, be relaxed and maybe even removed.
2017-01-25 16:50:32 +00:00
Bryan Boreham dbb9849b8c Remove whitespace from blank lines and comment lines
Principally because emacs complains about it, but also to remove the
overhead of firing up a shell process to ignore a comment in a recipe
2017-01-25 14:20:54 +00:00
Bryan Boreham 776af44782 Make manifest-tool using weave build container 2017-01-25 14:18:55 +00:00
Bryan Boreham 69dacd0594 Restrict CircleCI publishing to AMD64 2017-01-25 10:52:53 +00:00
Bryan Boreham f17a2a00b1 Merge pull request #2713 from luxaslabs/multiarch
Make Weave Net multi-architecture
2017-01-24 18:07:32 +00:00
Lucas Käldström 1a64420e01 Fix duplicate publish target 2017-01-24 17:38:44 +02:00
Bryan Boreham 49b9a2c8df Bump Docker to 1.10 2017-01-24 17:28:08 +02:00
Bryan Boreham 6c251417d5 Update 'docker inspect weavedb' format for Docker 1.10 2017-01-24 17:27:53 +02:00
Lucas Käldström 8c0c38c8b3 Add manifest-tool as a submodule 2017-01-24 17:27:30 +02:00
Lucas Käldström 29eee4e858 Fixing review feedback, adding checksums, etc 2017-01-24 17:24:04 +02:00
Lucas Käldström 454c6f713d Make Weave Net multi-architecture and add support for ARM and ARM 64-bit 2017-01-24 17:23:00 +02:00
Marc Carré dd715e18ec Merge pull request #2743 from weaveworks/fix-uuid
Don't fail if only half the system IDs are blank
2017-01-23 15:00:06 +00:00
Bryan Boreham f067c7d44e Add rule to allow multicast at top level 2017-01-23 12:11:44 +00:00
Bryan Boreham c1023eaf18 Hard-code repository name for weavebuild container
so we don't create a new one when testing publish to different DOCKERHUB_USER
2017-01-20 14:55:10 +00:00
Bryan Boreham b091f59311 Merge pull request #2734 from Compositional/master
Add partial support for non-FHS host systems
2017-01-20 14:45:33 +00:00
Marc Carré f98ad822e3 Merge pull request #2740 from weaveworks/issues/2738-dedupe-surrogate
Update mesh lib to break cycle of old gossip
2017-01-20 12:36:08 +00:00
Bryan Boreham 917c1ddbad Update mesh lib to break cycle of old gossip 2017-01-20 12:05:55 +00:00
Marc Carré d81d2f691d Merge pull request #2742 from weaveworks/build-improvements
Build improvements
2017-01-20 11:26:18 +00:00
Bryan Boreham 1ad118a38f Merge branch '1.8' 2017-01-20 09:45:13 +00:00
Bryan Boreham 9d1648cee7 Merge pull request #2741 from weaveworks/document-mtu-with-weave-kube
Document WEAVE_MTU in weave-kube config options
2017-01-20 09:40:57 +00:00
Bryan Boreham 929167366a Don't fail if only half the system IDs are blank 2017-01-19 15:57:21 +00:00
Bryan Boreham 353ccf5e6c Move build to 'dependencies' section
This means we don't spend time trying to run other tests if the build failed.
2017-01-19 10:59:16 +00:00
Bryan Boreham cfc1fa4fae Build test runner inside build container for consistency 2017-01-19 10:59:04 +00:00
Robert Hensing d881f47088 Add partial support for non-FHS host systems
Fixes weaveworks/weave#2733 partially, where <host>/etc/resolv.conf is not a
symlink
2017-01-18 23:28:49 +01:00
Bryan Boreham 84013c4452 Merge pull request #2735 from weaveworks/issues/2732-pin-alpine-version
Pin alpine container version
2017-01-18 16:49:04 +00:00
Adam Harrison d9dc1a988c Document WEAVE_MTU in weave-kube config options 2017-01-18 15:11:41 +00:00
Marc CARRE 5fd14348aa Fix broken link to 'Building Weave Net' documentation. 2017-01-17 17:49:17 +00:00
Adam Harrison 57a250a20b Pin alpine container version 2017-01-16 12:27:53 +00:00
Adam Harrison 81add75258 Merge pull request #2711 from weaveworks/issues/2427-unique-ids
Better machine unique IDs
2017-01-13 09:40:18 +00:00
Bryan Boreham 0145282a10 Merge pull request #2728 from weaveworks/issues/2653-ulogd-pdeathsig
SIGKILL ulogd on weave-npc exit
2017-01-11 17:31:18 +00:00
Adam Harrison ae0cb5d483 SIGKILL ulogd on weave-npc exit 2017-01-11 14:12:01 +00:00
Bryan Boreham e7eeecd762 Smoke test for peer names 2017-01-11 13:14:35 +00:00
Bryan Boreham 7d308a4ac5 Wire weaveutil unique-id into weave script
Also ensure the right host directories are mounted when create-bridge
is called from either the weave script or weave-kube.
2017-01-11 13:14:35 +00:00
Bryan Boreham ebcb7f6108 Use persisted peer name if it matches old-style ID 2017-01-11 13:14:35 +00:00
Bryan Boreham e03c7b1b7c Allow opening persistence file read-only 2017-01-11 13:13:19 +00:00
Bryan Boreham 70a20b4d26 Generate peer name / mac address in Go 2017-01-11 13:12:30 +00:00
Bryan Boreham d143470d77 Refactor: extract db filename to a constant 2017-01-11 13:05:25 +00:00
Bryan Boreham 30d6639a98 Refactor: move peer name identifier to DB package 2017-01-11 13:05:25 +00:00
Adam Harrison 92cfd3b4f9 Merge pull request #2725 from weaveworks/update-tools
Update tools submodule to avoid breaking on missing Docker mflag
2017-01-09 17:09:53 +00:00
Adam Harrison 7659ea21c7 Merge branch '1.8'
Fixes #2693.
2017-01-09 16:24:08 +00:00
Adam Harrison 4e740736e7 Merge pull request #2697 from weaveworks/issues/2693-npc-log-instructions
Fix instructions to view npc logs when >1 pod exists
2017-01-09 16:23:42 +00:00
Adam Harrison 4f44d9e25a Merge branch '1.8'
Fixes #2719.
2017-01-09 15:49:29 +00:00
Adam Harrison 2ae2d52289 Merge pull request #2722 from weaveworks/issues/2719-delete-pods
Warn not to delete all Weave Net pods
2017-01-09 15:48:48 +00:00
Adam Harrison 635191970f Merge pull request #2688 from weaveworks/issues/2684-exec-weaver
Exec weaver from weave-kube launch rather than running in background
2017-01-09 15:24:19 +00:00
Bryan Boreham e370443a3f Merge pull request #2699 from weaveworks/2647-parallelise-sanity-checks
Parallelise sanity checks in order to speed them up.
2017-01-09 12:57:44 +00:00
Bryan Boreham 738ff2b65f Update tools submodule to avoid breaking on missing Docker mflag 2017-01-09 12:50:18 +00:00
Bryan Boreham cef8c908d0 Merge pull request #2704 from weaveworks/2647-parallelise-setup
Parallelise setup.sh's individual tasks.
2017-01-09 12:30:53 +00:00
Marc CARRE edc0cdbc10 Sanity checks' output is now redirected to $CIRCLE_ARTIFACTS directly when running smoke tests in CircleCI.
Previously sanity checks' output was redirected to /tmp and then copied to $CIRCLE_ARTIFACTS, which is more "moving pieces".
2017-01-09 12:25:29 +00:00
Marc CARRE 89e116961c Now measure time spent in setup. 2017-01-09 12:03:13 +00:00
Marc CARRE 71180f97e7 Parallelise setup.sh. 2017-01-09 12:03:09 +00:00
Adam Harrison be8d9d88d8 Merge pull request #2724 from weaveworks/2647-remove-dependency-on-jq
Removed dependency on jq in test #175.
2017-01-09 10:59:52 +00:00
Bryan Boreham 35de3720e9 Merge pull request #2698 from weaveworks/2647-find-relative-dir
Finding and running tests no longer depends on current directory.
2017-01-09 10:34:07 +00:00
Marc CARRE 4a7e2054db Removed dependency on jq in test #175.
If the machine coordinating the test runs does not have jq, then test #175 fails with:
> test #1 "weave_on test-0.lon1.weave-net report | jq -r '.Router.Targets[] | tostring' | sort" failed:
>     expected "test-1.lon1.weave-net
> test-2.lon1.weave-net"
>     got nothing
This change completely removes the dependency on jq to make the test more robust and avoid potential confusion.
2017-01-09 10:16:05 +00:00
Marc CARRE fe75047988 weave-daemonset.yaml is now referred to using relative paths. 2017-01-09 10:08:38 +00:00
Marc CARRE f73fb5307f Redirect sanity checks' output to temporary files (and archive them as artifact files under CircleCLI).
This should make it easier to find and access relevant debugging information without polluting STDOUT and without any risk of log interleaving. See also:
- https://weaveworks.slack.com/archives/net/p1482154505001192
- https://weaveworks.slack.com/archives/net/p1482254780001493
2017-01-09 09:17:45 +00:00
Marc CARRE 172597a68d Now measure time spent in sanity checks. 2017-01-09 09:17:45 +00:00
Marc CARRE f05169e457 Initialise pids before using it, to avoid potential issues with previously set values. 2017-01-09 09:17:45 +00:00
Marc CARRE b171497466 Ensure sanity checks exit early in case of a ping failure. 2017-01-09 09:17:45 +00:00
Marc CARRE 61375fb785 Format ping output as one line. 2017-01-09 09:17:45 +00:00
Marc CARRE 04cc4edf26 Parallelise sanity checks in order to speed them up. 2017-01-09 09:17:45 +00:00
Marc CARRE 0101a12fba Undo 0dff07dc8b since current directory is already changed on previous line. 2017-01-09 09:16:53 +00:00
Marc CARRE e094fb1547 DOCKER_CERT_PATH is now set using a relative path. 2017-01-09 09:16:53 +00:00
Marc CARRE e0a44a901a Tests now source dependencies using relative paths (previously breaking make depending on current directory). 2017-01-09 09:16:53 +00:00
Marc CARRE d4f9abeefd Finding tests no longer depends on current directory. 2017-01-09 09:16:53 +00:00
Bryan Boreham 0338d4595b Fix instructions to view npc logs when >1 pod exists 2017-01-06 11:24:20 +00:00
Bryan Boreham 7328c3fe86 Comment about full build on first push 2017-01-06 10:54:13 +00:00
Bryan Boreham bf288ff6f5 Warn not to delete all Weave Net pods 2017-01-06 10:30:46 +00:00
Marc Carré ef4c4024bc Merge pull request #2720 from weaveworks/2647-fix-test-150
Fix ordering bug in test #150.
2017-01-05 15:29:58 +00:00
Marc CARRE 6f24cca4b1 Fix ordering bug in test #150.
Test hard-codes a string containing '\n' and then expects echo
to interpret it as a newline, which it does not without the -e option.

This fixes flaky test runs like the below:
>>> Running /root/src/github.com/weaveworks/weave/test/150_connect_forget_2_test.sh on [138.68.153.213 138.68.149.186]
>>> Test /root/src/github.com/weaveworks/weave/test/150_connect_forget_2_test.sh finished after 12.4 secs with error: exit status 1
test #5 "direct_peers 138.68.149.186 | sort" failed:
  expected "138.68.153.213\n138.68.149.186"
  got "138.68.149.186\n138.68.153.213"
2017-01-05 15:02:16 +00:00
Bryan Boreham bf59a003bb Exec weaver from weave-kube launch rather than running in background
So we only have one process running inside the container after all
set-up is finished
2017-01-04 15:00:52 +00:00
Bryan Boreham 2298a40327 Fix bug which was killing all smoke-tests
- only fail if there is no secret password
2017-01-04 14:53:43 +00:00
Adam Harrison 61d22bb8b4 Merge pull request #2686 from weaveworks/issues/2580-allow-ips
Allow docker bridge to have more than one IP address
2017-01-04 14:35:48 +00:00
Adam Harrison eb3bbff883 Merge pull request #2708 from weaveworks/weave-kube-mounts
Mount /etc under a different path for weave-kube
2017-01-04 10:15:54 +00:00
Adam Harrison 03c1379d1b Merge pull request #2716 from liubog2008/fix
fix a bug of updating network policy
2017-01-03 17:44:58 +00:00
liubog2008 1635093341 fix a bug of updating network policy 2016-12-28 14:12:06 +08:00
Bryan Boreham 93dcc4550a Merge pull request #2712 from luxaslabs/deprecate_maintainer_dockerfile
Remove the deprecated MAINTAINER field in Dockerfiles and change to "LABEL maintainer" instead
2016-12-23 16:06:41 +00:00
Bryan Boreham ab55da47b6 Check if we have secrets before decrypting or running smoke tests
And enable running CircleCI on forked pull requests
2016-12-23 16:06:20 +00:00
Lucas Käldström 17971a5a3a Remove the deprecated MAINTAINER field in Dockerfiles for LABEL maintainer instead
Also add https://microbadger.com/labels labels and remove LABEL fields where they already are inherited
2016-12-23 14:57:02 +02:00
Bryan Boreham e0b90e8f02 Inline single-line function docker_bridge_ip 2016-12-23 12:15:04 +00:00
Bryan Boreham ea014d1362 Reimplement docker_bridge_ip shell pipeline in Go 2016-12-23 12:10:26 +00:00
Bryan Boreham 6ef302b8a1 Extract FindBridgeIP to net package 2016-12-23 11:57:04 +00:00
Bryan Boreham 1e7afe3bec Merge branch '1.8' 2016-12-23 11:35:53 +00:00
Bryan Boreham 48508044d6 Merge pull request #2703 from weaveworks/issues/2700-ip-link
Docs: improve IP route links
2016-12-23 11:26:52 +00:00
Bryan Boreham a4ad66f1c8 Mount /etc under a different path for weave-kube
So we don't accidentally read or write the hosts's /etc.
Also move the other volumes under /host to be more consistent with
what the weave script expects.
2016-12-22 10:35:47 +00:00
Bryan Boreham 0f85a959bb Merge branch '1.8' 2016-12-21 11:15:04 +00:00
Bryan Boreham d9a8adda1d Merge pull request #2706 from weaveworks/issues/2638-segfault-dp
Do not segfault if the datapath exists
2016-12-21 11:12:19 +00:00
Marc Carré ef4a8648a9 Merge pull request #2707 from weaveworks/2647-fix-typo-in-sanity-checks
Fixed typo in sanity check of weave's version
2016-12-21 10:28:09 +00:00
Marc CARRE 8bb72aa175 Fixed typo in sanity check of weave's version (previously checking locally, now checking test host). 2016-12-21 10:03:05 +00:00
Martynas Pumputis fa05dcf6ee Do not segfault if the datapath exists
If the datapath exists when creating it, dpif.CreateDatapath
will return an empty handle which access will cause the segfault.
2016-12-20 18:16:16 +02:00
Martynas Pumputis 8affa26858 Merge pull request #2695 from weaveworks/issues/2692-consistent-npc-log
Change rest of npc to weave common logging

Fixes #2692
2016-12-19 16:41:27 +02:00
Martynas Pumputis 856cb48170 Merge pull request #2685 from weaveworks/issues/2480-correct-mac
Take peerName from weave bridge if not specified

Fixes #2480
2016-12-19 16:35:15 +02:00
Bryan Boreham 1239fca567 Docs: improve IP route links 2016-12-19 12:34:05 +00:00
Bryan Boreham 6592a9afc7 Merge branch '1.8' 2016-12-14 11:57:11 +00:00
Mathias Methner 7ffd96f425 Document how to publish prometheus metric endpoint on all interfaces
This is a combination of 4 commits.
 The first commit's message is:
2677 docu, how to publish prometheus metric endpoint on all interfaces

 This is the 2nd commit message:
2677 change docu on how to publish metrics, be more careful with publishing on all interfaces

 This is the 3rd commit message:
2677 fix spelling

 This is the 4th commit message:
2677 fix wrong port title and grammar
2016-12-14 11:54:56 +00:00
Bryan Boreham 906d9a47b1 Merge pull request #2696 from weaveworks/2647-import-using-absolute-paths
Scripts now source dependencies using relative paths
2016-12-13 17:00:58 +00:00
Marc CARRE 0dff07dc8b Scripts now source dependencies using relative paths (previously breaking make depending on current directory). 2016-12-13 16:00:37 +00:00
Bryan Boreham 9261d17dbe Fix option name 2016-12-13 14:59:45 +00:00
Bryan Boreham 7d8a18bd20 Change rest of npc to weave common logging 2016-12-13 13:52:48 +00:00
Bryan Boreham 29cb13cba6 Merge branch '1.8' 2016-12-13 13:34:03 +00:00
Martynas Pumputis 52f375ac1e Merge pull request #2663 from weaveworks/issues/2389-report-mtu
Add MTU to connection status

Fixes #2389
2016-12-13 11:53:39 +00:00
Bryan Boreham 73f184df7e Fix quotes in anchors 2016-12-13 11:42:20 +00:00
Bryan Boreham bbd631f08f weave-kube no longer needs to supply the peer address 2016-12-09 15:34:31 +00:00
Bryan Boreham cf315fb6ba Take peerName from weave bridge if not specified 2016-12-09 15:34:31 +00:00
Bryan Boreham c03a2caac2 Allow docker0 to have >1 IP address
and log the one we end up using
2016-12-09 15:22:49 +00:00
Bryan Boreham 9c2bc0b825 Add MTU to connection status 2016-12-09 13:59:49 +00:00
Martynas Pumputis fcda8985fb Remove bin/setup-ci-secrets
It was used by Travis CI which we do not use anymore.
2016-12-08 16:22:12 +00:00
Martynas Pumputis 14082f9332 Merge branch '1.8' 2016-12-08 15:44:40 +00:00
Martynas Pumputis 83401eb245 Update release-process.md
git.io/weave-kube does not point to the weave-kube repo anymore.
2016-12-08 15:35:54 +00:00
Martynas Pumputis 022a98d4a4 Add release v1.8.2 2016-12-08 15:11:21 +00:00
Bryan Boreham bb1cca713d Merge branch '1.8' 2016-12-08 12:27:40 +00:00
Bryan Boreham 1d80a8d676 Merge pull request #2674 from weaveworks/issues/2650-fix-looping-flows
Detect looping flows
2016-12-08 12:27:15 +00:00
Martynas Pumputis aa9c032176 Add sanity check to detect when receiving own packets 2016-12-08 11:38:37 +00:00
Martynas Pumputis baa8f229f7 Detect enabling of hairpin mode on vethwe-bridge
Enabled hairpin mode on vethwe-bridge was one of the root causes
for installing looping flows in the fastdp mode.

Also, it confused the weave custom L2 bridge, as the bridge treats
a bounced back packet, e.g. ARP brodcast request, as a local one
(the case for "Captured a packet associated with remote host").
2016-12-08 11:37:52 +00:00
Martynas Pumputis ab1b99a4d9 Update vishvananda/netlink vendored dependency
The updated version includes parsing of IFLA_PROTINFO
which is needed to get info about hairpin mode when
subscribing to link updates.
2016-12-08 10:33:22 +00:00
Adam Harrison 11ff1880e5 Merge pull request #2666 from weaveworks/issues/2633-json-events
Log objects via JSON for better debugging
2016-12-07 17:25:55 +00:00
Bryan Boreham 71bf040715 Add --log-level option, default to debug 2016-12-07 11:53:40 +00:00
Bryan Boreham 6a04c6c7bd Change to weave common logging 2016-12-07 11:53:31 +00:00
Bryan Boreham 8530528dd5 Drop pod log messages to Debug level 2016-12-07 11:51:53 +00:00
Adam Harrison e1d8992ec5 Merge branch '1.8'
Fixes #2673.
2016-12-07 11:24:13 +00:00
Adam Harrison b03311e99d Merge pull request #2683 from weaveworks/issues/2673-expose-again
Re-add expose to ensure it gets run on all nodes
2016-12-07 11:23:52 +00:00
Adam Harrison 0c1138ee60 Merge pull request #2662 from weaveworks/issues/2594-setup-cni
Unify weave and launch.sh CNI setup
2016-12-07 11:21:25 +00:00
Bryan Boreham 8a45292e24 Log objects via JSON for better debugging 2016-12-06 17:40:17 +00:00
Bryan Boreham d1712e9589 Re-add expose to ensure it gets run on all nodes
Previous change in a07e3301b1 meant that if there are no pods on
this node then the 'expose' never gets run.
2016-12-06 14:58:31 +00:00
Bryan Boreham ec21afb426 Unify weave and launch.sh CNI setup
Test 830 has to run CNI plugin under sudo now
2016-12-06 11:52:09 +00:00
Bryan Boreham 882bff292e Fix test invocation of weave again
Previous fix in b4a43f1b85 did not work
when built with code coverage.

Running a test script with -v causes `weave_on` to output progress
messages, so we don't want to use those commands inside `$()`
2016-12-06 11:48:48 +00:00
Adam Harrison f3843a6b18 Merge branch '1.8' 2016-12-06 11:41:45 +00:00
Adam Harrison 597c6c111d Merge pull request #2657 from weaveworks/remove-bridge-on-error
Remove weave bridge if something goes wrong when creating it
2016-12-06 11:41:29 +00:00
Adam Harrison ac4957e15c Merge branch '1.8' 2016-12-06 11:30:32 +00:00
Adam Harrison f3915592b2 Merge pull request #2679 from weaveworks/expose-loop
Run iptables commands in a loop
2016-12-06 11:30:20 +00:00
Bryan Boreham 8a292fd9f3 Merge pull request #2678 from weaveworks/issues/2593-remove-cni-from-plugin
Remove CNI support from Docker plugin
2016-12-06 02:51:23 -08:00
Bryan Boreham f34936d9be Merge branch '1.8' 2016-12-06 10:39:50 +00:00
Bryan Boreham d4367457a9 Merge pull request #2671 from weaveworks/document-env-vars
Document env-var configuration for weave-kube
2016-12-06 02:39:20 -08:00
Bryan Boreham b4a43f1b85 Fix test running with -v flag
Running a test script with -v causes `weave_on` and `docker_on` to
output progress messages, so we don't want to use those commands
inside `$()`
2016-12-05 16:12:15 +00:00
Bryan Boreham 3674808244 Remove weave bridge and associated devices if something goes wrong when creating it
Otherwise it is left in a half-created state and the user has to run `weave reset` to continue.
2016-12-05 15:11:47 +00:00
Bryan Boreham 44cc978a94 Update CNI information 2016-12-05 14:29:07 +00:00
Bryan Boreham f441ec2644 Document env-var configuration for weave-kube
E.g. how to configure the IP allocation range
2016-12-05 13:55:33 +00:00
Martynas Pumputis 0ae13a2650 Detect hairpin flows
The introduced "isHairpinFlow" detects whether a flow has been
created due to enabled hairpin mode.
2016-12-05 12:42:24 +00:00
Bryan Boreham ee6596e21c Run iptables commands in a loop
in case they get  "temporarily unavailable" exit
2016-12-05 11:11:20 +00:00
Anita Buehrle a63147beda Improve wording of kube-addon page 2016-11-30 16:15:30 +00:00
Adam Harrison cdcf5808db Remove CNI support from Docker plugin 2016-11-30 10:43:50 +00:00
Bryan Boreham d501c78795 Merge pull request #2659 from weaveworks/issues/2581-optional-bridge-nf
Optional bridge-nf detection
2016-11-28 18:09:40 -08:00
Adam Harrison e61ddc59c4 Merge branch '1.8'
Fixes #2669.
2016-11-28 11:54:03 +00:00
Adam Harrison 46e4f047de Merge pull request #2672 from weaveworks/issues/2669-iprange-clash
Check whether Weave's IP range overlaps something on the host already
2016-11-28 11:53:50 +00:00
Adam Harrison 9cff5f2c5e Merge branch '1.8' 2016-11-25 17:23:39 +00:00
Adam Harrison 5f031453d3 Remove backticks which are tripping up the markdown renderer 2016-11-25 16:55:22 +00:00
Marc CARRE 028216021f Fixed formatting of documentation about logging of connection blocked by Weave NPC. 2016-11-25 16:00:05 +00:00
Bryan Boreham d6544302d3 Check whether Weave's IP range overlaps something on the host already 2016-11-25 14:43:23 +00:00
Adam Harrison bc529c5d09 Merge branch '1.8'
Fixes #2667.
2016-11-25 13:10:29 +00:00
Adam Harrison 354d1ddd5c Merge pull request #2670 from weaveworks/issues/2667-firewall-rules
Run GCE test VMs on a locked-down network
2016-11-25 13:09:54 +00:00
Adam Harrison 28bf4e6e95 Optional bridge-nf detection 2016-11-25 12:40:20 +00:00
Marc Carré 33b7faa17d Merge pull request #2668 from weaveworks/fix-doc-formatting
Fix documentation's formatting.
2016-11-25 12:28:26 +00:00
Marc CARRE ac731c0ff7 Fixed formatting of documentation about logging of connection blocked by Weave NPC. 2016-11-25 12:19:53 +00:00
Bryan Boreham fd34dda6c1 Run test instances on a locked-down network
and open up a rule from the specific IP running the tests
2016-11-24 17:17:12 +00:00
Bryan Boreham 16fca913de Merge branch '1.8' 2016-11-24 15:27:36 +00:00
Bryan Boreham f989a82eb0 Merge pull request #2573 from weaveworks/2546-clarify-npc-packet-drop-no-link
Clarified and documented Weave NPC packet drops (w/o short URL).
2016-11-24 15:26:49 +00:00
Marc CARRE d410ecd34c Document logging of connection blocked by Weave NPC. 2016-11-24 14:04:43 +00:00
Marc CARRE 48569265e2 Add logging of connection blocked by Weave NPC. 2016-11-24 14:02:22 +00:00
Bryan Boreham ad43acf843 Merge branch '1.8' 2016-11-24 10:53:59 +00:00
Bryan Boreham 71782a6aa5 Merge pull request #2661 from weaveworks/fix-700-again
Wait up to 30s for version check error in logs
2016-11-24 10:52:47 +00:00
Adam Harrison 6df24d1a40 Merge branch '1.8' 2016-11-23 12:37:14 +00:00
Adam Harrison e283b0a1ce Add release v1.8.1 2016-11-23 12:25:07 +00:00
Adam Harrison fa15193011 Wait up to 30s for version check error in logs 2016-11-23 10:53:42 +00:00
Bryan Boreham dff14c19f8 Don't remove base CNI plugins in test 2016-11-23 10:38:23 +00:00
Adam Harrison 6103595b9c Merge branch '1.8' 2016-11-23 10:36:53 +00:00
Adam Harrison 01c436ae15 Merge pull request #2642 from weaveworks/fix-launch-version
Fix weave-kube launch.sh version usage
2016-11-23 10:36:16 +00:00
Adam Harrison c3a2539445 Merge branch '1.8' 2016-11-22 16:17:30 +00:00
Adam Harrison 664ba8735f Merge pull request #2643 from weaveworks/issues/2632-cni-no-check-alive
Don't release CNI-allocated IP address when container dies
2016-11-22 16:17:11 +00:00
Bryan Boreham 937036aa64 Simplify default version string 2016-11-22 15:43:17 +00:00
Bryan Boreham 47cdf2b755 Simplify version sed 2016-11-22 15:42:53 +00:00
Adam Harrison ef270764f3 Merge branch '1.8'
Fixes #2632.
2016-11-22 15:28:03 +00:00
Adam Harrison a6edd40de3 Merge pull request #2658 from weaveworks/issues/2632-use-pod-status
Make NPC only look at IP addresses on running pods
2016-11-22 15:27:48 +00:00
Bryan Boreham 4219c2c2ab Only look at IP addresses on pods that haven't finished 2016-11-22 13:49:28 +00:00
Bryan Boreham 4785de1a34 Merge branch '1.8' 2016-11-22 09:59:27 +00:00
Bryan Boreham cbec624cd8 Remove CNI files when tearing down Kubernetes 2016-11-21 16:08:50 +00:00
Bryan Boreham e7bde18f71 Merge pull request #2656 from weaveworks/add-jq-to-vagrantfile
Include jq in the build VM
2016-11-21 11:53:03 +00:00
Bryan Boreham e9eeaee520 Warn user on unknown gce util command 2016-11-21 09:49:41 +00:00
Bryan Boreham d5ec9fb38d Fix test 700 to use resolver override
instead of /etc/hosts override that didn't work in netgo mode
2016-11-18 20:42:15 +00:00
Adam Harrison 233a776c41 Include jq in the build VM
Required to run the tests.
2016-11-18 17:59:13 +00:00
Bryan Boreham d5f1c233bf Remove punctuation from the end of error messages
to placate the linter
2016-11-18 10:40:41 +00:00
Bryan Boreham af732d0495 Merge pull request #2529 from weaveworks/use-golang-171
Build container FROM golang:1.7.3
2016-11-17 15:04:12 +00:00
Marc Carré 04a87f951b Merge pull request #2644 from weaveworks/issues/2567-tighter-iprange
Better value for --ipalloc-range in attach-router
2016-11-17 11:38:12 +00:00
Bryan Boreham 9cc98919fa Adjust CNI smoke-test to cope with new plugin behaviour 2016-11-14 19:53:54 +00:00
Bryan Boreham e42600632f Don't release dead container's IP addresses if not asked to check it is alive. 2016-11-14 19:53:54 +00:00
Bryan Boreham 93aa3fed16 Merge branch '1.8' 2016-11-14 19:47:05 +00:00
Bryan Boreham 49e76d1486 Merge pull request #2645 from weaveworks/fix-test-700
Replace iptables block with resolver override
2016-11-14 19:44:26 +00:00
Adam Harrison 965bed7c4f Replace iptables block with resolver override 2016-11-14 17:11:17 +00:00
Bryan Boreham 317c6ba04c Better value for --ipalloc-range in attach-router
The previous regex matched a blank --ipalloc-range and the following
parameter, which defeated the whole point of the check.
2016-11-14 16:11:42 +00:00
Adam Harrison 41d127934b Remove redundant GO15VENDOREXPERIMENT setting 2016-11-14 15:13:19 +00:00
Adam Harrison 915638d17a Address linter failures 2016-11-14 15:13:19 +00:00
Adam Harrison f73355abcc Incorporate Docker's malformed host fix 2016-11-14 15:13:19 +00:00
Adam Harrison 8f9da95e5e Restore golint 2016-11-14 15:13:19 +00:00
Adam Harrison 0935aa9221 Build container FROM golang:1.7.3 2016-11-14 15:13:19 +00:00
Adam Harrison aaa073afed Merge branch '1.8'
Fixes #2617 and fixes #2570.
2016-11-14 15:11:57 +00:00
Adam Harrison 9b606fb823 Merge pull request #2637 from weaveworks/issues/2617-cni-expose
Remove 'weave expose' race in CNI plugin
2016-11-14 15:11:38 +00:00
Bryan Boreham 15d91c558b Quote version string which may contain spaces, etc 2016-11-14 12:49:00 +00:00
Bryan Boreham ffc5a78139 Add code-coverage options to weaver version call 2016-11-14 12:42:17 +00:00
Bryan Boreham f8693074a3 Move CNI config file to the end of launch script
So something waiting for the config (e.g. Kubernetes) doesn't try to
talk to Weave before then (this only helps on first install, but that
tends to be when things are busiest).
2016-11-14 12:37:42 +00:00
Bryan Boreham 1629f4f3f0 Loop round iptables commands on EAGAIN 2016-11-14 12:37:42 +00:00
Bryan Boreham 10baab38d3 Extend smoke-test to include pinging 2016-11-14 12:37:42 +00:00
Bryan Boreham e458c11e66 Weave script calls Go implementation of expose_nat 2016-11-14 12:37:42 +00:00
Bryan Boreham a07e3301b1 Add 'weave expose' NAT iptables rules inside CNI plugin
This avoids a race between the plugin and the script
2016-11-14 12:37:42 +00:00
Bryan Boreham 2b4d13c5b1 Don't error on bridge address already there 2016-11-14 12:37:42 +00:00
Bryan Boreham 755e42836c Merge branch '1.8' 2016-11-14 11:29:34 +00:00
Bryan Boreham ad743b0e96 Merge pull request #2577 from weaveworks/2548-fix-reclaim-after-using-cni
Fix reclaim after using CNI; Fixes #2548.
2016-11-14 11:28:42 +00:00
Marc CARRE 0544901357 Factorise "_" duplicates as a constant. 2016-11-11 17:00:26 +00:00
Marc CARRE bc94633180 Re-claim IP on start-up when an existing ID has been found.
- Rewrote conditions to keep c.ident immutable and hopefully makes
things clearer.
- Added a case to tolerate reclaim after we have used CNI (passed CID
is “_” and existing CID is a real container ID).
2016-11-11 17:00:26 +00:00
Marc CARRE 16415404c7 Added automated test reproducing the issue.
test #4 "[
3e52b548e6df304c61ea5bee0af4b3515e025e7e25152c65ecae3d03c71cf52d ==
Unable to claim: address 10.32.0.3/12 is already owned by
fbe411facc8b657c5850591ab56fc40fb56160d43db0d7363a29ba3edad61134
Unable to claim: address 10.32.0.1/12 is already owned by
cf16a2bcdee8dd1ef7e5f0a611127611e67ea734f45d7526678fc3b1fc0c6f5d
3e52b548e6df304c61ea5bee0af4b3515e025e7e25152c65ecae3d03c71cf52d ]"
failed:
	program terminated with code 2 instead of 0
1 of 6 tests failed in 6.499s.
2016-11-11 17:00:26 +00:00
Adam Harrison 702d12d801 Merge branch '1.8'
Fixes #2537.
2016-11-11 16:14:52 +00:00
Adam Harrison 46eb01604c Merge pull request #2565 from weaveworks/2537-fix-status-on-version-check-failures
Improve 'status' to handle cases when the checkpoint API is not available
2016-11-11 16:14:24 +00:00
Adam Harrison af36682a7e Merge branch '1.8' 2016-11-11 11:27:25 +00:00
Bryan Boreham 03d9e3db69 weaveutil now depends on plugin code 2016-11-10 17:04:10 +00:00
Marc CARRE b03b3fccc7 Fixes 2537: status now prints 'failed to check latest version' when the checkpoint API is not available (+test). 2016-11-09 17:46:52 +00:00
Marc Carré 9414e2979d Merge pull request #2599 from weaveworks/replace-kubectl-create-with-apply
Updated doc: replaced kubectl create with kubectl apply.
2016-11-07 16:31:31 +00:00
Marc CARRE 865664425b Updated doc: replaced kubectl create with kubectl apply. 2016-11-07 16:18:40 +00:00
Adam Harrison b060cf30f4 Add release v1.8.0 2016-11-04 15:49:36 +00:00
Marc Carré 5352ed837a Merge pull request #2598 from weaveworks/cni-setup-remove-symlink
Clean up CNI symlinks from weave-kube
2016-11-04 15:28:44 +00:00
Adam Harrison d4d54a1ff5 Clean up CNI symlinks from weave-kube 2016-11-04 14:41:34 +00:00
Adam Harrison ea82a6715f Merge pull request #2569 from weaveworks/weave-kube-smoke-test
weave-kube smoke test
2016-11-04 12:58:20 +00:00
Martynas Pumputis d356e32bdf Merge pull request #2588 from weaveworks/kube-npc-docs
Document k8s addon & prometheus metrics
2016-11-04 12:50:41 +00:00
Martynas Pumputis 6193d22d2e Merge pull request #2595 from weaveworks/change-npc-metrics-port
Change default NPC metrics port
2016-11-04 12:41:25 +00:00
Adam Harrison 50c9568073 Document Prometheus metrics endpoints 2016-11-04 12:33:06 +00:00
Adam Harrison 9d05ed41b2 Change default NPC metrics port 2016-11-04 12:31:01 +00:00
Adam Harrison e3f7e0a23a Merge pull request #2590 from weaveworks/issues/2586-/opt/cni/bin-never-upgraded
Add support for atomic and versioned upgrades of CNI plugin.
2016-11-04 12:27:48 +00:00
Marc CARRE da2f0803ce Add support for atomic and versioned upgrades of CNI plugin. 2016-11-04 11:54:22 +00:00
Bryan Boreham 6dde5e5ee9 Add code-coverage options to weaver start 2016-11-04 10:52:36 +00:00
Bryan Boreham 494df21bdf Disable imagePullPolicy so we test the image we just built 2016-11-04 10:52:36 +00:00
Bryan Boreham e44bbbec63 Add smoke-test for weave-kube 2016-11-04 10:52:36 +00:00
Bryan Boreham c19f49a284 Install Kubernetes packages and pre-pull images
Bump template version too
Note that we disable kubelet in the image, so you have to start it if
you want to use it.
2016-11-04 10:52:36 +00:00
Adam Harrison d3f2c110e4 Merge pull request #2589 from weaveworks/issues/2587-cni-weaveutil
Fix CNI plugin calling weaveutil
2016-11-04 10:47:38 +00:00
Bryan Boreham 09628178e4 Weave-kube doesn't need to depend on plugin repo any more 2016-11-03 17:42:39 +00:00
Bryan Boreham 5630a01a8c Implement CNI plugin via weaveutil 2016-11-03 17:42:39 +00:00
Adam Harrison 40b3a49c90 Merge pull request #2563 from weaveworks/update-test-template
Update CI VMs to Ubuntu 16.04 and Docker 1.11
2016-11-03 17:35:21 +00:00
Adam Harrison 431b87b94a Merge pull request #2591 from weaveworks/reset-npc
Have 'weave reset' remove NPC rules
2016-11-03 15:22:46 +00:00
Adam Harrison 828c3d21d2 Recommend using the k8s addon from the CNI docs 2016-11-03 15:13:50 +00:00
Adam Harrison f0e75481d5 Add network policy to features 2016-11-03 15:13:50 +00:00
Adam Harrison 8bb7e1cf24 Document Kubernetes Addon 2016-11-03 15:13:50 +00:00
Bryan Boreham e117a6bd04 Have 'weave reset' remove NPC rules 2016-11-03 14:24:26 +00:00
Adam Harrison ac44fa63c8 Fix breakage caused by #2574 2016-11-03 11:52:58 +00:00
Martynas Pumputis bb639dbf32 Merge pull request #2585 from weaveworks/merge-weave-npc
Merge weave npc
2016-11-02 11:58:43 +00:00
Bryan Boreham 64c890005a Merge pull request #2583 from damoon/fixup-74b477ac82e1ae267cf8501519f52e1f71a782dc
weaveworks/weave-kube:latest broken - fixup! allow to not run NPC: do not create iptables rules for NPC
2016-11-02 11:58:02 +00:00
Adam Harrison 19088ba8bc Import from weave-npc repo 2016-11-02 11:28:59 +00:00
Martynas Pumputis ec5f7033a4 Merge pull request #2579 from weaveworks/issues/2557-improve-metric-naming
Improve metric naming
2016-11-02 11:02:23 +00:00
Bryan Boreham eb60f68df2 Report metrics on all connection states 2016-11-02 09:51:13 +00:00
David Sauer d72e671d8b fixup! allow to not run NPC: do not create iptables rules for NPC 2016-11-02 10:10:33 +01:00
Martynas Pumputis 3462357481 Merge pull request #2578 from weaveworks/issues/2576-metrics-on
Serve metrics by default, on port 6782
2016-11-02 09:08:13 +00:00
Bryan Boreham 2b4da35b1c Remove 'total' DNS entries; let the caller add them up 2016-11-01 18:03:35 +00:00
Bryan Boreham 86d68c9875 Move total IPs in range from a state to a separate metric 2016-11-01 18:03:35 +00:00
Bryan Boreham cfff8ee8be Merge pull request #2568 from weaveworks/rename-conn-term-prom-metric
Rename weave_connection_termination_count metric
2016-11-01 18:02:55 +00:00
Bryan Boreham af10cef5f0 Set --status-addr for metrics by default 2016-11-01 17:04:04 +00:00
Bryan Boreham a1a42736ed Fix hard-coded http address 2016-11-01 16:53:37 +00:00
Adam Harrison b533a11bee Update client-go
weave-npc needs some fixes from client-go master (specifically the
unversioned.LabelSelector change)
2016-11-01 16:19:43 +00:00
Bryan Boreham afed9e9646 Merge pull request #2574 from pondohva/fix_weave_static_pod
allow to not run NPC: do not create iptables rules for NPC
2016-11-01 15:35:49 +00:00
Artur Gadelshin 74b477ac82 allow to not run NPC: do not create iptables rules for NPC 2016-11-01 17:32:41 +03:00
Bryan Boreham bf74c8f108 Add dependency of weave-kube on launch.sh 2016-11-01 10:46:25 +00:00
Bryan Boreham 04c7f5283e Reconfigure and restart docker for systemctl 2016-10-31 17:33:33 +00:00
Bryan Boreham d1d53ba45c Pre-install more stuff in the image.
Install bc and jq in the image rather than on every build.
Also pre-pull some Docker images
2016-10-31 17:33:33 +00:00
Bryan Boreham dfadb8f189 Upgrade to Ubuntu 16.04 and Docker 1.11
Using Docker 1.11 since there isn't a Docker-supplied package for 1.10 on Xenial
2016-10-31 17:33:33 +00:00
Bryan Boreham 5335c133a3 Update deprecated gcloud syntax 2016-10-31 17:33:33 +00:00
Adam Harrison 8fcb5daedf Merge pull request #2551 from weaveworks/weave-kube
Merge weave-kube into the Weave Net repo
2016-10-31 17:12:03 +00:00
Martynas Pumputis ede70a78d6 Rename weave_connection_termination_count metric
To make it follow the Prometheus naming conventions:
https://prometheus.io/docs/practices/naming/
2016-10-31 13:23:12 +00:00
Bryan Boreham 23056cbb45 Temporarily release weave-daemonset.yaml to weave-kube repo 2016-10-31 10:59:15 +00:00
Bryan Boreham 29e9e70ac9 Add weave-kube to release script 2016-10-31 10:59:15 +00:00
Bryan Boreham d0b711513e Add weave-daemonset.yaml 2016-10-31 10:59:15 +00:00
Bryan Boreham 7dbee74e85 Add weave-kube image 2016-10-31 10:59:15 +00:00
Bryan Boreham 4e7a3b1805 Add kube-peers program 2016-10-31 10:59:15 +00:00
Bryan Boreham 3c7b244f18 Change image layering - plugin builds on weaver & weaver builds on weaveexec 2016-10-31 10:59:13 +00:00
Bryan Boreham e50f5c52c5 Make templating of Dockerfiles more generic 2016-10-31 10:56:18 +00:00
Bryan Boreham baf91658d6 Fix static linking flags 2016-10-28 14:51:26 +01:00
Adam Harrison fda035d8d6 Merge branch '1.7' 2016-10-28 14:29:26 +01:00
Adam Harrison a4a53e1a11 Fix broken link 2016-10-28 14:08:54 +01:00
Martynas Pumputis aad3e52d72 Merge pull request #2564 from weaveworks/improved-dh-org-override-fix
Improve Dockerfile template substitution
2016-10-28 10:24:28 +01:00
Adam Harrison cb778a9af5 Improve Dockerfile template substitution 2016-10-27 11:43:41 +01:00
Marc CARRE 3af9732c84 Merge branch '1.7' 2016-10-26 16:49:58 +01:00
Marc Carré 00e754ed9f Merge pull request #2562 from weaveworks/build-test-runner-with-vendoring
Use vendoring when building test runner & Vagrantfile improvements
2016-10-26 16:44:15 +01:00
Marc CARRE d893f44833 Vagrantfile now copies SSH key required to run smoke tests from host to guest. 2016-10-26 16:09:09 +01:00
Marc CARRE 4839f41809 Improve resolution of Dockerfile since used in both Vagrantfile and test/Vagrantfile. 2016-10-26 16:09:09 +01:00
Marc CARRE c801409c94 Set VM's memory to 2048 MB by default. 2016-10-26 16:09:09 +01:00
Marc CARRE 1c4a01d52c Read Go version from Dockerfile in order to keep things 'DRY'. 2016-10-26 16:09:09 +01:00
Adam Harrison 880b0a883a Use vendoring when building test runner 2016-10-26 16:09:09 +01:00
Adam Harrison 4b77662e3b Merge pull request #2561 from weaveworks/issues/2560-fix-dns-ipam-metrics
Do not expose IPAM or DNS metrics if weave does not run IPAM or DNS
2016-10-26 14:24:43 +01:00
Adam Harrison a5ff7ab8df Merge pull request #2475 from weaveworks/issues/2419-withnetns
Add a safer version of WithNetNS*
2016-10-26 13:50:34 +01:00
Adam Harrison 04a6e6d13b Merge branch '1.7' 2016-10-26 13:47:05 +01:00
Martynas Pumputis 5c2e878c64 Do not expose IPAM or DNS metrics when weave does not run IPAM or DNS
Otherwise, GET /metrics will crash weaver.
2016-10-25 16:54:35 +01:00
Adam Harrison f9bada5af8 Merge pull request #2558 from weaveworks/fix-broken-url-in-doc
Fixed broken link to plugin.md to weave-docker-api.md.
2016-10-24 16:57:07 +01:00
Marc CARRE 80d66f8f68 Fixed broken link to plugin.md to weave-docker-api.md. 2016-10-24 16:37:55 +01:00
Martynas Pumputis 98b35b87a9 Fix weave_connection_termination_count
Do not count terminations caused by connect-to-ourselves.
2016-10-24 11:37:15 +01:00
Martynas Pumputis b1d6605e8f Remove inaccurate Prometheus metrics
The metrics include:
- weave_packets_total
- weave_bytes_total

The problem with those metrics is that fastdp periodically flushes
flows including their stats thus makes the current implementation
of the metrics unreliable.
2016-10-24 11:23:10 +01:00
Martynas Pumputis 2cd3bde348 Merge pull request #2555 from weaveworks/forget-immediately
Recompute targets immediately after 'weave forget'
2016-10-24 10:52:14 +01:00
Bryan Boreham f2454775b9 Merge pull request #2552 from weaveworks/issues/2550-fix-make-dockerhub-user
Ensure Dockerfiles obey DOCKERHUB_USER
2016-10-24 09:59:38 +01:00
Bryan Boreham a53d1e00ee Recompute targets immediately after 'weave forget' 2016-10-21 18:02:25 +01:00
Martynas Pumputis 523a964ac8 Merge pull request #2547 from weaveworks/prometheus-metrics
Prometheus metrics
2016-10-21 14:57:42 +01:00
Adam Harrison f8cf7a1054 Ensure Dockerfiles obey DOCKERHUB_USER 2016-10-21 14:45:10 +01:00
Bryan Boreham 4d8a40c0b5 Reduce metrics mechanism to just support fastdp 2016-10-21 14:44:12 +01:00
Martynas Pumputis 9754da15d6 Encode "list-netdevs" output in JSON 2016-10-20 18:18:57 +01:00
Bryan Boreham 0458d32089 Serve metrics on a different socket to the main API
Serve metrics+status on status socket and api+status+metrics on api
socket; the reasoning is that metrics or status are read-only hence
may be scraped from an off-machine connection, while we don't want to
open the control port up unprotected.
2016-10-20 16:25:16 +01:00
Bryan Boreham ee4e8eb994 Pull in updated mesh lib 2016-10-20 16:25:16 +01:00
Bryan Boreham b8d619dde7 Add Prometheus http handler for metrics
Metrics are: connection counts, active IP addresses, DNS addresses,
FastDP flow metrics, connection termination count
2016-10-20 16:25:16 +01:00
Bryan Boreham 00c86fed42 Expose overlay metrics from fastdp
and allow them to pass through OverlaySwitch
2016-10-20 16:25:16 +01:00
Bryan Boreham 6d5af85eee Report count of active IP addresses in status 2016-10-20 14:04:41 +01:00
Bryan Boreham 1ae2d33714 Remove old-style 'expvar' metrics 2016-10-20 13:54:42 +01:00
Bryan Boreham 71d550260f Extract countDNSEntries function 2016-10-20 13:54:42 +01:00
Bryan Boreham 1092bae05c Refactor: move 'unreachable' logic out of printing function 2016-10-20 13:54:42 +01:00
Martynas Pumputis e611f04f41 Move NetDev utils from common/ to net/ 2016-10-19 17:03:30 +01:00
Martynas Pumputis 3492cd93d0 Use safe version of WithNetNS 2016-10-19 16:15:59 +01:00
Martynas Pumputis 947ae11fee Refactor NetDev utilities
- Make them safe by using the safe version of WithNetNS.
- Improve naming.
2016-10-19 16:07:53 +01:00
Martynas Pumputis cdd6ed548c Add netdev subcommands to weaveutil
The subcommands are going to be used with WithNetNS wrapper.
2016-10-19 16:07:53 +01:00
Martynas Pumputis fc940d0017 Merge pull request #2549 from weaveworks/log-drops-via-nflog
Log dropped policy controller traffic via NFLOG
2016-10-19 11:02:28 +01:00
Bryan Boreham b38a55ca7c Include more context in error messages from CNI operations 2016-10-18 17:45:09 +01:00
Adam Harrison 8e739d5240 Log dropped policy controller traffic via NFLOG
Send blocked NEW connection attempts to NFLOG group 86 for accounting by
the weave-npc process.
2016-10-14 15:59:15 +01:00
Adam Harrison 71f8bb7e9a Merge branch '1.7' 2016-10-11 17:02:00 +01:00
Adam Harrison ebfaf11f4a Add release v1.7.2 2016-10-11 11:07:18 +01:00
Matthias Radestock 4a6cec3ecc Merge branch '1.7' 2016-10-07 12:47:04 +01:00
Matthias Radestock 1abce148a3 Merge pull request #2543 from weaveworks/issues/2527-remote-addr
Update Weave Mesh to bring in two fixes

Fixes #2481 via weaveworks/mesh#57
Fixes #2527 via weaveworks/mesh#60
2016-10-07 12:45:51 +01:00
Adam Harrison e0cc7f17b2 Merge branch '1.7'
Fixes #2540
2016-10-07 12:24:11 +01:00
Adam Harrison 264e5c9979 Merge pull request #2541 from weaveworks/issues/2540-withnetns
Change namespace via nsenter, for plugin arp-config step
2016-10-07 12:20:47 +01:00
Bryan Boreham a6a1ce5c9e Update Weave Mesh to bring in fix of panic 2016-10-07 12:13:49 +01:00
Bryan Boreham 6ac7ab162f Merge branch '1.7' 2016-10-06 16:42:07 +01:00
Bryan Boreham 5e660311d2 Merge pull request #2538 from weaveworks/2506-uts-release-bytes
inline (u)int8 array to string conversion
2016-10-06 16:41:26 +01:00
Martynas Pumputis 4a49ff3083 Replace usage of WithNetNSUnsafe in plugin/net/watcher.go with safer version
Unsafe version was in ConfigureARPforVeths; replacement is via `weaveutil configure-arp`
2016-10-06 15:25:05 +01:00
Martynas Pumputis 7f92c8c4c6 Add a safer version of WithNetNS*
The introduced functions are executing the work function via
a process which executes "nsenter --net=path weaveutil ...".
2016-10-06 15:25:05 +01:00
Matthias Radestock 85ac8177ad inline (u)int8 array to string conversion
so that the code compiles regardless of the uts.Release array type,
which varies across platforms.

Fixes #2506
2016-10-06 08:57:12 +01:00
Adam Harrison 03bd1fb91d Merge branch '1.7' 2016-10-05 16:49:33 +01:00
Adam Harrison eb5b16614c Add release v1.7.1 2016-10-05 15:23:25 +01:00
Adam Harrison a5873a3970 Merge branch '1.7' 2016-10-05 15:18:26 +01:00
Adam Harrison e48ca80dee Disable golint as it no longer builds with 1.5.x 2016-10-05 15:16:23 +01:00
Bryan Boreham e7c9e22350 Merge pull request #2274 from weaveworks/issues/2273-improve-doc-ci
Improve doc CI
2016-10-03 15:34:39 +01:00
Adam Harrison b8e7d83f19 Rename SKIP_TESTS 2016-10-03 14:07:57 +01:00
Adam Harrison 4c304c0013 Extract install-wordepress 2016-10-03 14:01:15 +01:00
Adam Harrison 7249350757 Merge pull request #2531 from weaveworks/process-addrs
Add weaveutil process-addrs
2016-09-30 10:28:59 +01:00
Bryan Boreham 50a8dc1383 Add weaveutil process-addrs
Fetches addresses for every veth that is in a network namespace and
attached to the specified bridge.  Works by iterating over every process.
2016-09-29 14:16:05 +01:00
Bryan Boreham 71491138aa Extract function to return all current process ids
This implementation should be more efficient because it only uses the
names under /proc, whereas the previous implementation fetched the
full directory entry for each one, and sorted them too.
2016-09-29 14:12:02 +01:00
Bryan Boreham ca87f8ada3 Improve comments 2016-09-29 14:06:43 +01:00
Adam Harrison 835b3f3d67 Improve script names 2016-09-29 13:01:18 +01:00
Adam Harrison 263dffeedc Extract shared function 2016-09-29 11:45:28 +01:00
Adam Harrison e1063944f6 Comment on GitHub PR with site changes 2016-09-29 11:45:28 +01:00
Adam Harrison 2380018457 Skip tests if PR contains only site changes 2016-09-29 11:45:28 +01:00
Adam Harrison a9db631836 Add toggle for skipping tests 2016-09-29 11:35:01 +01:00
Adam Harrison b45f138ff1 Propagate state between scripts 2016-09-29 11:25:34 +01:00
Adam Harrison b239694d34 Move circle commands into shell scripts 2016-09-29 11:25:34 +01:00
Adam Harrison 0c2774f367 Add release v1.7.0 2016-09-27 14:46:35 +01:00
Bryan Boreham ea4647bc74 Merge pull request #2524 from weaveworks/expect-npc
Implement `--expect-npc` flag to `create-bridge`
2016-09-27 13:41:22 +01:00
Adam Harrison 6ec21d3a58 Implement --expect-npc flag to create-bridge
Add a private flag for weave-kube to steer overlay traffic via the
network policy engine chain.
2016-09-27 09:23:19 +01:00
Adam Harrison 44a4a56024 Merge branch '1.6' 2016-09-21 17:14:07 +01:00
Adam Harrison 0aac614c08 Add release v1.6.2 2016-09-21 16:18:03 +01:00
Adam Harrison 2ea027d3a8 Merge branch '1.6' 2016-09-21 11:15:49 +01:00
Adam Harrison cd4cbed5a0 Merge pull request #2501 from weaveworks/issues/2495-filter-empty-peers
Reject empty peers
2016-09-21 11:12:10 +01:00
Adam Harrison 69b688b357 Merge pull request #2509 from weaveworks/issues/2503-persist-peers-fix
Create restart.sentinel after storing the peer list
2016-09-21 10:09:05 +01:00
Adam Harrison 7a81bc2ddc Merge pull request #2510 from weaveworks/issues/2329-fix-830-flakiness
Enable unsolicited ARPs in 830 test suite
2016-09-20 17:17:19 +01:00
Martynas Pumputis cdeae04238 Create restart.sentinel after storing peer list
Otherwise, we risk to lose peer list when any failure happens after
the creation but before storing the list and as a consequence,
the weave container gets restarted.
2016-09-20 17:07:48 +01:00
Martynas Pumputis 6df2782d73 Update weaveworks/mesh submodule 2016-09-20 17:03:38 +01:00
Adam Harrison 3fc7efa536 Merge pull request #2498 from weaveworks/broken-link
fixed broken link to command line args
2016-09-20 16:40:06 +01:00
Adam Harrison a556deec78 Merge branch '1.6' 2016-09-20 16:26:48 +01:00
Adam Harrison 71e43c2023 Merge pull request #2511 from weaveworks/issues/2340-make-640-less-flaky
Filter out netns of non-existing containers
2016-09-20 15:52:54 +01:00
Bryan Boreham 370f258c3a Fix outdated option ipam-seed 2016-09-16 15:53:43 -07:00
Martynas Pumputis 9b32bc2ab3 Close opened netns 2016-09-14 16:47:40 +01:00
Martynas Pumputis fd5e1970e1 Return nil netdev if netns of container cannot be found
The change applies to GetNetDevsWithPredicate. The function calls
FindNetDevs which already does the same filtering.

The change prevents from "container-addrs" (weaveutil) returning
"unable to open X process namespace" error which happens when
a container dies while the cmd is being executed.
2016-09-14 16:47:16 +01:00
Martynas Pumputis a1de7f3eef Enable unsolicited ARPs in 830 test case
Otherwise, ping (c1->c3) after the address reuse might time out.
2016-09-14 11:05:00 +01:00
Matthias Radestock 06a63db4cf Merge branch '1.6' 2016-09-08 12:55:05 +01:00
Matthias Radestock c720ebec02 Merge pull request #2502 from weaveworks/issues/2469-supply-subnet
Pass in default subnet when creating 'weave' plugin network.

Fixes #2469.
2016-09-08 12:49:01 +01:00
Matthias Radestock 6a528409ab Merge pull request #2504 from weaveworks/check-tx-off
Check current tx value before trying to set it
2016-09-08 12:32:15 +01:00
Bryan Boreham c69e140e9e Check current tx value before trying to set it 2016-09-08 10:20:35 +01:00
Anita Buehrle 8ed0c13645 removed broken link 2016-09-06 14:36:25 +01:00
Anita Buehrle b635f9a994 fixed broken link to command line args 2016-09-06 14:36:25 +01:00
Bryan Boreham ac4246e1f5 Pass in default subnet when creating 'weave' plugin network.
New behaviour in Docker 1.12 means it disregards a plugin-supplied
address pool that overlaps an existing route, which causes a hang as
noted in #2469. When we pass in the subnet, Docker believes we really
do want that address range and avoids the hang.
2016-09-06 12:05:51 +01:00
Martynas Pumputis 06a325a05f Use weaveworks/docker/pkg/mflag everywhere 2016-09-05 17:22:28 +03:00
Martynas Pumputis 68e9bbe350 Add github.com/weaveworks/docker submodule 2016-09-05 16:16:06 +03:00
Matthias Radestock 3bd9e369cd Merge branch '1.6' 2016-09-05 12:51:30 +01:00
Matthias Radestock 3d12e8088e Merge pull request #2491 from weaveworks/switch-ci-14.04
Switch CircleCI build VM to 14.04
2016-09-05 12:49:25 +01:00
Martynas Pumputis aee35b34fe Pin joffrey/docker-py image to 1.8.1 vsn
The latest image requires 1.12.x dockerd.
2016-09-05 14:30:49 +03:00
Martynas Pumputis c06ccb3b0d Change owner of /usr/local/go on build VM
Otherwise "go get -tags netgo" fails with the permission denied error.
2016-09-05 14:30:49 +03:00
Martynas Pumputis 268bb656fc Do not fetch Google Cloud SDK
As it is already installed on CircleCI 14.04 build VMs
2016-09-05 14:30:49 +03:00
Martynas Pumputis 57357a728c Merge branch '1.6' 2016-09-05 13:48:30 +03:00
Martynas Pumputis a335c419ec Fix typo 2016-09-05 13:27:49 +03:00
Martynas Pumputis e263295720 Revert "Do not fetch Google Cloud SDK"
This reverts commit f557835ad0.
2016-08-26 14:42:50 +01:00
Martynas Pumputis 0c854f2144 Merge pull request #2489 from weaveworks/fix-mflag-missing
Use mflag package from weaveworks fork until we find a better solution
2016-08-26 12:19:59 +01:00
Alfonso Acosta bdf4debdfd Use mflag package from weaveworks fork until we find a better solution 2016-08-26 11:07:21 +00:00
Martynas Pumputis f557835ad0 Do not fetch Google Cloud SDK
As it is already installed on CircleCI 14.04 build VMs
2016-08-26 11:38:37 +01:00
Martynas Pumputis 17a7391086 Remove unused functions 2016-08-26 10:15:27 +01:00
Martynas Pumputis e65293eb50 Merge branch '1.6' 2016-08-19 14:12:26 +01:00
Martynas Pumputis 48c9547943 Update CHANGELOG.md 2016-08-19 14:11:57 +01:00
Martynas Pumputis caa6c6c931 Merge branch '1.6' 2016-08-19 11:22:07 +01:00
Martynas Pumputis 11f56031f1 Add release v1.6.1 2016-08-18 17:39:46 +01:00
Adam Harrison 2e825242cd Merge branch '1.6' 2016-08-18 11:32:43 +01:00
Adam Harrison ebe4c5b8b7 Merge pull request #2478 from weaveworks/bridge-veth-setup
Refactor: move bridge veth creation into 'init_bridge'
2016-08-18 11:31:16 +01:00
Adam Harrison 027064cbdb Merge branch '1.6' 2016-08-18 10:56:03 +01:00
Adam Harrison 9fddb827f9 Merge pull request #2442 from weaveworks/cni-setup-fixes
CNI setup fixes
2016-08-18 10:55:46 +01:00
Bryan Boreham 3162009325 Refactor: move bridge veth creation into 'init_bridge' 2016-08-17 17:33:34 +01:00
Martynas Pumputis 060f6392c7 Merge branch '1.6' 2016-08-16 18:03:00 +01:00
Martynas Pumputis 8c8c6db7dd Increase sleep time in 830_cni_plugin_test
Fix #2329
2016-08-16 18:00:46 +01:00
Matthias Radestock cd94dd0088 setup CNI on weave launch[-router]
not just `setup[-cni]`

Fixes #2435
2016-08-16 14:18:55 +01:00
Matthias Radestock afc6f49e80 mount CNI_NETNS dir, in case it is some exotic location
Fixes #2394
2016-08-16 14:18:28 +01:00
Martynas Pumputis c509b6e5bb Revert "Derive the bridge MAC from concatenated multiple sources"
This reverts commit c2083cbce0.
2016-08-15 09:48:55 +01:00
Bryan Boreham a466f55d59 Merge pull request #2462 from weaveworks/note-proxy-file
added note about net flag
2016-08-12 16:55:57 +01:00
Bryan Boreham c79b6a8bd7 Merge pull request #2460 from weaveworks/issues/2427-detect-peerid-clashes
Detect and report peer name collisions
2016-08-12 16:52:56 +01:00
Martynas Pumputis c2083cbce0 Derive the bridge MAC from concatenated multiple sources
The sources include:

- /etc/machine-id (generated by "systemd-machine-id-setup") or
  /var/lib/dbus/machine-id (generated by "dbus-uuidgen").
- /sys/class/dmi/id/product_uuid.
- /sys/hypervisor/uuid.

The product of the concatenation should produce an unique identifier
which is stable across reboots.
2016-08-11 12:01:35 +01:00
Martynas Pumputis 4157d9298d Update vendored weaveworks/mesh 2016-08-11 12:01:20 +01:00
Adam Harrison f686408808 Merge branch '1.6' 2016-08-10 14:44:25 +01:00
Adam Harrison 432e10e19f Merge pull request #2474 from weaveworks/issues/2375-check-vxlan-udp-port
Check if a vxlan vport netdev is UP after its creation
2016-08-10 14:44:11 +01:00
Adam Harrison b8c57ef10f Merge branch '1.6' 2016-08-10 13:58:53 +01:00
Adam Harrison 601bda3176 Merge pull request #2457 from weaveworks/issues/2424-weaken-tls-check
Do not fail launching the proxy if unable to detect a running instance of docker daemon
2016-08-10 13:58:42 +01:00
Martynas Pumputis d9bde790c6 Check if a vxlan vport netdev is up after its creation
This bypasses a kernel bug when the creation of vxlan vport
completes successfully regardless whether an vxlan UDP port has been
bind (http://marc.info/?l=linux-netdev&m=147075637009483&w=2).
2016-08-10 13:34:44 +01:00
Adam Harrison 5cc0826ca0 Merge branch '1.6' 2016-08-10 13:16:24 +01:00
Adam Harrison 96f2eb3ecf Merge pull request #2471 from weaveworks/cni-bridge-ip
CNI plugin assigns an IP to the bridge by itself
2016-08-10 11:49:25 +01:00
Adam Harrison e703f2f3f2 Merge branch '1.6' 2016-08-10 11:48:31 +01:00
Adam Harrison 1c0ffbc177 Stop publishing historic versions 2016-08-10 11:12:23 +01:00
Adam Harrison f544da9e19 Merge branch '1.6' 2016-08-10 10:18:01 +01:00
Adam Harrison c0592ba1b3 Merge pull request #2470 from weaveworks/no-force-tag
Remove -f flag from 'docker tag' commands
2016-08-10 10:17:06 +01:00
Bryan Boreham 0cbf5ca130 Allow 'weave create-bridge', if the user insists.
For example this is used when setting up CNI for Kubernetes, in
an environment where we know none of the bad consequences apply.
2016-08-10 10:00:17 +01:00
Adam Harrison 472eab2acd Merge pull request #2466 from weaveworks/issues/2464-enable-create-bridge
Re-enable 'weave create-bridge' in fastdp mode.
2016-08-10 09:57:40 +01:00
Bryan Boreham 7a5d7fca6c Allow 'weave create-bridge', if the user insists.
For example this is used when setting up CNI for Kubernetes, in
an environment where we know none of the bad consequences apply.
2016-08-08 17:20:25 +01:00
Bryan Boreham 081b95dfd0 CNI plugin assigns an IP to the bridge by itself
No need to call `weave expose` before use.
2016-08-08 15:28:26 +01:00
Matthias Radestock faf5b14d8b make CNI setup work on recent Docker-for-Macs
Docker for Mac 1.12.0-rc3 (as of beta18) looks for mounted paths on VM
first, and when it doesn't find them there, it assumes they refer to
paths on the Mac OS host. At which point it will complain that the
paths don't exit.

So instead we mount / since that will always exist on the VM. It's
also what we used to do already when launching the router.

Fixes #2434.
2016-08-04 22:03:39 +01:00
Bryan Boreham 38958049f4 Remove -f flag from 'docker tag' commands
This flag was deprecated in Docker 1.10 and removed in Docker 1.12.
2016-08-04 17:03:35 +01:00
Bryan Boreham 589b45dace Merge branch '1.6' 2016-08-03 14:34:49 +01:00
Bryan Boreham 7ebf3d7a88 Don't crash when dockerCli is nil 2016-08-03 14:28:05 +01:00
Anita Buehrle 3273d13666 gave points numbers for clarity 2016-08-02 16:40:16 -05:00
abuehrle 5fdbbf3722 wording formatting 2016-08-02 16:38:41 -05:00
abuehrle 14350ff463 added anchor to attaching containers 2016-08-02 16:35:52 -05:00
abuehrle 0b49c961a7 reconfigured note to include additional method 2016-08-02 16:30:32 -05:00
abuehrle 39b80f26ed made terminology consistent 2016-08-02 13:15:17 -05:00
abuehrle 74b20265e4 fixed links and some titles 2016-08-02 12:59:27 -05:00
abuehrle 358fddb958 fixed broken link and title 2016-08-02 12:52:36 -05:00
abuehrle 5c8f6175b5 added note about net flag 2016-08-02 12:34:52 -05:00
Martynas Pumputis e8d823d66b Do not fail launching the proxy if unable to detect dockerd 2016-07-28 12:53:44 +01:00
Adam Harrison 83ce5875ee Merge branch '1.6' 2016-07-28 12:52:53 +01:00
Adam Harrison ed83efbceb Merge pull request #2450 from weaveworks/eval-considered-harmless
remove dire warnings about 'eval' when using plugin
2016-07-28 12:49:55 +01:00
Adam Harrison 223116c4bf Merge pull request #2393 from weaveworks/intro-ops-guide
intro to ops guide (#2387)
2016-07-28 12:32:34 +01:00
Matthias Radestock 8056a098a8 remove dire warnings about 'eval' when using plugin
since as of #2330 the proxy ignores containers started with specified
user networks.
2016-07-28 11:49:54 +01:00
abuehrle 15a2cba7f8 added anchors to concepts 2016-07-28 11:49:06 +01:00
Anita Buehrle b37bb02a8b intro to ops guide (#2387) 2016-07-28 11:49:06 +01:00
Adam Harrison 0c14e5135a Delint (spelling error) 2016-07-28 11:48:14 +01:00
Adam Harrison f5a30c790e Merge branch '1.6' 2016-07-28 11:30:47 +01:00
Adam Harrison b06ddeb962 Merge pull request #2445 from weaveworks/fix-weave-ps
Fix "weave ps" output when weave is not running
2016-07-28 11:30:31 +01:00
Martynas Pumputis 34415c3c17 Merge pull request #2422 from weaveworks/log-resolvconf-errors
Log errors arising from reading resolv.conf
2016-07-26 18:01:33 +01:00
Matthias Radestock 6387fa8bc9 Merge branch '1.6' 2016-07-20 07:30:56 +01:00
Matthias Radestock f6e6926171 cosmetic: fix wrapped quote
apparently our wp md renderer does not handle this correctly
2016-07-20 07:09:09 +01:00
Matthias Radestock 25e7868cd5 fix some indentation in docs block quote 2016-07-20 07:03:17 +01:00
Matthias Radestock 385e6ff9b8 Merge pull request #2446 from weaveworks/explicit-sudo-s
Make use of `sudo -s` more explicit
2016-07-20 06:45:50 +01:00
Matthias Radestock 3755906689 blockquote sudo-ing 2016-07-20 06:26:23 +01:00
Matthias Radestock 63cbb34dec Make use of sudo -s more explicit
since people keep tripping over that.

Also

- add new error message spat out by recent dockers correct the socket
- URLs - they had fallen victim to a 'docker'->'Docker' replacement
- shorten the note on using the plugin
2016-07-20 06:26:03 +01:00
Adam Harrison 8ec6b699b1 Merge branch '1.6' 2016-07-18 11:48:08 +01:00
Adam Harrison 369852a3a7 Merge pull request #2430 from weaveworks/remove-duplicate-no-dns
remove duplication of `--no-dns`
2016-07-18 11:47:48 +01:00
Matthias Radestock c82be57639 Merge pull request #2423 from philwinder/docs/cni-mesos
Refactor CNI documentation.
2016-07-18 09:58:00 +01:00
Phil Winder 092c3a17d1 Change title. 2016-07-18 09:22:24 +01:00
Martynas Pumputis fd0a7efa23 Fix "weave ps" output when weave is not running
The #2418 has changed a behaviour of "weave ps" which outputs
"Link not found" in the case of weave not running. The previous
behaviour was to output an empty line.
2016-07-14 15:15:14 +01:00
Matthias Radestock 551f164ec3 Merge branch '1.6' 2016-07-12 20:47:23 +01:00
Matthias Radestock acdd739deb Merge branch 'fix-broken-link' into 1.6 2016-07-12 20:46:52 +01:00
Paul Bellamy 45e3016c6a Fixing a broken link in docs 2016-07-12 20:44:57 +01:00
Bryan Boreham 88bf64722f Merge branch '1.6' 2016-07-12 10:33:38 +00:00
Bryan Boreham c1483dbf1f Merge pull request #2418 from weaveworks/issues/2388-weave-ps
Fix "weave ps"; fixes #2388
2016-07-12 11:04:00 +01:00
Matthias Radestock d9c998b5c4 Merge pull request #2386 from weaveworks/issues/354-multicast-isolation
Provide multicast isolation with in-container-netns iptables rules

Fixes #354.
2016-07-12 09:46:14 +01:00
Adam Harrison 170e19c283 Merge branch '1.6' 2016-07-12 09:39:45 +01:00
Adam Harrison bce07b7491 Merge pull request #2439 from weaveworks/restore-script-function-grouping
refactor: restore grouping of functions in script
2016-07-12 09:39:15 +01:00
Matthias Radestock 8b5741506d refactor: restore grouping of functions in script
Recent(ish) changes placed functions in the wrong sections. Fix that
and label the sections more clearly.
2016-07-11 21:38:07 +01:00
Bryan Boreham 7c47a8ffb7 Log errors arising from reading resolv.conf 2016-07-11 12:08:04 +01:00
Matthias Radestock 791ab55875 Merge branch '1.6' 2016-07-09 05:42:02 +01:00
Matthias Radestock e642f366f5 cosmetic 2016-07-09 05:41:37 +01:00
Bryan Boreham bd1a9d020c Merge branch '1.6' 2016-07-07 11:20:50 +00:00
pidster d794b203f7 Adds ipam option to help.
Fixes https://github.com/weaveworks/weave/issues/2425
2016-07-07 11:20:00 +00:00
Matthias Radestock 7ec68119a6 remove duplication of --no-dns
This was harmless, but annoying.
2016-07-06 23:21:42 +01:00
Martynas Pumputis 71fd3b6b2b Merge remote-tracking branch 'origin/1.6' 2016-07-05 17:37:50 +01:00
Martynas Pumputis 93c60395f6 Merge pull request #2417 from weaveworks/issues/1852-less-logging
Move 'ODP miss' log from every miss to specific places

Fixes #1852
2016-07-05 17:34:57 +01:00
Phil Winder af27aa04f2 Add Mesos instructions. Edit old links. 2016-07-05 16:01:01 +01:00
Martynas Pumputis 0861d05522 Address PR comments
- Do not re-enter the root netns when querying weave bridge.
- Enter the root netns when constructing the predicate.
2016-07-05 15:12:39 +01:00
Martynas Pumputis 89221f117b Denote WithNetNS* functions with unsafe
Please see https://github.com/weaveworks/weave/issues/2388#issuecomment-228365069
for more details.
2016-07-05 15:12:39 +01:00
Martynas Pumputis 7f5c37ef1e Fix "weave ps"
Make sure that any network namespace changes happens at the end of
the cmd invocation. Otherwise, we are risking to end up in a situation
in which OS scheduling threads are in a "wrong" namespace.

See WithNetNS for more details.
2016-07-05 15:12:39 +01:00
Martynas Pumputis 05baa566c6 Refactor common.GetBridgeNetDev
- Optimize. Use LinkByName instead of iterating over list of available
  links. Linux does not support interfaces with the same names.
- Remove unnecessary indirection in utility functions which return
  common.NetDev.
2016-07-05 15:12:39 +01:00
Bryan Boreham f8ac27a6cc Merge branch '1.6' 2016-07-05 13:22:25 +01:00
Bryan Boreham e5c23bf9f5 Don't crash if docker API is disabled by params 2016-07-05 13:02:59 +01:00
Matthias Radestock 954cd0b86a Merge branch '1.6' 2016-07-04 16:27:59 +01:00
Matthias Radestock 0635ed1854 highlight the need for weave expose in CNI/k8s (#2411)
* highlight the need for `weave expose` in CNI/k8s

Fixes #2405

* Extend error message

* rearranged the sentences

weave launch <peer hosts> seems a bit orphaned here maybe include the weave connect command as well, since it's being mentioned.
2016-07-04 16:27:11 +01:00
Matthias Radestock 9dedeadf15 Merge branch '1.6' 2016-07-04 16:22:42 +01:00
Matthias Radestock 4424e877f0 Merge branch '1710-lb-clarification' into 1.6 2016-07-04 16:21:54 +01:00
Matthias Radestock 6561272f8d Merge branch '1.6' 2016-07-04 16:20:37 +01:00
Matthias Radestock aa54d332c2 correct RFC3484 address selection caveat (#2407)
and move it to a more prominent location

Fixes #1710
2016-07-04 16:20:19 +01:00
Matthias Radestock 881e795db5 correct RFC3484 address selection caveat (#2407)
and move it to a more prominent location

Fixes #1710
2016-07-04 16:19:20 +01:00
Matthias Radestock 4216231ec7 Merge branch '1.6' 2016-07-04 14:30:03 +01:00
Matthias Radestock e5aeb4bd05 improve --trusted-subnets docs (#2415)
improve --trusted-subnets docs

Fixes #2211
2016-07-04 14:28:11 +01:00
Matthias Radestock 333d5f7511 Merge pull request #2412 from weaveworks/1803-plugin-create
Refactor plugin to create veths in CreateEndpoint



Fixes #1803.
2016-07-04 12:19:01 +01:00
Matthias Radestock 7be7945b29 Merge branch '1.6' 2016-07-04 10:08:43 +01:00
Matthias Radestock 566ed64607 Merge pull request #2413 from weaveworks/2347-document-host
document --host

Fixes #2347.
2016-07-04 10:07:48 +01:00
Anita Buehrle 83c358c8d2 edited sentence 2016-07-03 09:51:52 -05:00
Bryan Boreham afe882cd94 Use more chars from endpointID to reduce clashes in veth names
Import library to get max name length IFNAMSIZ
2016-07-01 16:05:02 +01:00
Matthias Radestock 5b8a359475 Merge branch '1.6' 2016-07-01 10:31:39 +01:00
Matthias Radestock ae95248499 Merge remote-tracking branch 'upstream/issues/2293-warn-router-down' into 1.6 2016-07-01 10:31:12 +01:00
Matthias Radestock df0af203f8 Merge pull request #2416 from weaveworks/issues/2293-warn-router-down
Check that weave router is running before launching plugin

Fixes #2293.
2016-07-01 10:24:15 +01:00
Bryan Boreham 53b8c804f2 Launch the whole of weave to avoid tripping over plugin-only test 2016-07-01 10:17:05 +01:00
Bryan Boreham 7d0aaea6e8 Move 'ODP miss' log from every miss to specific places
Added log lines for packets that we will broadcast;
Added log lines for flows we don't know how to handle;
Moved the line for when we expect to insert a flow down to the miss-handler;
Packets handled by the bridge already have their own logging via --pktdebug
2016-07-01 10:12:53 +01:00
Bryan Boreham 45a66ac517 Extend 'mac associated with other peer' error info 2016-06-30 18:02:39 +01:00
Bryan Boreham 087d948941 Check that weave router is running before launching plugin 2016-06-30 12:02:52 +01:00
Matthias Radestock 5b2a4ff614 Merge branch '1.6' 2016-06-29 20:12:58 +01:00
Matthias Radestock 72e92db96e document --host
and add some broader points about access control early on, since some
users will wonder about that right from the start.

Fixes #2347
2016-06-29 20:09:02 +01:00
Matthias Radestock 768414534f cosmetic: more logical order of args in usage 2016-06-29 20:00:47 +01:00
Bryan Boreham ceb5f8c714 Move endpoint creation into CreateEndpoint so we can return the MAC address 2016-06-29 17:38:07 +01:00
Bryan Boreham cc3359dfe5 Merge branch '1.6' 2016-06-29 14:42:17 +01:00
Bryan Boreham f1ca4854b8 Merge pull request #2409 from weaveworks/issues/2381-awsvpc-fix-attach-router
Fix re-attaching of weave router in awsvpc mode
2016-06-29 14:41:14 +01:00
Martynas Pumputis 6319860230 Change the order of awsvpc initialization
We want to setup the necessary arp settings as soon as possible
and before we re-insert DNS entries. Otherwise, the announced
containers might not be reachable.

Also, do not try to reclaim for weave:expose inside populate_router,
because we do expose before calling it.
2016-06-29 11:15:56 +01:00
Martynas Pumputis 58caf38f07 Fix re-attaching of weave router in awsvpc mode
In order to re-attach the router and make it work in awsvpc mode,
the following has to be done:

- expose_ip on the router
- adjusting arp settings
- restoring host routes

To detect that we run in awsvpc mode, we inspect cmd parameters
of the weave router instead of GET'ing /ipinfo/tracker. This is so,
because the HTTP server started by the router might not be running
at the time of restoration.
2016-06-29 11:15:49 +01:00
Matthias Radestock cb4b5fd143 correct RFC3484 address selection caveat
and move it to a more prominent location

Fixes #1710
2016-06-29 06:57:17 +01:00
Matthias Radestock cda6785f1d Merge remote-tracking branch 'upstream/master' 2016-06-29 05:58:29 +01:00
Matthias Radestock cb030be4ad Merge branch '1.6' 2016-06-29 05:57:01 +01:00
Matthias Radestock 7165414fc3 improve clock skew error message
Fixes #2174
2016-06-29 05:48:10 +01:00
Bryan Boreham b464ce86f7 Merge branch '1.6' 2016-06-28 13:36:10 +00:00
Bryan Boreham d72d3af36e Remove deprecated -awsvpc option 2016-06-28 13:35:47 +00:00
Adam Harrison 80b3514e24 Merge branch '1.6' 2016-06-20 16:29:29 +01:00
Adam Harrison f07ed7153b Remove link to non-existent blog post 2016-06-20 15:32:00 +01:00
Adam Harrison e33f56f9b0 Merge branch '1.6' 2016-06-20 14:53:03 +01:00
Adam Harrison 6c46af25cc Fix typo 2016-06-20 14:47:52 +01:00
Adam Harrison 5ad227a8b3 Add release v1.6.0 2016-06-20 13:50:19 +01:00
Matthias Radestock 67fe1e5daf clarify init-peer-count deprecation warning
Fixes #2355
2016-06-20 03:54:16 +01:00
Matthias Radestock 99b475056a Merge branch '1.5' 2016-06-20 03:25:10 +01:00
Martynas Pumputis 804f4ad971 Add check-datapath to weaveutil
The utility is used to check whether a datapath can be created.
2016-06-20 03:24:30 +01:00
Martynas Pumputis 24d9a00f47 Add check-datapath to weaveutil
The utility is used to check whether a datapath can be created.
2016-06-20 03:20:46 +01:00
Matthias Radestock b00e7d088e Merge pull request #2372 from weaveworks/issues/2310-more-checkpoint
Add kernel version, Docker version and awsvpc setting to checkpoint info

Fixes #2310
2016-06-20 03:15:25 +01:00
Bryan Boreham c12e909882 Document what is sent in checkpoint request 2016-06-20 03:13:10 +01:00
Anita Buehrle 6356fbc882 Ops edits (#2371) 2016-06-20 03:04:53 +01:00
Matthias Radestock ca7220b775 Merge branch '1.5' 2016-06-19 02:51:52 +01:00
Matthias Radestock 619a02eefb fix a couple of typos 2016-06-19 02:51:11 +01:00
Martynas Pumputis 85c1a31e5c Merge pull request #2383 from weaveworks/proxy-buffer
Use buffered writer for http headers
2016-06-17 17:29:39 +01:00
Adam Harrison f386548890 Maintain per-subnet ACCEPT rule for multicast ingress 2016-06-17 17:19:52 +01:00
Bryan Boreham f86ade6568 Squash up the code via 'defer' 2016-06-17 16:52:17 +01:00
Bryan Boreham 81fa4059df Use buffered writer for http headers 2016-06-17 16:52:17 +01:00
Adam Harrison c80d87554a Maintain per-interface DROP rule for multicast ingress 2016-06-17 16:10:13 +01:00
Matthias Radestock e77bf60d34 Merge branch '1.5' 2016-06-17 15:48:33 +01:00
Matthias Radestock 61cb5535db Merge pull request #2385 from weaveworks/2286-fix-check
Fix check before removing plugin sockets

Fixes the fix in #2292.
2016-06-17 15:47:48 +01:00
Bryan Boreham 63314beb2a Remove plugin sockets in 'weave reset' 2016-06-17 15:17:13 +01:00
Bryan Boreham 2d0be34a93 Fix check to see if plugin is running 2016-06-17 15:17:13 +01:00
Matthias Radestock 0abfdf4efb Merge branch '1.5' 2016-06-17 15:07:34 +01:00
Matthias Radestock b014de3f08 Merge pull request #2382 from weaveworks/issues/2379
Fix Docker 1.12 incompatibilities

Fixes #2379.
2016-06-17 15:06:55 +01:00
Bryan Boreham 56c275a9bf Copy Docker's response code through for raw stream.
This means when Docker says "101 UPGRADED" the proxy will say the
same, instead of "200 OK".  Docker 1.12 barfs if you do that.
2016-06-17 13:07:04 +01:00
Bryan Boreham ddd039761d Handle Docker daemon named 'dockerd' 2016-06-17 13:05:35 +01:00
Adam Harrison f4798fadf8 Merge pull request #2374 from weaveworks/issues/1726-plugin-arp
Perform arp configuration for plugin-connected containers
2016-06-17 10:19:53 +01:00
Bryan Boreham adda1c459c Fix plugin filter - truncate Docker ID to 12 chars 2016-06-16 18:03:45 +01:00
Matthias Radestock 979df93bff Merge pull request #2378 from weaveworks/issues/2364-observe-resolv-conf
Observe resolv.conf changes

Fixes #2364.
2016-06-16 17:13:10 +01:00
Adam Harrison 27e7ec08d4 Observe resolv.conf changes 2016-06-16 16:55:40 +01:00
Adam Harrison c6a777c4b0 Merge pull request #2366 from weaveworks/issues/2189-publish-weavedb
Publish weavedb container from release script
2016-06-16 11:03:27 +01:00
Bryan Boreham 7182ec0463 Merge pull request #2338 from weaveworks/awsvpc-docs
awsvpc docs
2016-06-15 16:59:54 +01:00
Bryan Boreham 425f17aab1 Mention that 'weave launch' now waits 2016-06-15 16:58:05 +01:00
Bryan Boreham 3494cc39c1 Expand description surrounding link to awsvpc mode 2016-06-15 16:58:05 +01:00
Bryan Boreham 2face0f318 Publish weavedb container from release script 2016-06-15 15:50:37 +01:00
Bryan Boreham bb203a2d18 Merge branch '1.5' 2016-06-15 13:50:47 +01:00
Bryan Boreham 95b42a532a Merge pull request #2367 from weaveworks/issues/2290-own-image
Use our own ubuntu image
2016-06-15 13:50:26 +01:00
Bryan Boreham 08e2c5c14e Fix link for 'docker run' docs 2016-06-15 13:48:25 +01:00
Bryan Boreham a4f3e763bb Use our own ubuntu image 2016-06-15 13:47:20 +01:00
Bryan Boreham 06feefe80f Merge branch '1.5' 2016-06-15 11:12:12 +01:00
Bryan Boreham 3dd7e13cc0 Merge pull request #2369 from weaveworks/issues/2335
Describe creating multiple networks using the plugin
2016-06-15 11:11:25 +01:00
Bryan Boreham fdf3afa935 Review feedback 2016-06-15 11:10:13 +01:00
Bryan Boreham 8bb8f70bb6 Perform arp configuration for plugin-connected containers 2016-06-14 17:53:34 +01:00
Bryan Boreham c71c630cf6 Use driver name to detect 'our' endpoints
so we don't have to remember all the endpoint IDs, or load them up
after a restart.
2016-06-14 17:52:45 +01:00
Matthias Radestock 179b6f7cf9 Merge pull request #2368 from weaveworks/small-doc-fixes
Small doc fixes
2016-06-14 16:26:17 +01:00
Bryan Boreham 1fe5c65fd4 Add kernel version, Docker version and awsvpc setting to checkpoint info 2016-06-14 12:24:37 +01:00
Bryan Boreham e1edce84d9 Extract checkForUpdates to its own file 2016-06-14 10:33:46 +01:00
Martynas Pumputis 73a393823a Merge pull request #2370 from weaveworks/awsvpc-clashes
Report a couple of options that are incompatible with --awsvpc
2016-06-14 10:12:37 +01:00
Bryan Boreham b32da8d69f Report a couple of options that are incompatible with --awsvpc 2016-06-13 16:53:27 +01:00
Bryan Boreham b993fd67ab Describe creating multiple networks using the plugin 2016-06-13 16:49:55 +01:00
Bryan Boreham e9770740d8 Use short name rather than long hex ID 2016-06-13 16:20:32 +01:00
Bryan Boreham 7abed164eb Clean up reference to 'above' 2016-06-13 16:11:01 +01:00
Matthias Radestock 7a1bd27a58 Merge branch '1.5' 2016-06-13 15:24:49 +01:00
Matthias Radestock aca34191da Merge pull request #2365 from weaveworks/issues/2283-validate-cidrs
Validate CIDRs in proxy before attaching a container

Fixes #2283
2016-06-13 15:15:48 +01:00
Martynas Pumputis df5508c0f3 Check CIDRs before attaching a container in proxy
If any cidr is invalid, a user will get the following error:
"docker: Error response from daemon: invalid WEAVE_CIDR: $CIDR".
2016-06-13 14:54:16 +01:00
Bryan Boreham e63fd0b38f Merge branch '1.5' 2016-06-13 12:00:46 +01:00
Bryan Boreham 47878cf5b6 Merge pull request #2362 from weaveworks/checkpoint-doc
Re-instate mention of checkpoint on install page
2016-06-13 11:13:16 +01:00
Anita Buehrle f0ea18171b tweaked the sentence a little 2016-06-13 10:57:35 +01:00
Bryan Boreham aa3f40ec8d Re-instate mention of checkpoint on install page lost in d1e004dedc 2016-06-13 10:57:19 +01:00
Bryan Boreham bf8c8833e5 Merge pull request #2356 from weaveworks/issues/2322-awsvpc-enhance
Transfer IPAM ranges to UnknownPeer if no peer is found during Shutdown
2016-06-10 14:00:36 +01:00
Martynas Pumputis 8569cbd4a3 Force transferring of IPAM ranges in a case of Shutdown
If no peer for transfer is found, we transfer them to
mesh.UnknownPeerName to notify the ring update tracker.

Makes the awsvpc tracker to remove local entries from
the VPC route table when the last peer calls "weave reset".
2016-06-10 11:51:31 +01:00
Adam Harrison adcb1018df Merge pull request #2345 from weaveworks/issues/2344-persist-more
Fix ring persistence after free space update
2016-06-09 16:37:57 +01:00
Adam Harrison f4b9a9b66c Merge pull request #2352 from weaveworks/issues/2318-moar-help
Print usage on --help argument to any command
2016-06-09 16:02:35 +01:00
Bryan Boreham 52d911c8c1 Merge branch '1.5' 2016-06-09 13:06:41 +00:00
Bryan Boreham d1314dd248 Fix broken link 2016-06-09 13:05:39 +00:00
Bryan Boreham 5db7a2bae1 Print usage on --help argument to any command 2016-06-09 12:44:37 +00:00
Bryan Boreham 71540e6c6d Clarify IAM role and policy 2016-06-09 10:41:34 +00:00
Anita Buehrle 3c45ba09f9 A few edits to improve awsvpc docs.
Fixed up the notes with spaces and bolding
Fixed some awkwardness in first paragraph
Fixed a couple of other sentences
2016-06-09 10:40:46 +00:00
Bryan Boreham cf87a84bd9 Merge pull request #2341 from weaveworks/issues/2017-awsvpc
Add AWSVPC. Fixes #2017
2016-06-08 17:24:55 +01:00
Bryan Boreham c77b2e8fb3 Tell the proxy that multicast is off in awsvpc mode.
Otherwise it will use the regular weavewait program which wait for the
multicast route to be added.
2016-06-08 16:44:54 +01:00
Bryan Boreham 37fd54f20b Perform AWSVPC checks for attach in script rather than in weaveutil 2016-06-08 16:44:54 +01:00
Martynas Pumputis fb9b4ddec0 Enable AWSVPC
This requires the following additional steps:

- Setting proxy_arp on on the bridge, because that's how we do
  the routing (check the comment at the place where we set it on).
- Disable ARP requests queueing, because it introduces unnecessary
  delay for the first ARP request resulting in a high latency of
  the first packet (on t2.micro machines I've encountered ~700ms
  latency). Also, the queue is bounded, so we might risking to drop
  the requests.
2016-06-08 16:44:54 +01:00
Martynas Pumputis 7670fed72c Add AWSVPC setup routines to the attach script
When running in the AWSVPC mode, we need to do the following:

- Keep the HW TX offloading on.
- Check that the allocated address belongs to the default subnet,
  because only one subnet is allowed and it should be the default one.

If it is not possible to determine whether AWSVPC is on, we ignore
all the steps, because the attachment routines have to work
regardless whether the router is running and the AWSVPC detection
is done by querying the /ipinfo/tracker endpoint served by
the router.
2016-06-08 16:44:54 +01:00
Martynas Pumputis de2a70861c Add GET /ipinfo/tracker
The endpoint returns the name of tracker. It is used to determine
whether the router is running a tracker.
2016-06-08 16:44:54 +01:00
Martynas Pumputis 9fc7be83c8 Create a Tracker when starting the router
The tracker's HandleUpdate method is called by the ring update routines.

In addition, we add a dummy overlay for AWSVPC to make `weave (status|
report)` to produce reasonable reports which includes AWS hosts
connection state.
2016-06-08 16:44:54 +01:00
Martynas Pumputis c260536429 Add AWSVPC Tracker
The tracker is responsible for managing the AWSVPC route tables
which is used to implement the underlay routing based on VPC.
2016-06-08 16:44:54 +01:00
Martynas Pumputis 59b3a3c8c5 Add the Tracker interface
An instance of the interface must implement the HandleUpdate method
which (in the future) will be called when any change to the IPAM ring
occurs.
2016-06-08 16:44:54 +01:00
Martynas Pumputis 49f2e208c3 Make ClaimForPeers to claim CIDR-aligned ranges 2016-06-08 16:44:54 +01:00
Martynas Pumputis 2266868648 Add the range.CIDRs functions 2016-06-08 16:44:54 +01:00
Bryan Boreham d1bba977f3 Don't stop reporting free space at the first unchanged range 2016-06-08 11:53:35 +01:00
Bryan Boreham e2bee6e8c6 Persist ring after updates caused by reportFreeSpace() 2016-06-08 11:52:38 +01:00
Bryan Boreham 6062627582 Merge branch '1.5' 2016-06-08 11:00:57 +01:00
Anita Buehrle efee8e73c6 minor edits also added link to guide 2016-06-08 11:00:33 +01:00
Bryan Boreham 37f820a168 Fail the script if any of the background tasks fails 2016-06-07 14:37:43 +01:00
Bryan Boreham c41ca708f3 Add AWS-VPC diagram 2016-06-07 13:58:22 +01:00
Bryan Boreham 73d7812dc5 Check that latest version of weave image exists
The smoke-tests are meant to be run in a context where you have just
uploaded a build. If that upload failed and we don't do this check
then we will download the 'latest' images from DockerHub.
2016-06-07 13:29:44 +01:00
Bryan Boreham 6a410a7749 Minor improvements 2016-06-07 13:01:42 +01:00
Adam Harrison 843a993600 Merge pull request #2332 from weaveworks/issues/2326-warn-rmpeer
Warn on 'weave reset' if DELETE fails
2016-06-06 16:56:38 +01:00
Bryan Boreham 0fc59a831c Initial awsvpc docs 2016-06-06 16:47:23 +01:00
Matthias Radestock 7ffbeead8d Merge pull request #2327 from weaveworks/issues/1960-mcast-option
Add an option to disable multicast route per-network

Fixes #1960.
2016-06-06 15:49:09 +01:00
Bryan Boreham 9a17439e2f Warn on 'weave reset' if weave container is not running 2016-06-06 15:46:30 +01:00
Bryan Boreham ab74d7b438 Improve plugin multicast docs 2016-06-06 15:41:21 +01:00
Adam Harrison d4de48aeee Merge branch '1.5'
Closes #2302
2016-06-06 15:21:54 +01:00
Adam Harrison eaa4bd1a6c Merge pull request #2333 from weaveworks/issues/2302-symlink-loop
Check if socket is identical to weave socket after trimming prefix.
2016-06-06 15:20:23 +01:00
Bryan Boreham c380a6f4ee Improve handling of build container
- Only mention the need for it on the one rule where it gets used.
- Don't delete it in `make clean-bin`.
2016-06-06 14:04:33 +01:00
Matthias Radestock faef371a8c Merge branch '1.5' 2016-06-06 11:51:19 +01:00
Bryan Boreham 39ba706a9b Run just one container to build all exes 2016-06-06 11:43:08 +01:00
Matthias Radestock aa4980bbda remove plugin cluster store section
it served no purpose and was misleading
2016-06-06 11:36:18 +01:00
Matthias Radestock 7f5bf67d33 cosmetic: fix some styling in plugin docs 2016-06-06 11:33:38 +01:00
Matthias Radestock e7e27796e4 eliminate some duplication in the plugin docs 2016-06-06 11:32:57 +01:00
Matthias Radestock 2491f49243 tweak plugin config docs 2016-06-06 11:32:15 +01:00
Matthias Radestock c25281e827 remove dead link 2016-06-06 11:30:10 +01:00
Matthias Radestock a4cd4d5a2f tweak plugin pitch 2016-06-06 11:22:07 +01:00
Bryan Boreham c6d1adf220 Revert "Do a build before the 'go test'"; it doesn't look like this goes faster after all
This reverts commit bd7e5d6921.
2016-06-05 14:56:05 +01:00
Bryan Boreham 5dd7590e5c Merge pull request #1978 from weaveworks/weave-1.5-doc-updates
Operational guide. Fixes #726, fixes #1102
2016-06-03 17:30:06 +01:00
Adam Harrison e092a517aa Operational guide 2016-06-03 17:12:29 +01:00
Adam Harrison 9b6154cf63 Merge pull request #2331 from weaveworks/issues/2320-plugin-warning
Augment warning on active plugin endpoints
2016-06-03 16:17:31 +01:00
Adam Harrison 1e4d86775f Merge pull request #2330 from weaveworks/issues/1988-proxy-plugin
Proxy shouldn't weave-attach containers which are using a network plugin
2016-06-03 15:48:35 +01:00
Bryan Boreham 2728bc0f9d Merge pull request #2305 from weaveworks/issues/2186-peer-list-persistence
Peer list persistence; Fixes #2186.
2016-06-03 14:31:01 +01:00
Bryan Boreham dac2124cd1 Don't weave-attach containers which are using a network plugin
Particularly intended for cases where the user has configured the
proxy and also said --net=weave, but will catch any other plugin
similarly
2016-06-03 14:11:15 +01:00
Anita Buehrle 37f5a17953 Update docs 2016-06-03 13:53:07 +01:00
Adam Harrison f9dd763774 Peer list persistence smoke test 2016-06-03 13:53:07 +01:00
Adam Harrison 4b758dd130 Implement weave launch --resume 2016-06-03 13:53:07 +01:00
Adam Harrison 5e03c0fe25 Revert #1967 (container reuse) 2016-06-03 13:53:07 +01:00
Adam Harrison 166d4afad8 Use persisted peer list on Docker restart 2016-06-03 13:53:07 +01:00
Bryan Boreham 153ed601be Check if socket is identical to weave socket after trimming prefix.
This allows us to run 'weave proxy -H /var/run/weave/weave.sock'
2016-06-03 13:34:43 +01:00
Bryan Boreham cbf4a0facd Move warning on plugin active into Go code 2016-06-02 17:19:51 +01:00
Bryan Boreham a1c3cba363 Invert multicast option in plugin
Now it's off by default, and there is an option to enable the
multicast route per-network.
We turn it on for the `weave` network created when we start the plugin.
2016-06-02 12:52:30 +01:00
Bryan Boreham 1d91c1a23b Cleanup: change ring test from 255 to 256 in length, which is more realistic 2016-06-01 17:51:21 +01:00
Martynas Pumputis f50fbc002e Change ipam Universe from Range to CIDR
There was no code to initialize it as anything else, and this lets us
bake in an assumption that it will always be a CIDR.
2016-06-01 17:06:31 +01:00
Adam Harrison dbc8b4fe1a Updated badges 2016-06-01 14:43:23 +01:00
Matthias Radestock b1fa417381 Merge branch '1.5' 2016-05-27 19:34:51 +01:00
Matthias Radestock 912e8fe119 Merge pull request #2323 from weaveworks/name-tests-properly
Name tests so they are picked up by runner
2016-05-27 19:33:34 +01:00
Bryan Boreham e2294482a6 Refactor: extract functional parts of weave export so they can be called from elsewhere 2016-05-27 16:52:53 +01:00
Adam Harrison b4fda4c98e Name tests so they are picked up by runner 2016-05-27 16:47:47 +01:00
Bryan Boreham d9da08792f Merge branch '1.5' 2016-05-27 13:40:29 +01:00
Bryan Boreham bf040105da Speed up smoke-tests by reducing timeout on 'docker stop' 2016-05-27 13:15:32 +01:00
Bryan Boreham e8ca085758 Merge branch '1.5' 2016-05-26 16:30:26 +00:00
Bryan Boreham 7300c33793 Add release v1.5.2 2016-05-26 16:10:07 +00:00
Bryan Boreham f5cd7b5073 Remove 'make update' from release process now we vendor dependencies 2016-05-26 16:10:07 +00:00
Adam Harrison f02b78ed73 Merge branch '1.5'
Closes #2282
2016-05-26 16:16:54 +01:00
Adam Harrison b3379df53d Merge pull request #2321 from weaveworks/issues/2282-check-subnets
Check validity of IP subnets
2016-05-26 16:16:39 +01:00
Adam Harrison c9525532ea Merge branch '1.5'
Closes #2300
2016-05-26 16:08:14 +01:00
Adam Harrison 654a811ef0 Merge pull request #2319 from weaveworks/issues/2300-spot-gateway
Don't release fake gateway address in plugin
2016-05-26 16:07:39 +01:00
Bryan Boreham cda1084777 Check validity of IP subnets
Be more consistent about this - check in the same way whether at startup
or during allocation.
2016-05-26 14:31:17 +00:00
Bryan Boreham fd257f43d1 Don't release fake gateway address
Watch out for Docker releasing the fake gateway address we create when
the network is set up, and don't pass it on to Weave IPAM.
2016-05-26 12:30:03 +00:00
Bryan Boreham 8ff814d976 Plugin and weaveutil depend on networking code 2016-05-26 11:35:10 +00:00
Bryan Boreham 7c819e7f5c Merge branch 'issues/1940-remove-proxy-attach-dep' 2016-05-26 11:33:37 +00:00
Bryan Boreham b417696c66 Wait 1ms before sending gratuitous arp 2016-05-26 11:17:04 +00:00
Martynas Pumputis f0109c1920 Merge pull request #2307 from weaveworks/issues/1940-remove-proxy-attach-dep
Move container attachment from sh to Go
2016-05-26 10:11:02 +01:00
Bryan Boreham 6dd109a5bb Only do ethtool tx off in bridged (pcap) mode.
Detect the bridge type in the same way the weave script does.
2016-05-25 17:34:13 +01:00
Bryan Boreham 2702b85ee5 Improve veth name construction; use a constant instead of "ethwe" 2016-05-25 17:34:13 +01:00
Bryan Boreham 8717fd15ed Use 'peer' and 'veth' instead of 'guest' and 'local', after review comments 2016-05-25 17:34:13 +01:00
Bryan Boreham 161446d55d Move error detection for attach() into Go 2016-05-25 17:34:13 +01:00
Bryan Boreham ac14b19db8 Move attach() and detach() from shell script to Go 2016-05-25 17:34:13 +01:00
Adam Harrison e3ef473cd3 Utility function to disable tx checksum offload 2016-05-25 17:29:45 +01:00
Bryan Boreham 4fc2835d92 Extract AddRoute function 2016-05-25 17:29:45 +01:00
Bryan Boreham 85023e0a76 Extract AttachContainer() function
Also move netlink and netns code from common to net

Creates interface if not already there
Adds addresses
Move the set link 'up' to after addresses are added
2016-05-25 17:29:45 +01:00
Bryan Boreham 0257274aa8 Extract basic veth setup 2016-05-25 17:23:49 +01:00
Bryan Boreham 9aaa7f19fd initialize via sub-function 2016-05-25 17:17:19 +01:00
Bryan Boreham 9f8b94645d Obtain IP address before setting up veth 2016-05-25 17:17:19 +01:00
Bryan Boreham c458deaf80 Slight cleanup 2016-05-25 17:17:19 +01:00
Bryan Boreham d59c170cd5 Remove veth on error 2016-05-25 17:17:19 +01:00
Bryan Boreham f11d91badf Extract veth creation and LinkSetUp to net package 2016-05-25 17:17:19 +01:00
Martynas Pumputis c63619bf7d Merge remote-tracking branch 'origin/1.5' 2016-05-25 17:09:48 +01:00
Martynas Pumputis d9d1956e0c Merge pull request #2313 from weaveworks/cni-gratuitous-arp
Send out arp update from CNI plugin
2016-05-25 17:06:10 +01:00
Bryan Boreham f695b3fd17 Smoke-test CNI arp update 2016-05-25 12:05:20 +01:00
Bryan Boreham ede00047db Send out arp update from CNI plugin 2016-05-25 12:05:20 +01:00
Adam Harrison 52377df340 Merge branch '1.5' 2016-05-24 17:10:52 +01:00
Adam Harrison 424d331a32 Merge pull request #2314 from weaveworks/disable-doc-previews
Temporarily disable doc previews
2016-05-24 17:10:28 +01:00
Adam Harrison fbbbb924a3 Temporarily disable doc previews 2016-05-24 16:46:41 +01:00
Matthias Radestock caeff127c9 Merge branch '1.5' 2016-05-24 11:27:42 +01:00
Bryan Boreham 56145ba518 Merge pull request #2311 from weaveworks/issues/2306-proxy-swarm-pending
Flush chunked response header immediately; fixes #2306.
2016-05-24 10:36:09 +01:00
Adam Harrison 885b6195f6 Flush chunked response header immediately 2016-05-24 08:28:24 +01:00
Bryan Boreham df3ccd362a Merge branch '1.5' 2016-05-19 15:58:55 +01:00
Bryan Boreham 5ed18994cd Send error messages about incompatible bridge settings to stderr 2016-05-19 15:58:15 +01:00
Adam Harrison 4dca07c9ff Merge pull request #2296 from weaveworks/issues/2284-die-another-way
Move kill-on-failure responsibility to caller of weave script
2016-05-18 12:19:44 +01:00
Adam Harrison b16de0c71e Merge pull request #2299 from weaveworks/issues/fix-offset-abuse
Change the type of entry.Free to address.Count
2016-05-18 12:04:54 +01:00
Adam Harrison a131703b2d Merge remote-tracking branch 'origin/1.5' 2016-05-18 10:29:55 +01:00
Adam Harrison 78672db440 Merge pull request #2292 from weaveworks/issues/2286-hang-torpedoes
Protect against Docker hanging trying to talk to a non-existent plugin
2016-05-18 10:27:13 +01:00
Adam Harrison 5b4906f822 Merge branch '1.5' 2016-05-18 09:46:01 +01:00
Adam Harrison ee9f8eec1c Merge pull request #2291 from weaveworks/issues/refactor-check-attached
Refactor wait_for_{proxy,attached}
2016-05-18 09:44:15 +01:00
Adam Harrison dc0e25a420 Add .ackrc which excludes vendor/ and .pkg/ 2016-05-17 10:37:56 +01:00
Martynas Pumputis 85cea672d3 Change the type of entry.Free to address.Count
This change is backward compatible, because the underlying types of
address.Offset (the previous type) and address.Count are the same
and the Gob encoder does not require types to exactly correspond.
2016-05-16 15:03:05 +01:00
Bryan Boreham ff81ecfd41 Move kill-on-failure responsibility to caller of weave script 2016-05-16 13:38:22 +01:00
Martynas Pumputis ef5f80a05a Merge pull request #2287 from weaveworks/donate-cidr-aligned
Donate CIDR-aligned ranges instead of just slicing at the mid-point.
2016-05-16 12:40:17 +01:00
Bryan Boreham d551b6b0a8 Review feedback 2016-05-13 16:27:28 +01:00
Bryan Boreham 1ec2c0fb3f Use a CIDR-aligned CIDR in unit tests 2016-05-13 16:27:28 +01:00
Bryan Boreham d1e2aa6d36 Use quick.Check instead of many specific tests 2016-05-13 16:27:28 +01:00
Bryan Boreham 64dc7a1f69 Donate power-of-2-aligned ranges instead of just slicing at the mid-point.
Also fix up space tests to match.
2016-05-13 16:27:28 +01:00
Bryan Boreham bc79a9187f Protect against Docker hanging trying to talk to a non-existent plugin
Remove the Unix socket from the filesystem before doing volume
operations, if the plugin is not running.
2016-05-12 15:40:04 +00:00
Martynas Pumputis 02d9c090ed Add wait_for_attached 2016-05-12 12:25:59 +01:00
Martynas Pumputis 671ed724d5 Move wait_for_proxy to config.sh 2016-05-12 12:15:20 +01:00
Bryan Boreham f37e742536 Merge branch '1.5' 2016-05-12 11:00:14 +00:00
Bryan Boreham 6c7f860418 Merge pull request #2278 from weaveworks/issues/fix-320-claim-test
Fix 320_claim_3_test.sh
2016-05-12 11:59:14 +01:00
Bryan Boreham 79d78ae97b Merge branch '1.5' 2016-05-12 09:57:48 +00:00
Bryan Boreham 4ff574744e Use ubuntu:trusty to ensure 'nc' is available 2016-05-12 09:53:29 +00:00
Martynas Pumputis 7c3e937ae8 Fix 320_claim_3_test 2016-05-11 12:18:39 +01:00
Martynas Pumputis 178438c470 Merge branch '1.5' 2016-05-10 17:36:56 +01:00
Martynas Pumputis 632694472c Merge pull request #2281 from weaveworks/issues/2275-request-order
Ignore IPAM requests for space until we have a ring

Fixes #2275
2016-05-10 17:36:26 +01:00
Martynas Pumputis 14e1145972 Merge branch '1.5' 2016-05-10 17:34:08 +01:00
Martynas Pumputis 8df1aa48a5 Merge pull request #2280 from weaveworks/sleep-perchance
Move sleep on reset from IPAM Allocator to weave script
2016-05-10 17:33:30 +01:00
Bryan Boreham 16b75f899e Move sleep on reset from IPAM Allocator to weave script 2016-05-10 16:03:08 +01:00
Bryan Boreham c3abe4f7b2 If we don't have a ring, just ignore a request for space. 2016-05-10 15:33:13 +01:00
Bryan Boreham f800813031 Test claim as first operation 2016-05-10 15:32:15 +01:00
Martynas Pumputis f7bddab4cb Merge branch '1.5' 2016-05-10 15:27:15 +01:00
Martynas Pumputis c434345960 Fix typo 2016-05-10 15:24:38 +01:00
Martynas Pumputis f9157acced Fix logging 2016-05-10 15:18:10 +01:00
Bryan Boreham e49bbe176d Make clear that we want the same universe throughout the test 2016-05-10 13:32:56 +01:00
Adam Harrison 0e694ed6b4 Merge branch '1.5' 2016-05-09 16:37:05 +01:00
Adam Harrison 9dfd7004cc Document adding new version to checkpoint API 2016-05-09 16:36:32 +01:00
Bryan Boreham cf6d0c8126 Merge branch '1.5' 2016-05-09 15:48:20 +01:00
Bryan Boreham 3963d4453a Remove mention of obsolete branch latest_release_doc_updates 2016-05-09 15:48:05 +01:00
Bryan Boreham 99b0b949e8 Merge branch '1.5' 2016-05-09 15:40:12 +01:00
Bryan Boreham ce5d2a6dd0 Add release v1.5.1 2016-05-09 15:16:21 +01:00
Adam Harrison 801283267a Merge branch '1.5'
Closes #1876.
2016-05-09 14:58:28 +01:00
Bryan Boreham a2e301c648 Merge pull request #2263 from weaveworks/issues/1876-weave-status-ipam-docs
Document `weave status ipam`. Fixes #1876.
2016-05-09 14:56:59 +01:00
Bryan Boreham 2249c7c648 Merge branch '1.5' 2016-05-09 14:46:06 +01:00
Bryan Boreham 0425d5bf6a Removed duplicated 'name' 2016-05-09 14:45:43 +01:00
Bryan Boreham de9597b6fa Merge branch '1.5' 2016-05-09 14:38:00 +01:00
Bryan Boreham 2fa576f3c0 Merge pull request #2265 from weaveworks/issues/2232-block-claim
Make claim block if the IPAM ring is not established. Fixes #2232
2016-05-09 14:37:37 +01:00
Adam Harrison fa29a4b4af Document weave status ipam 2016-05-09 13:41:42 +01:00
Martynas Pumputis d698aefbfc Make Claim to block if the IPAM ring is not established 2016-05-09 12:48:41 +01:00
Matthias Radestock db1ac2a343 Merge branch '1.5' 2016-05-09 11:50:09 +01:00
Matthias Radestock a3b6380296 Merge pull request #2264 from weaveworks/issues/2123-die-another-way
Kill process instead of container, on container restart.

Fixes #2123
2016-05-09 11:47:58 +01:00
Bryan Boreham 469d456c8b Smoke-test for container restart with proxy attach failure 2016-05-09 11:19:19 +01:00
Matthias Radestock 438efcccda Merge branch '1.5' 2016-05-07 20:19:18 +01:00
Matthias Radestock daa369b86c refactor: extract a couple of helpers in allocator tests
to reduce repetition
2016-05-07 20:18:21 +01:00
Matthias Radestock c3a2ea3dd8 Merge branch '1.5' 2016-05-07 17:57:10 +01:00
Matthias Radestock c54f2959ad Merge pull request #2266 from weaveworks/issues/2233-peer-name-docs
Document peer name

Fixes #2233.
2016-05-07 17:56:39 +01:00
Matthias Radestock ac0f284c5f Merge branch '1.5' 2016-05-07 14:43:04 +01:00
Matthias Radestock bd06553ce0 Merge pull request #2262 from weaveworks/issues/2194-reclaim-plugin-addrs
Reclaim plugin addresses without warning

Fixes #2194
2016-05-07 14:41:03 +01:00
Adam Harrison 158fa9d8e5 Reclaim plugin addresses using container ID of '_' 2016-05-07 14:35:15 +01:00
Anita Buehrle d234ca6ab8 clarified sentence, cosmetic 2016-05-06 12:41:59 -05:00
Bryan Boreham 8d71467802 Kill process instead of container, on container restart.
When Docker restarts a container and something goes wrong attaching
the network, kill the process inside the container instead of killing
the container, so that Docker will restart it again
2016-05-06 18:02:11 +01:00
Adam Harrison 8c5cbc738a Document peer name 2016-05-06 17:47:34 +01:00
Bryan Boreham 01e3d1d81b Refactor: extract kill_container function 2016-05-06 15:45:54 +01:00
Matthias Radestock 5e297c366e Merge branch '1.5' 2016-05-06 15:13:19 +01:00
Matthias Radestock 39b0d2a0cb Merge pull request #2261 from weaveworks/readme-update
remove duplicate content in README

Fixes #2217
2016-05-06 15:10:59 +01:00
Adam Harrison 260b416cd7 Include interface name in container-addrs output 2016-05-06 14:12:50 +01:00
Adam Harrison ad5845b67f Fix echo_ips 2016-05-06 14:12:19 +01:00
Bryan Boreham b426973679 Merge branch '1.5' 2016-05-06 12:46:21 +01:00
Bryan Boreham 7fcd837277 Cosmetic 2016-05-06 12:45:54 +01:00
Bryan Boreham 5993b3e846 Refactor: extract function to look up waiting channel for container 2016-05-06 12:45:03 +01:00
Matthias Radestock cf7ea357de Merge branch '1.5' 2016-05-06 11:21:57 +01:00
Matthias Radestock 4e48b956d9 Merge pull request #2250 from weaveworks/issues/2245-document-log-level
Document --log-level

Fixes #2245
2016-05-06 11:21:20 +01:00
Matthias Radestock 5b5d9d833a Merge pull request #2219 from weaveworks/export-wider
Document adding a route on non-Weave hosts
2016-05-06 11:20:27 +01:00
Bryan Boreham e16a4aa97a Document adding a route on non-Weave hosts 2016-05-06 11:13:15 +01:00
Bryan Boreham 12fa345d10 Punctuation 2016-05-06 11:10:34 +01:00
Matthias Radestock d2ea7e046d make clear that this repo is for Weave Net
...and make the links more relevant and 'active'
2016-05-06 10:55:29 +01:00
Matthias Radestock 1b50285609 add link to Weave Net product when first mentioning it
just as we do for scope and flux
2016-05-06 10:55:29 +01:00
Matthias Radestock 658c910862 fix typo 2016-05-06 10:55:29 +01:00
Anita Buehrle e1ab6a9035 removed installing heading 2016-05-06 10:55:29 +01:00
abuehrle 8c8709e527 added overview links to install 2016-05-06 10:55:29 +01:00
abuehrle d1e004dedc removed duplicate content added links to website 2016-05-06 10:55:29 +01:00
Matthias Radestock 8a827bebc8 Merge branch '1.5' 2016-05-05 17:56:57 +01:00
Matthias Radestock 4fc232be61 Merge pull request #2259 from weaveworks/issues/2214-fix-plugin-readme-links
Plugin README links refer to latest release docs

Fixes #2214.
2016-05-05 17:56:28 +01:00
Adam Harrison df2868fcdd Plugin README links refer to latest release docs 2016-05-05 16:32:53 +01:00
Matthias Radestock 32ba82efaf Merge branch '1.5' 2016-05-05 14:50:00 +01:00
Matthias Radestock b1aa52b3ed Merge pull request #2238 from weaveworks/missing-persist
Persist the IPAM ring on `weave reset` and `weave rmpeer`
2016-05-05 14:41:53 +01:00
Bryan Boreham 11c368531a Add --log-level to weave usage message, and document it and a couple of
other options on the proxy.
2016-05-05 12:44:40 +00:00
Matthias Radestock e389c8bb06 Merge branch '1.5' 2016-05-05 13:33:54 +01:00
Adam Harrison 608da90dc7 Publish doc previews for all branches, not just those named issues/* (#2258) 2016-05-05 13:33:28 +01:00
Matthias Radestock d3ddb71557 Merge branch '1.5' 2016-05-05 12:07:12 +01:00
Bryan Boreham fbb6e58b4f Add a section explaining WEAVE_MTU for fastdp (#2253)
Add a section explaining WEAVE_MTU for fastdp

Fixes #2198
2016-05-05 12:06:13 +01:00
Adam Harrison 34b95ee36f Merge branch '1.5' 2016-05-05 10:11:50 +01:00
Adam Harrison 1283ba4f61 Merge pull request #2249 from weaveworks/issues/2209-depersist-on-range-change
Better deleting of persisted IPAM data
2016-05-05 10:11:22 +01:00
Tom Wilkie a0982cb5e5 Merge pull request #2005 from weaveworks/sudo
Autodetect if we talk to docker via tcp in the Makefile
2016-05-05 10:05:56 +01:00
Tom Wilkie 0314a86e03 Autodetect if we talk to docker via tcp in the Makefile 2016-05-04 16:28:28 +01:00
Bryan Boreham d9d038ae35 Merge branch '1.5' 2016-05-04 15:38:33 +01:00
Bryan Boreham 87b61419f3 Move plugin arguments from separate doc into main plugin doc and add table of contents with sub-heading anchors 2016-05-04 14:44:10 +01:00
Adam Harrison 5fb6df5219 Merge branch '1.5' 2016-05-04 13:34:06 +01:00
Matthias Radestock b6647741b5 Merge pull request #2162 from weaveworks/issues/2034-log-rest-api
Add LogHandler for logging REST API calls at server side

Fixes #2034
2016-05-04 12:39:11 +01:00
Adam Harrison 0b4f9dbcf9 Merge pull request #2255 from weaveworks/issues/wordepress-stable-urls
Upgrade release branch doc publishing to wordepress 1.0.0
2016-05-04 11:59:22 +01:00
Martynas Pumputis 9644ed3f29 Merge pull request #2196 from weaveworks/issues/2194-claim-addr
Improve handling of `claim _`
2016-05-04 11:22:04 +01:00
Adam Harrison 1d52615452 Pin all branches to Wordepress 1.0.0 2016-05-04 11:07:12 +01:00
Adam Harrison 327a6f6d61 Upgrade to Wordepress 1.0.0
Release docs will now also be available with a stable 'latest' URL.
2016-05-04 11:01:07 +01:00
Adam Harrison 7aee9ebf84 Merge pull request #2254 from weaveworks/issues/wordepress-stable-urls
Upgrade to Wordepress 1.0.0
2016-05-04 10:56:34 +01:00
Adam Harrison 8f6087cfec Upgrade to Wordepress 1.0.0
Release docs will now also be available with a stable 'latest' URL.
2016-05-04 10:30:18 +01:00
Matthias Radestock 6022ad467a Merge branch '1.5' 2016-05-03 17:56:46 +01:00
Matthias Radestock 05652c0a3c Merge pull request #2252 from weaveworks/issues/2244-dns-noerror
Blank DNS response to AAAA queries where we have an A record

Fixes #2244.
2016-05-03 17:55:37 +01:00
Bryan Boreham 503546d2a9 Return DNS no-error with empty answer if we have a matching name
but the query is for a record type we don't support.
2016-05-03 17:33:51 +01:00
Bryan Boreham 3252a25e00 Broadcast initial ring after persisting it, in case we die between those operations 2016-05-03 17:23:00 +01:00
Bryan Boreham 6847a3551d Persist the ring in Shutdown() and AdminTakeoverRanges().
Also make AdminTakeoverRanges cause pending ops to be retried.
2016-05-03 17:23:00 +01:00
Bryan Boreham 70bd0ade45 Identifier "_" is address, not cidr 2016-05-03 15:47:45 +01:00
Martynas Pumputis 9dd1fbba39 Add LoggingHTTPHandler for logging REST requests at the server-side 2016-05-03 15:40:37 +01:00
Bryan Boreham 8405e0759a Clarify the function of the periodic ticker.
- it either retries for consensus or retries operations we would have tried previously.
There is no point retrying pending operations if we are waiting for consensus.
2016-05-03 15:13:20 +01:00
Adam Harrison bcc9a85e29 Merge remote-tracking branch 'origin/1.5' 2016-05-03 14:27:51 +01:00
Adam Harrison be3b0aa976 Merge pull request #2247 from weaveworks/pin-wordepress-version
Pin wordepress version used to publish site
2016-05-03 14:13:03 +01:00
Bryan Boreham 5ac8cc74d3 Refactor nested if-statements as switch 2016-05-03 13:52:36 +01:00
Adam Harrison 68e5ed575f Pin wordepress version
Use specific versions of wordepress for live and dev publishing
2016-05-03 13:47:37 +01:00
Bryan Boreham f6966548eb Delete persisted data when IPAM range changes 2016-05-03 13:20:04 +01:00
Bryan Boreham fb3ed9c1a6 Re-organise checking of persisted data so the failure paths bail out
of the function first.
Also bail out if there is no persisted ring, since persisted 'owned'
data isn't meaningful in that state.
2016-05-03 13:20:04 +01:00
Bryan Boreham 61fc5d56fb Refactor: move initialisation in the case that we don't use persisted data
out from loadPersistedData().
2016-05-03 13:20:04 +01:00
Bryan Boreham e96b68f0aa Don't use persisted data until we are sure it matches 2016-05-03 13:20:04 +01:00
Bryan Boreham bd23c79823 Merge branch '1.5' 2016-04-29 21:11:12 +01:00
Bryan Boreham 393fa3a333 Remove obsolete option and add --no-restart option 2016-04-29 19:49:21 +00:00
Bryan Boreham 27bdd3b4ad Revert "Log the error when something goes wrong requesting a claimed address"
This reverts commit 14bc1c987e.
2016-04-29 16:03:41 +01:00
Bryan Boreham 14bc1c987e Log the error when something goes wrong requesting a claimed address 2016-04-29 16:01:21 +01:00
Bryan Boreham fd7fcc762e Clarify the function of the periodic ticker.
- it either retries for consensus or retries operations we would have tried previously.
There is no point retrying pending operations if we are waiting for consensus.
2016-04-29 13:59:25 +01:00
Matthias Radestock 03afb54cdd remove cruft 2016-04-29 10:03:23 +01:00
Bryan Boreham 50e114863d Merge branch '1.5' 2016-04-28 09:40:04 +00:00
Bryan Boreham 9ce229ba3a Merge pull request #2202 from weaveworks/issues/1482-update-test320
Update test 320 to cope with persistence
2016-04-28 10:21:57 +01:00
Adam Harrison e6f031a3c9 Merge pull request #2218 from weaveworks/1.6-upgradeathon
Upgrade vendored libs
2016-04-28 10:13:44 +01:00
abuehrle 8b432a4d3e fixed broken links 2016-04-27 15:16:45 -05:00
Matthias Radestock 818f3e284b Merge branch '1.5' 2016-04-27 20:29:38 +01:00
Matthias Radestock 560f38330e Merge pull request #2230 from weaveworks/tweak-using-titles
Tweak titles under "Using Weave Net"
2016-04-27 20:17:04 +01:00
Matthias Radestock 5771ba15dd Merge branch '1.5' 2016-04-27 19:37:22 +01:00
abuehrle 9243bc2b0a fixed broken links 2016-04-27 13:25:32 -05:00
Matthias Radestock df5d6972e1 Tweak titles under "Using Weave Net"
- strip "Weave" and "Weave Net"
- "Integrating a Host Network with Weave" -> "Integrating with the
  Host Network"
- "Configuring Weave to Explicitly Use an IP Range" -> "Allocating IPs
  in a Specific Range"
2016-04-27 19:21:02 +01:00
Matthias Radestock 380cb9b0fc Merge pull request #2228 from weaveworks/tweak-using-sections
tweak 'Using Weave Net' section order
2016-04-27 18:50:14 +01:00
Matthias Radestock bd3b3791c6 tweak 'Using Weave Net' section order
- move "Managing Services in Weave Net" up so it comes after
  "Integrating a Host Network with Weave Net", to which it is deeply
  related
- move "Adding and Removing Hosts Dynamically" down so it is adjacent
  to the other sections which talk about peer connectivity
2016-04-27 18:37:28 +01:00
Matthias Radestock 77ced2ac55 Merge branch '1.5' 2016-04-27 18:25:23 +01:00
Matthias Radestock 7decce690a Merge pull request #2227 from weaveworks/2207-dedup-service-export-docs
dedup service export docs

Fixes #2207.
2016-04-27 17:31:34 +01:00
Matthias Radestock 65ecac6f1a cosmetic: consistency 2016-04-27 11:54:23 +01:00
Matthias Radestock 14a3898371 remove service-export doc since it duplicates content
...and update links accordingly.
2016-04-27 11:53:03 +01:00
Matthias Radestock c012650476 make service export section match whats in the separate doc 2016-04-27 11:48:56 +01:00
Adam Harrison d5fd62393f Merge branch '1.5' 2016-04-27 10:00:21 +01:00
Adam Harrison 789a6192f2 Merge pull request #2221 from weaveworks/issues/2216-fix-link
Fix broken link
2016-04-27 09:32:26 +01:00
Matthias Radestock 298fdc3d58 Merge branch '1.5' 2016-04-27 08:40:58 +01:00
Matthias Radestock 019a065d03 refactor: more logical question ordering 2016-04-27 08:40:07 +01:00
Matthias Radestock de1304d424 fix typo 2016-04-27 08:39:23 +01:00
Matthias Radestock ef915ca58f cosmetic: consistent formatting of FAQ questions 2016-04-27 08:36:25 +01:00
Matthias Radestock 72e134605c refactor: move pure code outside actor 2016-04-26 20:02:47 +01:00
Matthias Radestock 7cc2a1fe38 refactor: more descriptive function name 2016-04-26 17:33:04 +01:00
Adam Harrison 5de090999c Fix broken link 2016-04-26 17:29:34 +01:00
Adam Harrison 8ea5d999c2 Disable dry run mode 2016-04-26 17:29:26 +01:00
Adam Harrison 671dddf761 Merge pull request #2212 from weaveworks/issues/2114-wordepress-circleci
Incrementally publish 1.5 branch doc updates directly to live
2016-04-26 17:06:14 +01:00
Adam Harrison f4a117a8fc Enable dry run mode 2016-04-26 16:46:04 +01:00
Bryan Boreham 8fdbaf5745 Merge branch '1.5' 2016-04-26 15:43:12 +01:00
Bryan Boreham 0e655a2bbd Remove plugin-connected containers before end of test, to avoid delaying later cleanup.
Also use a shorter sequence to exclude the plugin when removing other containers.
2016-04-26 15:42:35 +01:00
Bryan Boreham 15054393fb Update profile package to latest version 2016-04-26 14:57:04 +01:00
Bryan Boreham f56d001703 Updated vendored libraries:
vendor/github.com/Sirupsen/logrus          to latest release 0.10.0
vendor/github.com/appc/cni                 to latest master
vendor/github.com/boltdb/bolt              to latest release 1.2.0
vendor/github.com/coreos/go-iptables       to latest release 0.1.0
vendor/github.com/fsouza/go-dockerclient   to latest master
vendor/github.com/docker/docker            to latest release 1.11.0
vendor/github.com/docker/libnetwork        to v0.7.0-dev.6 matching docker 1.11.0
vendor/github.com/docker/machine           to latest release v0.7.0
vendor/github.com/google/gopacket          to latest master
vendor/github.com/gorilla/context          to latest release 1.1
vendor/github.com/gorilla/mux              to latest release 1.1
vendor/github.com/hashicorp/go-cleanhttp   to latest master
vendor/github.com/miekg/dns                to latest master
vendor/github.com/opencontainers/runc      to latest release 0.1.0
vendor/github.com/stretchr/testify         unchanged at 1.1.3
vendor/github.com/vishvananda/netlink      to latest master
vendor/github.com/vishvananda/netns        to latest master
vendor/github.com/weaveworks/go-checkpoint unchanged; already at latest on master
vendor/github.com/weaveworks/go-odp        to latest master
vendor/github.com/weaveworks/mesh          to latest master
vendor/golang.org/x/crypto                 to latest master
2016-04-26 14:19:29 +01:00
Matthias Radestock 6ac248bfbf Merge branch '1.5' 2016-04-26 14:08:21 +01:00
Matthias Radestock a5739e8753 make plugin README link to other docs on github rather than website
until we have stable (non-version-specific) links for the latter.

Stop-gap for #2214.
2016-04-26 14:06:40 +01:00
Adam Harrison 79f2324d2b Update release process 2016-04-26 12:04:28 +01:00
Anita Buehrle c1a3ea925d Updated IPAM title and added punctuation 2016-04-26 10:10:41 +01:00
Adam Harrison 062c7a6fdc Minor doc fixes for incremental publish 2016-04-25 17:30:51 +01:00
Adam Harrison 6cc7f37dbb Publish /site from CI 2016-04-25 17:30:51 +01:00
Bryan Boreham 76601fed09 Fix up merge in unit test 2016-04-25 12:28:47 +01:00
Bryan Boreham 88a044f7f9 Merge pull request #2184 from weaveworks/2181-excessive-ring-frag
prevent excessive ring fragmentation due to repeated space requests. Fixes #2181
2016-04-25 11:54:12 +01:00
Matthias Radestock 03fcbbceb9 add CONTRIBUTING.md 2016-04-24 19:55:23 +01:00
Matthias Radestock cec88f154e Merge pull request #2205 from weaveworks/issues/2057-gc-nicknames
Add allocator.PeerGone

Fixes #2057
2016-04-22 17:42:43 +01:00
Martynas Pumputis 849edb1768 Add allocator.PeerGone
The function is registered within the mesh gc and it is responsible
for removing gone nicknames (#2057).
2016-04-22 17:29:27 +01:00
Bryan Boreham 981b78f680 Merge pull request #2203 from weaveworks/issues/2197-add-equals
Add equals sign to --dns arg, for consistency
2016-04-22 14:39:18 +01:00
Bryan Boreham ee75d91756 Merge branch '1.5' 2016-04-22 14:37:25 +01:00
Bryan Boreham d2450aae1c Merge pull request #2204 from weaveworks/issues/2193-dns-leak
Fixes #2123: Use ContainerID when restarting a container
2016-04-22 14:36:17 +01:00
Bryan Boreham b4f35f1d38 Add equals sign to --dns arg, for consistency 2016-04-22 11:16:58 +01:00
Matthias Radestock 9326775718 remove cruft 2016-04-21 18:59:28 +01:00
Bryan Boreham 76f9afb59c Removed errant spaces on bullets 2016-04-21 17:45:52 +01:00
Bryan Boreham 192fbe3a53 Update test 320 to cope with persistence 2016-04-21 16:19:59 +01:00
Martynas Pumputis 427b6d2902 Use ContainerID when restarting a container
Otherwise, we are risking to leak DNS entries which happens when
ContainerName is passed to `weave reset` and subsequent internal call
to nameserver creates a new entry instead of replacing the old one.
The ContainerID of the new entry is set to ContainerName and in such case
stopping the container will not remove the new entry.
2016-04-21 16:12:02 +01:00
Bryan Boreham 2f5a3f4513 Remove db-prefix now that persistence is in a volume 2016-04-21 14:32:45 +01:00
Bryan Boreham c984ec1e86 Fix port number in docs, and add to FAQ 2016-04-20 12:41:54 +01:00
Bryan Boreham 061d2b123f Add weavedb to the images pulled by 'weave setup' 2016-04-20 11:53:10 +01:00
Adam Harrison 07780fa10c Merge pull request #2188 from weaveworks/doc-improvements
Minor improvements to docs
2016-04-19 15:37:23 +01:00
Adam Harrison a6b7f0a9d4 Merge pull request #2185 from weaveworks/change-titles
Restructure docs
2016-04-19 15:34:53 +01:00
Bryan Boreham 5b72142aa3 Fix broken fastdp links 2016-04-19 15:21:49 +01:00
Bryan Boreham 476d2fee09 Update plugin docs for restarts 2016-04-19 15:09:53 +01:00
Bryan Boreham b95c559564 Document --no-restart 2016-04-19 15:09:31 +01:00
Bryan Boreham cfdba71f90 Document IPAM persistence
Remove statement that nothing is persisted in IPAM
2016-04-19 13:45:49 +01:00
Bryan Boreham 8ac90c693d Move video up, fix guide link and remove stray bracket 2016-04-19 13:45:21 +01:00
Bryan Boreham 74546578ac Move 'using weave' netcat example up a level 2016-04-19 13:45:21 +01:00
Bryan Boreham 88c6c17767 Minor improvements to docs 2016-04-19 13:38:10 +01:00
Bryan Boreham f5223d754a Add release v1.5.0 2016-04-19 12:03:44 +01:00
Bryan Boreham 278f7d8381 Move CNI up to top level 2016-04-18 18:15:32 +01:00
Adam Harrison 2dddc58754 Remove unnecessary title from building doc 2016-04-18 18:01:18 +01:00
Bryan Boreham d454e610f1 Move encryption out of top level 2016-04-18 18:00:09 +01:00
Bryan Boreham 4d06069138 Move IP Addressing overview under how-it-works and Configuring IP under Using Weave 2016-04-18 17:58:07 +01:00
Bryan Boreham 3f0a5d9e5d Move systemd page out of top level 2016-04-18 17:55:00 +01:00
Bryan Boreham 85bda72038 Move fastdp pages out of top level 2016-04-18 17:54:51 +01:00
Bryan Boreham 1c7df2958a Merge branch '1.4' 2016-04-18 17:15:37 +01:00
Bryan Boreham 302d412530 Merge pull request #2158 from weaveworks/issues/2147-dont-nat-cast
Add iptables rule excluding multicast from NAT on 'weave expose'
2016-04-18 17:14:29 +01:00
Bryan Boreham ca2e54c361 Renamed 'router-topology' to 'how-it-works' 2016-04-18 16:53:39 +01:00
Adam Harrison b9706e456a Strip erroneous extra backtick from code fences 2016-04-18 15:10:37 +01:00
Adam Harrison e1478eefd4 Remove language spec from code fences 2016-04-18 15:10:37 +01:00
Adam Harrison 3a2452baf6 Style FAQ questions with emphasis 2016-04-18 15:10:37 +01:00
Adam Harrison 82c9a88aa2 Update titles and menu order 2016-04-18 15:10:37 +01:00
Adam Harrison 7ef007bbf5 Copy linked screencast image into /site 2016-04-18 14:26:42 +01:00
Bryan Boreham d32fc495c8 Merge branch '1.4' 2016-04-18 14:08:04 +01:00
Bryan Boreham d3635eed77 Need to mock-gossip from the end of the chain 2016-04-18 14:06:38 +01:00
Adam Harrison a16b48d8f3 Restore submodule dependency broken by f3dbebd467 2016-04-18 13:04:21 +01:00
Adam Harrison 6ad9dac71a Merge pull request #2165 from weaveworks/issues/2164-less-deleting
Store 'checkAlive' flag in IPAM, so we don't delete non-container IDs
2016-04-18 11:49:50 +01:00
Adam Harrison a921f77258 Merge pull request #2172 from weaveworks/disable-peer-persistence
Disable persistence of peer lists
2016-04-18 11:48:46 +01:00
Bryan Boreham 8253d17529 Merge branch '1.4' 2016-04-18 10:58:39 +01:00
Bryan Boreham d3be3d8912 Remove outdated comment 2016-04-18 10:53:55 +01:00
Bryan Boreham a6e0226189 Merge pull request #2182 from weaveworks/2180-test-transfer-1.4
fix simulation of periodic gossip in TestTransfer
2016-04-18 10:52:28 +01:00
Adam Harrison f3dbebd467 Remove obsolete Jekyll raw directives 2016-04-18 10:36:43 +01:00
Bryan Boreham b7b9322e33 Merge pull request #2178 from weaveworks/2177-multiweave-persistence
name db container after weave container
2016-04-18 10:31:09 +01:00
Bryan Boreham 5e4ab7f307 Plumb isContainer through Claim calls 2016-04-18 10:16:54 +01:00
Bryan Boreham 2b159b0c75 Pass checkAlive flag through as isContainer in Allocate 2016-04-18 10:16:54 +01:00
Bryan Boreham 984ba8a377 Extend 'owned' structure to store IsContainer flag 2016-04-18 10:13:09 +01:00
Bryan Boreham 01be916c37 Add test to expose problem deleting non-container IPs
and check dead containers are removed
2016-04-18 10:13:09 +01:00
Matthias Radestock c1d98ba59c refactor: extract a helper 2016-04-17 12:40:34 +01:00
Matthias Radestock a1823af745 refactor: make error returns less onerous 2016-04-17 12:40:34 +01:00
Matthias Radestock 4a01d23025 refactor: extract entry merging from ring merging 2016-04-17 12:40:34 +01:00
Matthias Radestock 27632b118f prevent excessive ring fragmentation due to repeated space requests
Merging a ring now indicates whether the ring has been updated. This
prevents excessive allocation retries, which in turn can result in
repeated space requests - i.e. if an allocation cannot proceed due to
lack of space - which in turn can result in excessive ring
fragmentation since many of the requests will result in the creation
of a new ring entries, due to the need to split ranges.

Fixes #2181.
2016-04-17 12:40:18 +01:00
Matthias Radestock 0e54de63cc cosmetic 2016-04-17 09:33:52 +01:00
Matthias Radestock c0c5906d07 fix simulation of periodic gossip in TestTransfer
`GossipBroadcast` in the `TestRouter` only goes one hop. In
`TestTransfer` the three peers are connected in a chain, and hence we
need to take extra care to ensure propagation to all peers.

Fixes #2180.
2016-04-16 10:11:06 +01:00
Matthias Radestock f6f4ee708a Merge remote-tracking branch 'upstream/master' 2016-04-16 09:13:44 +01:00
Matthias Radestock 8f54f83285 refactor: align test allocator names with indices
for easier debugging
2016-04-16 09:12:49 +01:00
Matthias Radestock e393b4aaa6 name db container after weave container
...so that we can start multiple weaves on a machine w/o them sharing
a single db container and tripping over each other as a result.

Unbreaks multiweave.

Fixes #2177
2016-04-16 03:09:45 +01:00
Anita Buehrle 8822aa4ece fixed link and formatting 2016-04-15 17:03:54 -05:00
Anita Buehrle 3e83897752 fixed a link 2016-04-15 16:21:57 -05:00
Anita Buehrle 1d7cdfae5d moved full stop 2016-04-15 16:16:46 -05:00
Anita Buehrle 0e71b7c01d moved full stop 2016-04-15 16:15:14 -05:00
Anita Buehrle 3c8bff70df moved full stop to outside of link 2016-04-15 16:13:17 -05:00
Anita Buehrle 6de0c06ada missing link and punctuation 2016-04-15 15:54:25 -05:00
Anita Buehrle 4ede0ac923 fixed up missing punctuation 2016-04-15 15:50:34 -05:00
Anita Buehrle fa3f1b277f removed bash formatting 2016-04-15 15:42:13 -05:00
Anita Buehrle 5ade5cca03 fixed links and formatting 2016-04-15 15:38:25 -05:00
Anita Buehrle 99a5b4aed3 fixed links and formatting 2016-04-15 15:36:55 -05:00
Anita Buehrle 07026bc7a9 removed bash formatting 2016-04-15 15:30:45 -05:00
Anita Buehrle 0ed9694199 fixed broken links and added missing punctuation 2016-04-15 15:28:43 -05:00
Bryan Boreham 098be788ae Merge pull request #2166 from weaveworks/optional-restart-policy
Optional restart policy
2016-04-15 17:45:54 +01:00
Adam Harrison c6609bd248 Smoke test --no-restart 2016-04-15 15:04:29 +01:00
Adam Harrison cadc3869b3 Launch observes --no-restart 2016-04-15 15:04:29 +01:00
Bryan Boreham 4669da6074 Disable persistence of peer lists 2016-04-15 14:49:50 +01:00
Matthias Radestock 439c9143af Merge pull request #2173 from weaveworks/reword-ipam-status
Improve IPAM status wording
2016-04-15 14:00:30 +01:00
Adam Harrison b9340ada3e Improve IPAM status wording 2016-04-15 13:39:55 +01:00
Adam Harrison 88e2761b18 Improve wording 2016-04-15 09:53:33 +01:00
Bryan Boreham 02516361c7 Merge pull request #2155 from weaveworks/issues/2065-rationalise-ipam-concepts
Rationalise IPAM concepts
2016-04-14 17:33:27 +01:00
Adam Harrison 31ca8f9dbf Merge pull request #2135 from weaveworks/issues/2031-persistence-volume
Use a data volume container for persistence of IPAM etc.
2016-04-14 13:21:22 +01:00
Adam Harrison a657e25a81 Update documentation 2016-04-14 12:46:04 +01:00
Adam Harrison e355e50c0d Tests prefer --ipalloc-init 2016-04-14 12:46:03 +01:00
Adam Harrison af8f590646 Deprecate --init-peer-count 2016-04-14 12:46:03 +01:00
Adam Harrison c3ecbc9d48 Implement unified --ipalloc-init parameter 2016-04-14 12:46:03 +01:00
Adam Harrison a09986baa2 Rename consense -> prime 2016-04-14 12:46:03 +01:00
Matthias Radestock e9ca0ffad1 Merge remote-tracking branch 'upstream/master' 2016-04-13 19:48:33 +01:00
Matthias Radestock aed6fd3fcc eliminate pcap cruft from docs
Fixes #2159
Fixes #1908
2016-04-13 19:47:33 +01:00
Matthias Radestock e77b2ae288 make clear that documented encapsulation is for sleeve 2016-04-13 19:46:53 +01:00
Matthias Radestock 828e5ba0b8 clearer reference to 'sleeve' in fastdp intro 2016-04-13 19:45:35 +01:00
Bryan Boreham 0eee97b988 Use regular persistence settings in test, since they now survive a restart 2016-04-13 16:08:41 +01:00
Bryan Boreham 358342aa4f Use a data volume container for BoltDB files.
We provide a very small image to use for this container.
Also we add an empty weavedata.db file to weave image so it doesn't crash when run without volume override
2016-04-13 16:07:55 +01:00
Bryan Boreham 6b08f97910 Merge pull request #2131 from weaveworks/issues/2089-vsn-check
2089: Add info about new available versions to the `weave status` report
2016-04-13 12:20:57 +01:00
Bryan Boreham 045edcca2f Add iptables rule excluding multicast from NAT on 'weave expose' 2016-04-13 12:05:24 +01:00
Matthias Radestock b4050276a9 Merge pull request #2154 from weaveworks/issues/2153-lock-testrouter
Lock round TestRouter map accesses

Fixes #2153
2016-04-13 07:51:22 +01:00
Bryan Boreham 6639353568 Lock round TestRouter map accesses, and copy the set where we may block. 2016-04-13 07:49:53 +01:00
Martynas Pumputis 928a693491 Extend version summary in the weave status report
The extended version summary includes info about a new available
version in the case the checkpoint is enabled.
2016-04-12 22:32:18 +01:00
Matthias Radestock f08148cabb proper systemd override for docker in test VMs
now you can

- run `vagrant provision` any time
- upgrade the base image with `vagrant box update`
- upgrade docker inside the VM w/o
...etc...

...without breaking things!
2016-04-12 11:22:32 +01:00
Matthias Radestock d1ca38e106 Merge pull request #2148 from weaveworks/issues/2146-cni-sock
Bind-mount the docker socket for CNI plugin

Fixes #2146
2016-04-11 16:03:14 +01:00
Bryan Boreham 15bdf6cd2d Rework CNI test so it uses the scriptlet 2016-04-11 16:00:49 +01:00
Matthias Radestock 4037c763c2 Merge branch '1.4' 2016-04-11 15:40:32 +01:00
Matthias Radestock d4fb739981 Merge pull request #2151 from weaveworks/issues/2140-fqdn-trailing-dot
Remove trailing dot from FQDN

Fixes #2140
2016-04-11 15:39:48 +01:00
Bryan Boreham 4bd6de5995 Extract out CNI setup so we can call it from a test 2016-04-11 15:28:11 +01:00
Bryan Boreham 61b0d0ba9e Merge pull request #2149 from weaveworks/stop-test-router
stop ipam tests from leaking routers
2016-04-11 13:34:21 +01:00
Matthias Radestock 56bfe15eca Merge pull request #2150 from weaveworks/issues/2139-zero-quorum
Don't try to form IPAM ring with a bogus quorum size

Fixes #2139.
2016-04-11 13:31:09 +01:00
Bryan Boreham c10d26cf02 Fix up TestBootstrap after consensus changes 2016-04-11 13:20:54 +01:00
Matthias Radestock 695babf7ba make Allocator.Stop() idempotent and non-blocking
So that tests don't have to be careful about ensuring that allocators
are stopped exactly once, or rely on the magic mesh.ChannelSize for
non-blocking behaviour.
2016-04-11 12:32:01 +01:00
Bryan Boreham ecf1887e5b Initialize Paxos quorum to 0 until this node needs to request consensus.
With a 0 quorum we will participate in voting, but will not actively
try to form a ring.
2016-04-11 11:42:24 +01:00
Bryan Boreham c6e8f54fe7 Add CNI plugin to description 2016-04-11 11:31:25 +01:00
Martynas Pumputis a4062bd15c Remove trailing dot from FQDN
As it is described in #2140, the trailing dot might appear
when starting a container via "weave run".
2016-04-11 11:17:36 +01:00
Matthias Radestock 4d352d6eb1 stop router created by makeNetworkOfAllocators
so that unit tests don't leave garbage behind
2016-04-10 11:22:57 +01:00
Bryan Boreham 737b0e0504 Two different configs; ensure weave-ipam driver works when named 2016-04-08 17:59:23 +01:00
Bryan Boreham 16e5032528 Merge branch '1.4' 2016-04-08 17:48:33 +01:00
Bryan Boreham 26bd1b5787 Specify /dev/null stdin for netcat, to avoid inconsistency in Docker 1.11 2016-04-08 17:48:08 +01:00
Bryan Boreham 13f3ff15bd Sanity-check ipam args to make diagnosis easier 2016-04-08 15:18:08 +01:00
Bryan Boreham e88e67f02c Bind-mount docker socket for CNI plugin scripts 2016-04-08 15:16:54 +01:00
Adam Harrison 9c7b27acf0 Merge pull request #2134 from weaveworks/issues/2063-observer-status
Better log and status messages for Paxos observer
2016-04-08 10:11:46 +01:00
Bryan Boreham aad5b4dd7e Document observer status 2016-04-07 13:16:15 +01:00
Bryan Boreham c12a52d20e Better log and status messages for Paxos observer 2016-04-07 12:50:52 +01:00
Bryan Boreham 0c59de40e7 Refactor Paxos status call to remove type assertion 2016-04-07 12:12:08 +01:00
Adam Harrison a897a7711c Merge pull request #2115 from weaveworks/issues/2114-docs-in-wordpress
Restructure `/site` to conform to Wordepress requirements
2016-04-07 11:22:40 +01:00
Adam Harrison fb8167c6f1 Fix broken link 2016-04-07 11:04:35 +01:00
Adam Harrison 0482d0716f Fix broken links 2016-04-07 10:56:56 +01:00
Adam Harrison f183cb491f Adjust section links 2016-04-07 10:51:47 +01:00
Adam Harrison 80770cc96e Restructure docs 2016-04-07 10:37:57 +01:00
Adam Harrison 21d061fa44 Remove Jekyll/Travis config 2016-04-07 10:36:10 +01:00
Matthias Radestock 7d27df0907 Merge pull request #2133 from weaveworks/issues/2081-broadcast-dns-overrides
Immediately broadcast DNS records that "re-assert a peer's authority"
2016-04-06 14:51:22 +01:00
Bryan Boreham 768e2a31fa Re-hide output coming from stop, since it's generally uninteresting 2016-04-06 13:54:12 +01:00
Bryan Boreham 487392b99c Immediately broadcast DNS records that "re-assert a peer's authority"
and enable test to check.
2016-04-06 13:35:07 +01:00
Matthias Radestock 50af75972a Merge pull request #2122 from weaveworks/issues/2081-gossip-to-restarted-peer
Update weaveworks/mesh to send gossip to restarted peer

Fixes #2085.
2016-04-06 12:01:38 +01:00
Matthias Radestock 88518ba278 Merge pull request #2130 from weaveworks/issues/2108-reboot-docs
Update reboot docs

Fixes #2108.
2016-04-06 10:30:38 +01:00
Bryan Boreham a83359da7d Update reboots section now we have --restart=always 2016-04-06 10:29:53 +01:00
Bryan Boreham 9c4b4ca35f Remove recursive link 2016-04-06 10:02:57 +01:00
Matthias Radestock 2e31087818 dump state on paxos test failure
to help diagnosis of #2132 and similar problems
2016-04-06 08:55:49 +01:00
Matthias Radestock 11e520e212 Merge pull request #2129 from weaveworks/fix-cov-collection
Do not fail during teardown of test suites if $COVERAGE is not set
2016-04-05 22:17:40 +01:00
Matthias Radestock 3254870899 cosmetic: tweak proxy intro to make more sense 2016-04-05 21:38:10 +01:00
Matthias Radestock 51210045f7 =1 is better than =true
though they both do the same thing
2016-04-05 20:16:15 +01:00
Matthias Radestock 9e6ae4422e tweak checkpoint description 2016-04-05 20:02:46 +01:00
Matthias Radestock ce431dd73f Merge pull request #2096 from weaveworks/issues/2052-http-errors
Report errors when weave script talks to weave component via http

Fixes #2052.
2016-04-05 19:35:01 +01:00
Bryan Boreham 934ec2467d Eliminate race from call_weave; call check_running only after curl fails 2016-04-05 17:54:18 +01:00
Bryan Boreham ff4d0dae70 Keep going if an IPAM claim errors 2016-04-05 17:54:18 +01:00
Matthias Radestock bac3d65ede refactor: use a 'case' for greater clarity 2016-04-05 17:54:18 +01:00
Bryan Boreham ecb180c0c5 Ignore 404 from IP address claim when IPAM is disabled 2016-04-05 17:54:18 +01:00
Bryan Boreham f01d91459b Make http_call send error messages to stderr and return error codes,
and fix up all uses of this function.
2016-04-05 17:54:18 +01:00
Matthias Radestock 3e07f03c87 Merge branch '1.4' 2016-04-05 17:26:01 +01:00
Matthias Radestock 28e0b14220 Merge pull request #2128 from weaveworks/issues/2109-skip-empty-json
Don't attempt to parse JSON payload if it is 0 bytes long.

Fixes #2109.
2016-04-05 17:24:37 +01:00
Matthias Radestock f82ef55c67 Merge branch '1.4' 2016-04-05 17:21:09 +01:00
Matthias Radestock 53ba2f0aff rename test so it actually gets run 2016-04-05 17:07:07 +01:00
Matthias Radestock 45b36b378d Merge branch '1.4' 2016-04-05 16:57:47 +01:00
Martynas Pumputis 41a5c6f523 Do not fail if $COVERAGE is not set
Also, stop weave in end_suite by using `weave stop` which does not
remove the weave container (#1939).
2016-04-05 16:53:01 +01:00
Matthias Radestock 4f1d87f893 Merge pull request #2126 from weaveworks/2090-delay-start
Delay notifying observers about 'start' events

Fixes #2090. Partially addresses #1775.
2016-04-05 16:48:20 +01:00
Bryan Boreham 66c92fe075 Don't attempt to parse JSON payload if it is 0 bytes long.
Also added a test to trigger this.
2016-04-05 16:47:11 +01:00
Bryan Boreham ebc5dcb4bb Delay notifying observers about 'start' events
...until the container has a pid, or we see the same container die.
This is to work around https://github.com/docker/docker/issues/18574

Fixes #2090. Partially addresses #1775.
2016-04-05 16:20:07 +01:00
Bryan Boreham afff92c248 Merge pull request #2124 from weaveworks/idempotent-tombstone
make DNS tombstoning idempotent
2016-04-05 17:15:53 +02:00
Matthias Radestock ead3518b4b make DNS tombstoning idempotent
so we avoid the unnecessary gossip, and delayed convergence, that
otherwise ensues.
2016-04-04 20:34:01 +01:00
Bryan Boreham c38dcb1d73 Adapt to logging changes in weaveworks/mesh 2016-04-04 16:01:58 +01:00
Bryan Boreham 00fe47ba62 Update weaveworks/mesh to send gossip to restarted peer 2016-04-04 15:29:36 +01:00
Bryan Boreham b7d49cdeb7 Merge pull request #2117 from weaveworks/2113-wait-for-dp
wait for datapath device to be ready
2016-04-01 12:13:21 +02:00
Matthias Radestock 495a35a6a6 work around fd re-use bug in vishvananda/netlink
Closing a subscription can cause the associated fd to be re-used while
the subscription goroutine is also still trying to use it. Which can
have disastrous consequences.

So as a work around we don't close subscriptions. This means we leak
an fd, some buffer space, and goroutine. The latter will eventually
block in a channel send of a subscription event, since nothing is left
reading ont the other end. So at least it won't be consuming cycles.
2016-04-01 11:07:19 +01:00
Bryan Boreham 9f13d28508 Merge pull request #2116 from weaveworks/plugin-coverage
add coverage to plugin
2016-04-01 12:01:25 +02:00
Matthias Radestock de4cc0ad54 eradicate last remaining wEaVeDnS misspellings 2016-03-31 06:39:41 +01:00
Anita Buehrle 7f4c527fc5 Merge pull request #2118 from weaveworks/weaveDNS-fix
fixes #2102
2016-03-30 17:02:04 -06:00
Anita Buehrle 8a305ee189 fixes #2102 2016-03-30 17:05:26 -06:00
Matthias Radestock 718e93bd23 add coverage to plugin 2016-03-30 17:40:32 +01:00
Matthias Radestock 254be128b0 cosmetic: consistency 2016-03-30 16:25:26 +01:00
Matthias Radestock 2c49cd1e0a refactor: s/DOCKERPLUGIN/PLUGIN
since it's also a CNI plugin now
2016-03-30 15:43:55 +01:00
Matthias Radestock ec167554c5 refactor: consistent order 2016-03-30 14:13:41 +01:00
Matthias Radestock f24f38be9c refactor: get rid of a superfluous fastdp member 2016-03-30 14:10:03 +01:00
Matthias Radestock 0f89f8562f refactor(ish): parameterise dp creation by iface, not name 2016-03-30 14:07:33 +01:00
Matthias Radestock 8eb52538de wait for datapath device
so that when the router container restarts after a reboot it waits for
the proxy to create the datapath device.

Fixes #2113
2016-03-30 14:01:57 +01:00
Matthias Radestock 90629bc6d3 add another cross reference. 2016-03-30 00:03:55 +01:00
Matthias Radestock c6fea4939e fix broken link 2016-03-30 00:02:30 +01:00
Anita Buehrle 0597162189 Merge pull request #2111 from weaveworks/app-isolation-fix
sorted out isolated apps files
2016-03-29 16:42:29 -06:00
Anita Buehrle 74e7d383c9 sorted out isolated apps files 2016-03-29 16:45:20 -06:00
Adam Harrison 051320e73c Merge branch '1.4' 2016-03-29 11:45:24 +01:00
Adam Harrison 6e04ccf677 Merge pull request #2101 from weaveworks/2099-no-dns
make `weave dns-args` and `weave run` work with `--no-dns`
2016-03-29 11:44:12 +01:00
Adam Harrison 436dc01f52 Merge pull request #2070 from weaveworks/issues/1721-quorum-callback
Use current target list to compute quorum
2016-03-29 11:11:30 +01:00
Adam Harrison a6bb02aca1 Merge pull request #2106 from weaveworks/patch-up-2103
Patch up #2103
2016-03-29 10:37:04 +01:00
Matthias Radestock ec5008c702 remove "quote of quote" 2016-03-29 10:31:36 +01:00
Matthias Radestock 3453972ac4 banish ~~~bash
Just use indenting, which is much easier on the eye.
2016-03-29 10:30:51 +01:00
Adam Harrison 7c37cd98dd Merge pull request #2074 from weaveworks/cleanup-plugin-logging
clean up plugin logging
2016-03-29 10:02:21 +01:00
Matthias Radestock a1eb940c51 restore ellipses around weave status output fragments 2016-03-29 05:40:50 +01:00
Matthias Radestock bd6359dcb1 Merge branch '1.4' 2016-03-29 05:38:35 +01:00
Matthias Radestock cc75b084d8 Merge branch 'latest_release_doc_updates' into 1.4 2016-03-29 05:36:59 +01:00
Matthias Radestock bd9314939b correct weave status proxy output 2016-03-29 05:36:11 +01:00
Anita Buehrle 2298927331 Merge pull request #2103 from weaveworks/spellcheck
fixed formatting for wp  and spellcheck
2016-03-28 16:27:24 -06:00
Anita Buehrle b3b93b28df fixed formatting for wp and spellcheck 2016-03-28 16:30:33 -06:00
Matthias Radestock d68c1a8187 correct tools submodule reference
This got broken in 18f678a3c8
2016-03-28 18:09:08 +01:00
Matthias Radestock 06a525456d remove bogus link 2016-03-28 17:59:16 +01:00
Matthias Radestock 9d19676ef1 cosmetic(ish): add reference to crypto overview from implementation 2016-03-28 17:58:43 +01:00
Matthias Radestock 540b55a35c cosmetic(ish): add some references to crypto docs 2016-03-28 17:53:41 +01:00
Matthias Radestock 2f435cfcce fix/add links to examples when referring to them 2016-03-28 17:44:43 +01:00
Matthias Radestock 18f678a3c8 Merge branch '1.4' 2016-03-28 17:32:22 +01:00
Matthias Radestock cc06a2d8ab Merge branch 'latest_release_doc_updates' into 1.4 2016-03-28 17:24:51 +01:00
Matthias Radestock 1dd2cdf7a9 fix dns load balancing example 2016-03-28 17:24:08 +01:00
Matthias Radestock 5944f069b6 cosmetic: quoting consistency 2016-03-28 16:55:19 +01:00
Matthias Radestock aade206f22 cosmetic(ish): ungarble example 2016-03-28 16:53:07 +01:00
Matthias Radestock 22c3582699 cosmetic: tweak example links 2016-03-28 16:27:21 +01:00
Matthias Radestock 2948deb210 cosmetic: tweak link 2016-03-28 16:25:12 +01:00
Matthias Radestock db9139a0cd correct weave attach example 2016-03-28 16:03:20 +01:00
Matthias Radestock bbcbb5f7b8 fix more doc typos 2016-03-28 15:56:27 +01:00
Matthias Radestock 1a872f3895 fix a bunch of typos 2016-03-28 15:45:05 +01:00
Matthias Radestock 095d7e54c3 fix typo 2016-03-28 15:24:17 +01:00
Matthias Radestock b2a484d5f0 refactor: inline 2016-03-28 14:17:54 +01:00
Matthias Radestock 8472272afe refactor(ish): bail early if weaveDNS is disabled 2016-03-28 14:10:31 +01:00
Matthias Radestock 648632d5ac add a test for working with --no-dns 2016-03-28 14:07:48 +01:00
Matthias Radestock ea3456756d make weave dns-args and weave run work with --no-dns
...rather than exploding

i.e. the former returns nothing and the latter leaves naming related
container settings untouched, just like happens in the proxy and
plugin.

Fixes #2099.
2016-03-28 14:04:07 +01:00
Matthias Radestock 0672a0858f Merge branch '1.4' 2016-03-28 12:52:31 +01:00
Matthias Radestock a1381fe0cf add --no-dns to usage
Closes #1687.
2016-03-28 12:49:31 +01:00
Matthias Radestock 3baf8058ed Merge branch 'latest_release_doc_updates' into 1.4 2016-03-28 12:48:36 +01:00
Matthias Radestock daf92d8e08 document --no-dns
Part of #1687.
2016-03-28 12:46:58 +01:00
Matthias Radestock c91b2c2907 Merge remote-tracking branch 'upstream/master' 2016-03-28 11:37:24 +01:00
Matthias Radestock 6e0aea233b Merge branch '1.4' 2016-03-28 11:36:18 +01:00
Matthias Radestock abd138026b cosmetic: identation 2016-03-28 11:10:36 +01:00
kpoplin 3b9847d5d9 Update README.md
Updated the "About Weaveworks" section to differentiate between our overall mission and a Weave Net-specific overview; also included brief descriptions of Weave Scope and Weave Flux. Corrected product names missed in last update.
2016-03-27 07:25:14 -07:00
kpoplin c4ec25bb14 Update README.md
Updated for consistent pronoun usage; corrected product and company references, following our standardized naming conventions; fixed other minor grammatical errors.
2016-03-27 06:49:28 -07:00
Matthias Radestock 0109bf0ac7 tiny refactor: make function & const name more meaningful 2016-03-26 21:23:23 +00:00
Matthias Radestock 4482d307bf tweak ipam plugin logging
- log requests at info  level instead of debug level
- log errors   at error level instead of debug level
2016-03-24 18:52:55 +00:00
Matthias Radestock 5aa2a7a14c refactor(ish) of ipam plugin logging
prefix all log entries with "[ipam]"

Also eliminate a dot import.
2016-03-24 18:52:55 +00:00
Matthias Radestock 984cad5b58 clean up network plugin logging
Consistency, consistency, consistency:

- prefix all log messages with "[net]" - important since the same
  process acts as both a network and ipam driver
- include the API function name in all log messages
- log request and response details at debug level
- log request summary at info level
- log ContainerStarted as a pseudo API function, but only at debug
  level (since it can be quite high volume)

And eliminate some dot imports.
2016-03-24 18:52:44 +00:00
Matthias Radestock de8c1d262f don't error log in 'createAndAttach'
It is a library function, so logging of any errors should be left to
the caller.

We also get rid of a logged warning which contained the complete data
structure returned by netlink.LinkByName.

So this function now does no logging at all. Which is how it should be.
2016-03-24 18:52:07 +00:00
Matthias Radestock 2d964bdc95 don't log in cni; just return errors
CNI is invoked from the command line; so there is no point in getting
clever about logging.
2016-03-24 18:51:34 +00:00
Matthias Radestock 91044ac0fa cosmetic: consistency 2016-03-24 18:51:08 +00:00
Matthias Radestock 98aeb674c4 cosmetic: more plugin error message/logging tweaks 2016-03-24 18:41:47 +00:00
Matthias Radestock ea11c5eedc cosmetic: some error logging message tweaks 2016-03-24 18:16:57 +00:00
Matthias Radestock c146ee142d Merge branch '1.4' 2016-03-24 17:26:00 +00:00
Bryan Boreham 88d115aab1 Merge pull request #2098 from weaveworks/2097-fail-on-attach-errors
fail plugin operation on bridge attachment error
2016-03-24 17:16:55 +00:00
Matthias Radestock fce954192c fail plugin operation on bridge attachment error
Fixes #2097.
2016-03-24 17:01:15 +00:00
Bryan Boreham aab86c38b7 Merge pull request #2093 from weaveworks/tools
Update tools to get misspell integration. Aho-Corasick FTW!
2016-03-24 14:09:45 +00:00
Bryan Boreham adc038d8d1 Merge pull request #2095 from berlic/berlic-plugin-docker-args
Support custom docker args for weave-plugin
2016-03-24 12:53:10 +00:00
Bryan Boreham cfa9b4f638 Assert that paxos quorum is set 2016-03-24 12:06:59 +00:00
Bryan Boreham e6fd970920 Exclude retry-never peers from quorum
Note: includes update to latest version of weaveworks/mesh library.
2016-03-24 12:06:59 +00:00
Bryan Boreham ad0a5477f9 Reverse order of 'start' and 'connect' in test so we don't hang waiting for consensus 2016-03-24 12:06:59 +00:00
Bryan Boreham 2b617633ae Compute quorum based on the dynamic number of target peers 2016-03-24 12:06:59 +00:00
Adam Harrison 7776e48a62 Merge branch '1.4' 2016-03-23 18:00:38 +00:00
Adam Harrison 6c0075ab82 Add release v1.4.6 2016-03-23 17:37:21 +00:00
Matthias Radestock 48534b1e30 unbreak tests
Broken in an attempt to help with #2090.
2016-03-23 17:22:40 +00:00
Matthias Radestock 8b6c5bdae4 unbreak things 2016-03-23 17:05:19 +00:00
Matthias Radestock b8abb22833 Merge branch '1.4' 2016-03-23 16:39:17 +00:00
Matthias Radestock ae0a4fef50 Merge pull request #2092 from weaveworks/issues/2083-error-not-panic
Change invariant fail on Merge() from panic to error

Fixes #2083.
2016-03-23 16:38:52 +00:00
Matthias Radestock 4dcec8265d Merge branch '1.4'
(but really replace all the changes, which were in 'mesh', with
vendoring the latest mesh)
2016-03-23 16:30:28 +00:00
Matthias Radestock 8360024e06 Merge pull request #2088 from weaveworks/issues/2087-leave-direct-targets
Don't delete targets that seem invalid if they are 'direct' targets

Fixes #2087.
2016-03-23 16:22:08 +00:00
Tom Wilkie 7a7867ae16 Fix spelling mistakes. 2016-03-23 16:09:43 +00:00
Tom Wilkie 43f8d073db Update tools for misspell. 2016-03-23 16:05:13 +00:00
Bryan Boreham 2e4d56efd6 Suspend connecting to targets that seem invalid, if they are 'direct' targets.
Introduce TargetSuspended state to reflect this.
2016-03-23 15:36:55 +00:00
Bryan Boreham 6bc199a8bc Change invariant fail on Merge() from panic to error 2016-03-23 15:26:26 +00:00
Konstantin Suvorov ad42f27e03 Support custom docker args for weave-plugin
WEAVEPLUGIN_DOCKER_ARGS environment variable is used to pass custom args when creating plugin container
2016-03-23 16:20:06 +03:00
Matthias Radestock c75cadf007 more correct sudo scoping
we want to know whether systemctl can be run when sudoing.

This shouldn't fix #2090, only give is a different error.
2016-03-23 13:00:04 +00:00
Matthias Radestock b080224072 Merge branch '1.4' 2016-03-22 16:28:53 +00:00
Matthias Radestock 537868008f make linter happy 2016-03-22 16:28:25 +00:00
Matthias Radestock 63a9f879fb Merge branch '1.4' 2016-03-22 14:13:24 +00:00
Matthias Radestock 1664fce9d1 Merge pull request #2081 from weaveworks/issues/2023-override-stale-dns
Override stale dns entries received via gossip

Fixes #1867 and #2023.
2016-03-22 13:47:17 +00:00
Bryan Boreham c2cf825cdf Smoke test for stale DNS entries 2016-03-22 12:57:07 +00:00
Bryan Boreham 38a79b7f59 Pick entry with newer tombstone to merge 2016-03-22 12:57:07 +00:00
Bryan Boreham 010766fe9e Check entries claiming to originate from us against our current data, and override if necessary 2016-03-22 12:57:07 +00:00
Adam Harrison c09dfe6b5a Merge pull request #2078 from weaveworks/reify-ipam-config
Reify ipam config
2016-03-21 16:12:11 +00:00
Matthias Radestock d177bb8a47 Merge remote-tracking branch 'upstream/master' 2016-03-21 16:00:19 +00:00
Adam Harrison a26dd1b1d7 Merge pull request #2072 from weaveworks/2071-ci-coverage-underreporting
collect coverage data from ci nodes before teardown
2016-03-21 15:58:03 +00:00
Matthias Radestock 34de08d649 Merge branch '1.4' 2016-03-21 15:56:56 +00:00
Adam Harrison 74d0b3b51e Merge pull request #2075 from weaveworks/2044-multi-rmpeer
make `weave rmpeer` accept a list of peers
2016-03-21 15:55:22 +00:00
Matthias Radestock 6b33f4215b Merge branch 'latest_release_doc_updates' into 1.4 2016-03-21 15:53:18 +00:00
Matthias Radestock cc43782d87 Merge pull request #2080 from weaveworks/issues/2061-correct-weave-status
Correct IPAM state docs

Fixes #2061.
2016-03-21 15:49:03 +00:00
Adam Harrison c2eb900dd3 Correct IPAM state docs 2016-03-21 15:33:37 +00:00
Matthias Radestock 915a72ad18 add a check for "--ipalloc-default-subnet requires --ipalloc-range" 2016-03-21 14:00:51 +00:00
Matthias Radestock 320a8ad15b extract IPAM config
and fix error handling - the "do we have an --ipalloc-range?" check
was not performed in all required cases
2016-03-21 12:03:51 +00:00
Matthias Radestock cf08b8b1aa cosmetic: tweak --observer usage text 2016-03-21 12:02:22 +00:00
Bryan Boreham 001322751f Don't hold Nameserver lock over call out via isKnownPeer 2016-03-21 11:52:13 +00:00
Matthias Radestock 0b3dd35624 cosmetic 2016-03-21 11:08:17 +00:00
Adam Harrison cdf3e4b98e Merge pull request #2073 from weaveworks/rmpeer-test
add 'rmpeer' test
2016-03-21 11:05:53 +00:00
Adam Harrison 0d10479e8a Add --observer to weave script help 2016-03-21 11:01:55 +00:00
Matthias Radestock 357d0e918a Merge pull request #2000 from weaveworks/issues/1998-specify-ipam-seed
Allow specification of initial IPAM ring via --ipam-seed

Fixes #1998.
2016-03-21 10:52:40 +00:00
Adam Harrison 3123418022 Merge pull request #2030 from weaveworks/issues/1992-cni-plugin
Implement CNI plugin
2016-03-21 10:51:19 +00:00
Adam Harrison dcc2d16408 Update mesh dependency for peer name shorthand 2016-03-21 10:27:32 +00:00
Adam Harrison e9081c6607 Allow specification of initial IPAM ring via --ipam-seed 2016-03-21 09:49:54 +00:00
Matthias Radestock 439e57ca56 make weave rmpeer accept a list of peers
This isn't as efficient as it could be. In particular we end up
broadcasting the ipam state for every peer listed. To avoid that we'd
have to change the HTTP API, and would no longer be able to use
'DELETE'. That is just not worth it.

Closes #2044.
2016-03-20 15:53:45 +00:00
Matthias Radestock 18ddf50b4c cosmetic 2016-03-20 15:46:05 +00:00
Matthias Radestock 6ebac90cb0 refactor: eliminate dot imports in main packages 2016-03-20 14:34:27 +00:00
Matthias Radestock 5e0231ec5e refactor(ish): unify logging in docker client wrapper
and get rid of some debug logging.

and eliminate a dot import in the process.
2016-03-20 10:40:26 +00:00
Matthias Radestock c25bfafcb2 refactor: make proxy log via a package-local var
which gets rid of a bunch of (dot) imports.
2016-03-20 08:31:23 +00:00
Matthias Radestock 6e4f025d9c refactor: reduce duplication in nameserver logging
and remove a dot import in the process
2016-03-20 08:19:15 +00:00
Matthias Radestock 07ea8a2613 add 'rmpeer' test 2016-03-20 07:16:01 +00:00
Matthias Radestock f9a0ba82a0 collect coverage data from ci nodes before teardown
Fixes #2071.
2016-03-19 22:43:17 +00:00
Matthias Radestock 4c0fe7b006 take advantage of restart=always in tests
This should have been done as part of #2029.
2016-03-19 17:43:49 +00:00
Matthias Radestock cddef7cae5 Merge remote-tracking branch 'upstream/master' 2016-03-19 17:36:38 +00:00
Matthias Radestock 197f4165a3 cosmetic: move IPAM tests into 3xx range 2016-03-19 17:35:18 +00:00
Bryan Boreham 4a2affabb5 Clean up so test will run again on same host 2016-03-19 16:35:45 +00:00
Matthias Radestock 211e527d3f Merge pull request #2069 from weaveworks/issues/2047-go-via-actor
Avoid data race in TestSpaceRequest

Fixes #2047.
2016-03-19 16:09:42 +00:00
Bryan Boreham 09a6c2eda0 Get the owned ranges for test purposes via the actor loop, so we don't set off the race detector 2016-03-19 15:29:34 +00:00
Bryan Boreham 71ec252298 Merge pull request #2066 from weaveworks/2058-idempotent-rmpeer
make 'rmpeer' report on size of transferred range, and not fail
2016-03-19 15:10:58 +00:00
Matthias Radestock 9f10b21c9c use Space.NumFreeAddresses for calculating transferred ip count
...rather than Space.NumFreeAddressesInRange; we don't care about the
universe.

Alternatively we could make Space.AddRanges return the count. But
AddRanges doesn't know whether the ranges overlap with existing free
space - that is only guaranteed by the context - so would have to do
much the same before/after calculation.

Another alternative would be to add the range sizes in
AdminTakeoverRanges. But that is more code and less clear.
2016-03-19 14:41:36 +00:00
Matthias Radestock 62d823850c make rmpeer report on size of transferred space, and not fail
Closes #2058.
2016-03-19 14:40:26 +00:00
Matthias Radestock c48eefa82d refactor(ish): extract allocator logging commonality
and add warnf
2016-03-19 14:32:54 +00:00
Matthias Radestock 65eff683dd Merge branch '1.4' 2016-03-19 14:30:38 +00:00
Bryan Boreham b1ec2b788a Bump template name so it will fetch latest Docker 2016-03-19 14:12:17 +00:00
Matthias Radestock f42e275884 broadcast ipam ring update after rmpeer
So that other peers notice the change more promptly.

Fixes #2068.
2016-03-19 13:57:20 +00:00
Matthias Radestock 8ce6d3863e Merge pull request #2067 from weaveworks/address-count
Add address.Count type
2016-03-19 12:04:02 +00:00
Bryan Boreham f11314ed3e Introduce 'Count' type to avoid abusing 'Offset' 2016-03-19 11:47:34 +00:00
Bryan Boreham e080f00354 Review feedback 2016-03-18 19:40:16 +00:00
Bryan Boreham b00f0aee65 Check errors on test for root namespace 2016-03-18 19:39:52 +00:00
Matthias Radestock 7b6364696c Merge branch '1.4' 2016-03-18 19:29:59 +00:00
Matthias Radestock 5dfd104728 reduce docker event subscription retry max interval 2016-03-18 19:29:21 +00:00
Bryan Boreham 88cb07203a Improve name of cni_volume_options and include them when running the CNI plugin inside a container 2016-03-18 19:02:28 +00:00
Matthias Radestock bc7539c4ad cosmetic: consistency 2016-03-18 11:56:10 +00:00
Matthias Radestock 0474227d6e Merge pull request #2062 from weaveworks/issues/2059-weave-ps-ignore-stopped
Protect container-addrs util_op against stopped containers

Fixes #2059.
2016-03-18 11:13:14 +00:00
Adam Harrison 04bbb14f59 Propagate container-addrs util_op failure 2016-03-18 10:56:10 +00:00
Adam Harrison f9f6e8ed26 Protect container-addrs against stopped containers 2016-03-18 10:46:30 +00:00
Matthias Radestock 9c2e9bab14 cosmetic(ish) refactor 2016-03-18 02:42:53 +00:00
Matthias Radestock 4539bde5f5 simplify weave consense explanation 2016-03-18 02:03:34 +00:00
Matthias Radestock 44db686ef3 don't mention the election
Fixes #2060.
2016-03-18 01:56:52 +00:00
Matthias Radestock 221ef4adca make a few more shell funs safe
...for calling in a context w/o 'set -e', even though right now they
always are.

Follow-on of #2054.
2016-03-17 21:32:08 +00:00
Matthias Radestock c1d4e34ed0 Merge pull request #2055 from weaveworks/cleanup_attach_router
Remove unnecessary netns change in attach_router
2016-03-17 20:50:03 +00:00
Bryan Boreham 4903c2b23c Remove unnecessary netns switch for router in attach_router,
and improve the name of the function which sends existing
container data into the router
2016-03-17 20:32:41 +00:00
Matthias Radestock cd9b7bfcda Merge pull request #2054 from weaveworks/issues/2053-errexit
Fix missed errors in weave script

Fixes #2053.
2016-03-17 20:09:37 +00:00
Bryan Boreham c8ca295cda CNI plugin smoke test 2016-03-17 18:20:29 +00:00
Bryan Boreham 4e09889cab Make container_pid a common test function 2016-03-17 18:20:29 +00:00
Bryan Boreham a66543f98e Use link ParentIndex where available 2016-03-17 18:20:18 +00:00
Bryan Boreham 0705319f25 Return failure from various functions when sub-operation fails.
We cannot rely on `set -e` to fail the whole script in contexts
where functions are called inside conditionals.
2016-03-17 15:02:40 +00:00
Bryan Boreham b153e6a0d2 Simplify, after review feedback 2016-03-17 14:29:34 +00:00
Bryan Boreham ef892fd4ed Docs for CNI plugins 2016-03-17 14:29:34 +00:00
Bryan Boreham 024eb46c7d CNI plugin implemented as script that docker runs plugin container,
installed via `weave setup`
2016-03-17 14:29:33 +00:00
Bryan Boreham ecdd7aa7ce Configure arp cache on new interface 2016-03-17 14:29:33 +00:00
Adam Harrison b09b556796 Utility function to configure ARP cache timers 2016-03-17 14:29:25 +00:00
Bryan Boreham 2d6a916b2d Find weave veths by looking at what is connected to the bridge, not by name
and don't even look at containers running in the root namespace
2016-03-17 12:41:37 +00:00
Bryan Boreham 011fb55e5f Refactor FindNetDevs so we can get the link, and re-use parts of the function 2016-03-17 12:41:37 +00:00
Bryan Boreham ac4e87418a Set a default route via bridge if config doesn't specify any 2016-03-17 12:41:14 +00:00
Bryan Boreham 42ff61f97c CNI net plugin 2016-03-17 12:41:14 +00:00
Bryan Boreham 08059412b5 Refactor so we can call parts individually 2016-03-17 12:41:14 +00:00
Bryan Boreham f9615c34dc CNI IPAM plugin 2016-03-17 12:41:14 +00:00
Bryan Boreham 703b8dfd11 Expose 'ipam' type so we can refer to it elsewhere 2016-03-17 12:08:37 +00:00
Bryan Boreham b86e6412fa Don't try to parse return from DELETE address 2016-03-17 12:06:34 +00:00
Matthias Radestock aa1c1cc9be ignore arping failures
This is a largely cosmetic change since arping really shouldn't fail.
2016-03-16 20:32:42 +00:00
Adam Harrison 4b5fb2785e Merge pull request #2051 from weaveworks/issues/2046-static-ip
Fix plugin accepting --ip address
2016-03-16 15:46:49 +00:00
Bryan Boreham 4eaeb0f30c Merge branch '1.4' 2016-03-16 14:52:59 +00:00
Bryan Boreham 9c096526b8 Merge pull request #2049 from weaveworks/issues/2016-retry-docker-event-subscription
Retry docker event subscription
2016-03-16 14:38:27 +00:00
Bryan Boreham eee77d49d1 Claim IP takes CIDR not IP 2016-03-16 14:22:39 +00:00
Bryan Boreham d2d1d2b43a Test for docker network subnets and IPs 2016-03-16 13:47:30 +00:00
Adam Harrison 4874605add Merge pull request #2050 from weaveworks/bump-ci-docker
Bump template name so it will fetch latest Docker
2016-03-16 13:46:49 +00:00
Adam Harrison 922f465ecb Reset retry interval if we spent long enough processing events 2016-03-16 13:41:18 +00:00
Bryan Boreham c80bf7e996 Bump template name so it will fetch latest Docker 2016-03-16 13:14:40 +00:00
Bryan Boreham dd505a8e17 Merge pull request #2038 from weaveworks/wp-markdown-plugin-fixes
Doc fixes required by updated WP markdown plugin
2016-03-16 12:46:50 +00:00
Adam Harrison 08e9db900a Retry docker event subscription 2016-03-16 09:23:32 +00:00
Matthias Radestock 86bfc91ac9 refactor: clearer IPAM config 2016-03-15 10:29:32 +00:00
Adam Harrison 2eeb754454 refactor: Introduce IPAM config object 2016-03-14 17:41:20 +00:00
Matthias Radestock 2a10182cf6 Merge pull request #2029 from weaveworks/router-and-proxy-always-restart
Router and proxy run with --restart=always
2016-03-14 17:19:47 +00:00
Adam Harrison 115162fbfd Merge pull request #2037 from weaveworks/2021-fallback-to-hypervisor-uuid
fall back to hypervisor uuid for mac derivation
2016-03-14 16:56:00 +00:00
Adam Harrison 82adc85562 Router and proxy run with --restart=always 2016-03-14 16:31:06 +00:00
Matthias Radestock 05a7024b88 bump go-checkpoint version 2016-03-11 11:00:44 +00:00
Adam Harrison 62e8028591 Fixup link URLs 2016-03-11 10:52:58 +00:00
Adam Harrison 2bc5fd30c0 Make image paths absolute with respect to repo 2016-03-11 10:35:47 +00:00
Bryan Boreham 35671135bd Return errors that happen inside WithNetNS 2016-03-10 15:18:16 +00:00
Bryan Boreham a57335738d Don't do unnecessary clock skew check in IPAM 2016-03-10 11:41:47 +00:00
Matthias Radestock 459bb08828 fall back to hypervisor uuid for mac derivation
since the system uuid is not available on paravirtual EC2 VMs, and
possibly other hypervisors.

Fixes #2021
2016-03-09 22:35:44 +00:00
Bryan Boreham 3ad9d8e785 Don't fail start if image is missing 2016-03-09 17:10:20 +00:00
Matthias Radestock 52552b59fb Merge pull request #2024 from weaveworks/abstract-api-log
Abstract out logging function from weave api package
2016-03-09 15:45:00 +00:00
Matthias Radestock f8e2af32cd refactor: extract common docker run options 2016-03-08 23:10:19 +00:00
Anita Buehrle 66cd178308 Merge pull request #2019 from weaveworks/1-5-edit3
cleaned up product names
2016-03-08 12:29:18 -06:00
Anita Buehrle be2dfda78e edits from awh 2016-03-08 12:14:27 -06:00
Bryan Boreham 0009b05635 Improve naming of 'release' function in IPAM API 2016-03-07 16:24:53 +00:00
Bryan Boreham f2e38ae6c5 Abstract out logging function from weave api package to reduce dependencies 2016-03-07 15:37:51 +00:00
Bryan Boreham b83f4a00ed Merge pull request #1997 from weaveworks/issues/1994-weave-consense
Implement `weave consense`
2016-03-03 15:26:02 -08:00
Anita Buehrle e2c8dba981 cleaned up product names 2016-03-03 16:12:12 -06:00
Adam Harrison 6584df274e Implement weave consense 2016-03-03 18:52:09 +00:00
Bryan Boreham 7c65b6e3bb Merge pull request #1990 from weaveworks/issues/1743-restricted-electorate
Support non-electing peers via --observer
2016-03-03 10:46:58 -08:00
Adam Harrison 268d355cae Observer smoke tests 2016-03-03 17:48:50 +00:00
Adam Harrison b84ef98de8 Support non-electing peers via --observer 2016-03-03 17:48:50 +00:00
Adam Harrison 29674b7780 Merge pull request #2012 from weaveworks/issues/1655-store-all-addresses
Store all addresses+subnets in IPAM
2016-03-03 17:06:02 +00:00
Martynas Pumputis 9cfc104fc7 Add TestSpaceRequest test for allocator
Checks whether a donating peer does not leave one ip address
behind a block it donates (#2009).
2016-03-03 08:36:14 -08:00
Bryan Boreham 824329d4c9 Fix up unit tests to look at CIDRs instead of addresses. 2016-03-02 17:21:52 -08:00
Bryan Boreham 604309fb53 Parse CIDR strings without separating into subnet and address 2016-03-02 17:21:52 -08:00
Bryan Boreham 73f1a04d5f Deal in subnets, not ranges, when requesting address allocation 2016-03-02 17:21:51 -08:00
Bryan Boreham b76e2a87cf Store address+subnet prefix for 'owned' addresses 2016-03-02 17:21:24 -08:00
Bryan Boreham b6eec08247 Return all applicable results from Lookup
and stop erroring on Lookup not found; just return a blank result
2016-03-02 17:01:12 -08:00
Bryan Boreham 03563e847e Remember addresses outside of the allocation range 2016-03-02 17:01:12 -08:00
Bryan Boreham 4c159a9af6 Merge pull request #1973 from weaveworks/issues/678-persist-owned2
Persist 'owned' addresses in IPAM
2016-03-02 16:58:23 -08:00
Bryan Boreham bc61838aaa Merge pull request #2015 from weaveworks/1-5-edits2
Reorganization of docs for WordPress
2016-03-02 16:24:14 -08:00
Bryan Boreham 8c9937b0be Fix up some wording and links 2016-03-02 15:39:06 -08:00
Anita Buehrle bdc9eae000 reorganization-edit docs for WP 2016-03-02 13:54:05 -06:00
Bryan Boreham 95cbc8940e Sync 'owned' data with existing containers at startup 2016-03-02 11:35:24 -08:00
Bryan Boreham f29716387f Persist the 'owned' address set 2016-03-02 11:35:24 -08:00
Adam Harrison 30b9d33276 Adjust tests to accomodate docker/docker#14012 2016-03-02 11:59:10 +00:00
Bryan Boreham 532a6b69d9 Merge pull request #1672 from weaveworks/vagrant-pin-docker
Pin docker version in vagrant VM
2016-03-01 14:15:05 -08:00
Bryan Boreham f2ef5e880a Merge pull request #1982 from weaveworks/issues/578-pid-equals-host
Use --pid=host
2016-03-01 12:41:52 -08:00
Bryan Boreham dd74bb1774 Simplify by using GetFromPid 2016-03-01 12:12:46 -08:00
Adam Harrison adf56d316d Remove obsolete alternative procfs support 2016-03-01 20:10:47 +00:00
Adam Harrison cb9af20a2e Replace PROCFS with --pid=host 2016-03-01 20:10:47 +00:00
Bryan Boreham cb01e3f87b Typo 2016-02-29 15:08:55 -08:00
Bryan Boreham 590c1dde1d Merge branch '1.4' 2016-02-29 15:04:12 -08:00
Bryan Boreham be3f88656b Add release v1.4.5 2016-02-29 22:28:58 +00:00
Bryan Boreham 246f394731 Merge branch '1.4' 2016-02-29 14:07:02 -08:00
David Wragg 27367ab292 Process DiscardingFlowOp correctly in FastDatapath send()
The nil FlowOp check in collectFlowOps was not addressed with the
introduction of DiscardingFlowOp.  This meant that DiscardingFlowOps
produced in the router core would get handled by fastdp as if they were
foreign FlowOps, preventing flow creation and so leading to unwarranted
ODP misses.

To fix this, collectFlowOps cannot simply eliminate FlowOps for which
Discards() is true, because it's true for odpFlowKeyFlowOp.  So the
Discards() case has to be handled in FastDatapath send().
2016-02-29 13:27:15 -08:00
Matthias Radestock f5d8fc5de2 move weavedns design from site to docs 2016-02-29 19:18:08 +00:00
Matthias Radestock 7cdf273c88 Merge branch '1.4' 2016-02-29 19:13:23 +00:00
Matthias Radestock 20620f0002 Merge branch 'latest_release_doc_updates' into 1.4 2016-02-29 19:13:00 +00:00
Matthias Radestock 8d79e33ba1 remove stale ToC entry
This was missed in 8b061fd55
2016-02-29 19:12:00 +00:00
Bryan Boreham 7453c7a5dd Merge branch '1.4' 2016-02-29 08:22:22 -08:00
Bryan Boreham ce4857f5dc Merge pull request #2001 from weaveworks/issues/1996-try-all-pending-allocations
Try all pending allocations - LGTM.  Fixes #1996
2016-02-29 08:20:49 -08:00
Adam Harrison 71af1f3120 Merge pull request #1972 from weaveworks/persist-peers
Persist set of peers to connect to
2016-02-29 15:54:54 +00:00
Adam Harrison e65a08471f Merge pull request #1967 from weaveworks/issues/1859-start-existing
Start existing container, if its image and arguments match
2016-02-29 15:33:30 +00:00
Alfonso Acosta b96330d529 Pin docker version in vagrant VM
Otherwise it will always install the latest docker version, which will be
undesirable when new major releases are done, until they are well tested.

For instance, docker after automatically updating to 1.9, it was killing my VM
when spawning a kubernetes cluster, due to a high CPU consumption, probably due
to https://github.com/docker/docker/issues/17720
2016-02-29 14:31:06 +00:00
Bryan Boreham f17d50cc50 Check the exact version of the image, not the base 2016-02-26 23:44:04 +00:00
Bryan Boreham 436f8ef7c8 Compare the environment so we can detect a change in password 2016-02-26 23:41:57 +00:00
Bryan Boreham 65f435f042 Smoke-test for restarts 2016-02-26 23:41:57 +00:00
Bryan Boreham 561c8d012c Treat a restarting container like a running one, for idempotency 2016-02-26 23:41:46 +00:00
Bryan Boreham bb4c0f5247 Start existing container, if its image and arguments match 2016-02-26 23:40:02 +00:00
Adam Harrison 31a964ba9b Merge pull request #1954 from weaveworks/version-check
Periodically check for up to date versions of weave.
2016-02-26 17:25:24 +00:00
Tom Wilkie b717399364 Update go-checkpoint 2016-02-26 16:47:32 +00:00
Tom Wilkie b79bb32782 Review feedback 2016-02-26 15:37:00 +00:00
Tom Wilkie 6ff7419981 Review feedback 2016-02-26 15:35:12 +00:00
Tom Wilkie b228bbb9fb Periocially check for up to date versions of weave. 2016-02-26 15:35:12 +00:00
Matthias Radestock 752baa4bd6 remove unnecessary WEAVE_CIDR=none
since the router is now always running with --net=host
2016-02-26 13:58:06 +00:00
Matthias Radestock 6cbde89eeb refactor: consistency in specification of common docker run options 2016-02-26 13:57:37 +00:00
Adam Harrison bceabe32a2 Try all pending allocations
We can have outstanding allocations for different ranges owned by
different peers, so we should not short circuit after the first space
request.
2016-02-25 14:56:33 +00:00
Adam Harrison c5361801c9 Fix typo in weaver CLI help 2016-02-25 12:02:28 +00:00
Matthias Radestock 3283bc89fc Merge branch '1.4' 2016-02-23 13:56:56 +00:00
Matthias Radestock 26519333c0 cosmetic: correct comment 2016-02-23 13:36:56 +00:00
Matthias Radestock 639cde0f67 refactor: inline 2016-02-23 13:34:14 +00:00
Matthias Radestock 6a9f9f66dc don't check for 'Restarting' when attaching on startup
It is overkill.
2016-02-23 13:20:22 +00:00
Adam Harrison 639e0e82c9 Merge pull request #1989 from weaveworks/1977-restarting-not-running
treat 'restarting' as 'not running'
2016-02-23 10:49:31 +00:00
Adam Harrison 6f65512471 Merge branch '1.4' 2016-02-23 10:47:08 +00:00
Adam Harrison 4b0a6e1433 Merge pull request #1983 from weaveworks/1929-auto-detect-odp-on-relaunch
don't complain on relaunch when ODP is not supported
2016-02-23 10:46:36 +00:00
Matthias Radestock d5b82cac45 Merge branch '1.4' 2016-02-23 10:17:03 +00:00
Matthias Radestock cb6db91b09 Merge branch 'latest_release_doc_updates' into 1.4 2016-02-23 10:16:08 +00:00
Matthias Radestock 6a02e2dc17 explain TCP/UDP connections, heartbeats, back-off
Fixes #1969
2016-02-23 09:54:15 +00:00
Ilya Dmitrichenko f4ad97b0c9 Merge branch '1.4' 2016-02-22 14:16:37 +00:00
Ilya Dmitrichenko b377207faf Merge branch 'latest_release_doc_updates' into 1.4 2016-02-22 14:16:02 +00:00
Ilya Dmitrichenko 24ebb7cc7c Add missing dependency for latest gsutil 2016-02-22 14:11:36 +00:00
Ilya Dmitrichenko b5518db03c Add missing argument to tar 2016-02-22 14:02:39 +00:00
Ilya Dmitrichenko 2aa4e6a83a Use "official" gsutil installation instructions 2016-02-22 13:58:42 +00:00
Ilya Dmitrichenko 7c655cc3ba Fix false-positive docs uploads 2016-02-22 13:56:49 +00:00
Matthias Radestock d7a1bdd7a8 Merge branch '1.4' 2016-02-22 13:55:45 +00:00
Matthias Radestock 75cda01167 Merge branch 'latest_release_doc_updates' into 1.4 2016-02-22 13:55:18 +00:00
Matthias Radestock 4f0f3cf98d warn against using the plugin in combination with --net=weave
and expand the basic proxy usage docs slightly.
2016-02-22 13:53:39 +00:00
Matthias Radestock d9637ce620 Merge branch '1.4' 2016-02-22 13:38:08 +00:00
Matthias Radestock e014140134 Merge branch 'latest_release_doc_updates' into 1.4 2016-02-22 13:36:33 +00:00
Matthias Radestock c8ae128e59 for Travis, this no longer is a go project
Travis insists that one picks a project language. There is no go left
in the steps executed by travis. Instead we have Python, Ruby and
shell. Let's pick the first...

Picking Python makes travis unhappy with "Can not perform a '--user'
install. User site-packages are not visible in this
virtualenv". Dropping the '--user' flag fixes that.

(cherry picked from commit 1d8d098450)
2016-02-22 13:29:33 +00:00
Matthias Radestock 12d848162d shrink Travis usage
There is no point running builds, tests, lints on Travis, since we
already do that on Circle.

The only thing we aren't doing (and can't do) on Circle is doc
publishing, so now Travis does just that.

(cherry picked from commit 1038cbd1a3)
2016-02-22 13:29:33 +00:00
Matthias Radestock b12096bd6c tweak 2016-02-22 13:23:29 +00:00
Matthias Radestock 644485d4ae Merge branch '1.4' 2016-02-22 13:13:48 +00:00
Matthias Radestock 1430982166 Merge branch 'latest_release_doc_updates' into 1.4 2016-02-22 13:13:13 +00:00
Matthias Radestock 2a83aad1d6 warn against using plugin and proxy simultaneously
and give a complete example.

Partially addresses #1988.
2016-02-22 13:11:02 +00:00
Matthias Radestock 4a7157959a don't attempt to attach 'restarting' containers
this is an optimisation... there is no point attempting to attach a
'restarting' container - it will fail.

When the container *actually* restarts we'll get a 'Start' event, and
attach at that point.

Also, there is no point checking for 'Paused' since 'Paused' ->
'Running'.
2016-02-20 11:00:04 +00:00
Matthias Radestock e52abafc48 treat restarting containers as "not running"
thus preventing stale DNS & IPAM entries.

Fixes #1977
2016-02-20 10:59:47 +00:00
Bryan Boreham b064bcce49 Log when command-line peer list overridden by persisted list
Reworked interface to router so we split setting up the initial list
from beginning to make connections - we shouldn't do that until
after router.Start().
2016-02-19 14:29:33 +00:00
Matthias Radestock 0f9d9c77a3 remove cruft 2016-02-19 00:30:22 +00:00
Matthias Radestock 33c81add8d update dependency to fix build breakage 2016-02-19 00:27:45 +00:00
Matthias Radestock ee531b8023 don't complain on relaunch when ODP is not supported
...and WEAVE_NO_FASTDP isn't set.

Fixes #1929.
2016-02-18 22:00:08 +00:00
Matthias Radestock 497a104db7 Merge branch '1.4' 2016-02-18 21:59:42 +00:00
Matthias Radestock 5e761a62b0 Merge pull request #1985 from weaveworks/issues/1984-discovery
Add two functions required by ipamapi "contract"

Fixes #1984
2016-02-18 21:55:53 +00:00
Bryan Boreham b442567406 Add two functions required by ipamapi "contract" but not actually used 2016-02-18 15:29:10 +00:00
Adam Harrison 5dd8584fb6 Fix veth cleanup on Ubuntu 15.10
Cope with the @ characters that have started appearing in veth names as
of Ubuntu 15.10.
2016-02-18 12:11:48 +00:00
Matthias Radestock 4bd18737b7 fix typo 2016-02-18 11:39:54 +00:00
Bryan Boreham ba8926a6ea Persist set of peers to connect to 2016-02-17 18:12:16 +00:00
Matthias Radestock 09cd9e091a Merge branch '1.4' 2016-02-16 14:09:06 +00:00
Matthias Radestock 17d53af2a2 improve logging of dns entry creation
- log inside the lock, so we get proper serialisation
- include the container name, so we can identify the specific entry
2016-02-16 14:04:34 +00:00
Adam Harrison 2d4d3577ba Merge pull request #1971 from weaveworks/issues/678-persist-ipam2
Persist IPAM ring
2016-02-15 10:15:53 +00:00
Bryan Boreham 546f9592f9 Hard-fail on persistence errors, otherwise the network can get confused on a restart.
Create `Allocator.fatalf()`, for consistency
2016-02-12 18:12:26 +00:00
Bryan Boreham 06f3793f05 Remove persisted IPAM ring data on peerName change 2016-02-12 18:12:26 +00:00
Bryan Boreham f396c60402 Persist the Ring 2016-02-12 18:12:26 +00:00
Bryan Boreham ad036499eb Add db infra to IPAM 2016-02-12 18:12:26 +00:00
Bryan Boreham 38c6eb28e8 Add basic infrastructure to use BoltDB for persistence 2016-02-12 18:12:26 +00:00
Matthias Radestock 11e2515f70 Merge pull request #1968 from weaveworks/refactor-veth-creation
"refactor" veth creation
2016-02-10 13:49:13 +00:00
Matthias Radestock c79e036c08 Merge pull request #1966 from weaveworks/issues/1965-fix-local-weave-ps
Make weaveutil container-addrs observe $PROCFS

Fixes #1965.
2016-02-09 22:40:36 +00:00
Matthias Radestock 7a19c2f147 add a test 2016-02-09 22:26:01 +00:00
Adam Harrison 4cee647e73 Make weaveutil container-addrs observe $PROCFS 2016-02-09 22:25:47 +00:00
Matthias Radestock 7ea3299dc6 oops
/usr/local/bin/weave: 1172: [: true false: unexpected operator

This got broken in #1941.
2016-02-09 22:05:11 +00:00
Matthias Radestock 5707581ba3 Merge pull request #1964 from weaveworks/weave-veth-cleanup
Fix attach-bridge bugs
2016-02-09 21:11:27 +00:00
Adam Harrison 264d5e4828 Make attach-bridge iptables rule insertion idempotent 2016-02-09 20:42:59 +00:00
Matthias Radestock 9311294d9c "refactor" veth creation
Invoke the new create_veth from a few places, eliminating code
duplication and inconsistencies.

Semantic differences:

- init_bridged_fastdp now skips the veth creation/config if the veth
  already exists. This eliminates routing blips. Though in reality
  something very strange must have happened to end up in this code
  with an existing veth.
- init_bridged_fastdp no longer deletes the $BRIDGE and $DATAPATH when
  veth creation/configuration fails. This is consistent with
  init_bridge, which does not delete $BRIDGE when something goes
  wrong. And it is generally desirable since the init_* functions are
  invoked on potentially existing bridges - e.g. following 'weave
  stop'.
- attach_bridge and setup_router_iface_bridge used to mark one veth
  end 'up', then invoke add_iface_* for it, and then mark the other
  end 'up'. create_veth marks both ends 'up' first. This makes no
  practical difference in these cases.

notable other differences:
- we detect veth presence by checking whether *both* ends are present,
  rather than just one. We deliberately continue to (and fail in) the
  veth creation if one end already exists. This can only happen when
  we've stumbled across a different interface, since a veth end cannot
  exist independently. So it is right to treat this as an error.
- init_bridged_fastdp invokes add_iface_bridge instead of duplicating
  what that does. Also makes for nice coherence with the
  add_iface_fastdp it is invoking too.
2016-02-09 19:22:14 +00:00
Adam Harrison 2bfc86e7b2 Cleanup attach-bridge iptables rule 2016-02-09 16:51:04 +00:00
Adam Harrison 36ee8bacb0 Remove all vethwe* interfaces in reset 2016-02-09 16:48:03 +00:00
Matthias Radestock 1bb1108b91 tiny refactor: use ${CONTAINER_IFNAME} for name construction 2016-02-09 16:40:58 +00:00
Matthias Radestock a77201bf77 Merge pull request #1955 from weaveworks/weave-attach-bridge
'attach-bridge' feature to link an existing bridge netdev with the weave bridge
2016-02-09 15:45:28 +00:00
Adam Harrison a3d842bf4a Implement attach-bridge 2016-02-09 15:20:11 +00:00
Adam Harrison 43eb70193b Merge branch '1.4' 2016-02-09 11:40:14 +00:00
Adam Harrison 1228dbddb9 Add release v1.4.4 2016-02-09 11:20:51 +00:00
Adam Harrison a401d0d6ea Merge branch '1.4' 2016-02-09 10:53:52 +00:00
Adam Harrison c00b00d623 Merge pull request #1963 from weaveworks/issues/1959-dont-remove-network
Don't remove weave network on plugin shutdown because it bricks Docker 1.10
2016-02-09 10:53:13 +00:00
Bryan Boreham 7bbc9f1b82 Don't remove the weave network on shutdown because it bricks Docker 1.10 2016-02-09 10:02:06 +00:00
Matthias Radestock 6252871e93 Merge branch '1.4' 2016-02-09 09:30:19 +00:00
Matthias Radestock 15a92f9c92 Merge pull request #1961 from weaveworks/issues/1956-any-iface
Wait for multicast route on any interface

Fixes #1956.
2016-02-09 09:29:05 +00:00
Bryan Boreham 9386c01845 Wait for multicast route on any interface, to match weave script
which only adds a route if there isn't one already
2016-02-08 14:04:25 +00:00
Adam Harrison 6d1e33b558 Merge pull request #1957 from weaveworks/issues/1949-ring-errors
Make error messages on ring merge clearer
2016-02-08 13:52:59 +00:00
Bryan Boreham ed3c50f43e Merge pull request #1951 from weaveworks/issues/1940-remove-proxy-dockerbridgeip-dep
Use netlink instead of shelling out to `weave docker-bridge-ip`
2016-02-08 11:05:10 +00:00
Bryan Boreham 9ac62e8005 Extract common getenv-testing code 2016-02-08 10:46:18 +00:00
Bryan Boreham 034da376c4 Make error messages on ring merge clearer 2016-02-08 10:13:41 +00:00
Matthias Radestock 10fbc75997 Merge pull request #1922 from weaveworks/issues/1179-its-alive
In IPAM, resurrect apparently-dead containers on ContainerStarted event
2016-02-05 16:36:28 +00:00
Matthias Radestock 98d76e1099 Merge pull request #1941 from weaveworks/issues/1873-check-running-master
Improve visibility of startup problems

Fixes #1873.
2016-02-04 16:50:50 +00:00
Matthias Radestock f2a1b3829d tweak: consistency 2016-02-04 16:19:29 +00:00
Matthias Radestock e47c4a78f0 Merge pull request #1948 from weaveworks/test-claimforpeers
Improve IPAM Ring unit testing, and streamline ring.ClaimForPeers
2016-02-04 15:31:00 +00:00
Bryan Boreham f9f6649f90 Check some ring entries via AllRangeInfo, to improve coverage 2016-02-04 15:12:13 +00:00
Bryan Boreham a5c9898884 Checking for existing entries is pointless when the Ring starts empty 2016-02-04 15:12:13 +00:00
Bryan Boreham 839eb28310 Unit test for ring.ClaimForPeers 2016-02-04 15:11:46 +00:00
Adam Harrison e2ec2b436d Use netlink instead of shelling out to weave docker-bridge-ip 2016-02-04 14:00:01 +00:00
Bryan Boreham 07b79568dd Resurrect apparently-dead containers on ContainerStarted event 2016-02-04 13:49:43 +00:00
Bryan Boreham 1d3c80ab49 Merge pull request #1944 from weaveworks/issues/1940-remove-proxy-weaveps-dep
Use netlink instead of shelling out to `weave ps`
2016-02-04 13:45:58 +00:00
Bryan Boreham 38013d2f41 Kill zombies 2016-02-04 12:52:16 +00:00
Adam Harrison 65c48707f6 Use netlink instead of shelling out to weave ps 2016-02-04 12:51:18 +00:00
Adam Harrison 415e550f86 Merge pull request #1930 from weaveworks/issues/1746-always-use-host-netns
Always use host netns
2016-02-04 12:50:08 +00:00
Adam Harrison 034d8933c0 make multiweave work with weave running in the host netns
Multiweave now creates a temporary bridge with an IP alias per router
in the host netns, and overrides the router to bind to that specific
IP for weave protocol and data traffic and http control.
2016-02-03 11:57:12 +00:00
Matthias Radestock cf24bb0e89 remove weaveapi.NewClientWithResolver cruft 2016-02-03 11:56:50 +00:00
Matthias Radestock ae725e333a make plugin pay attention to WEAVE_HTTP_ADDR 2016-02-03 11:54:05 +00:00
Matthias Radestock dde244160b make proxy pay attention to WEAVE_HTTP_ADDR 2016-02-03 11:28:38 +00:00
Matthias Radestock fdd006022d make weave control address configurable 2016-02-02 21:38:02 +00:00
Adam Harrison 1e01a31939 Support --host argument to weave launch
Allow the weave router bind to a specific host IP address instead of
INADDR_ANY.
2016-02-02 20:48:49 +00:00
Adam Harrison 4117ef0c50 Fix WEAVE_NO_FASTDP test on GCE 2016-02-02 20:48:49 +00:00
Matthias Radestock e3c19d6414 get rid of container_ip
We already know what the weave container IP is, since now it runs in
the host netns.
2016-02-02 20:48:49 +00:00
Matthias Radestock b1e6bc2929 Always use host netns
which allows us to get rid of port mappings and a whole bunch of other
code.
2016-02-02 20:48:49 +00:00
Matthias Radestock feee4f0494 refactor: make proxy use weave/api
and extend that api as required, namely with DNSDomain()
2016-02-02 20:45:30 +00:00
Matthias Radestock 34ab86124b fix typo 2016-02-02 20:31:38 +00:00
Adam Harrison f37eb4b77d Merge branch '1.4' 2016-02-02 16:52:20 +00:00
Adam Harrison 5232a9af6b Add release v1.4.3 2016-02-02 16:35:32 +00:00
Adam Harrison 90795e5446 Merge branch '1.4'
Conflicts:
	plugin/ipam/driver.go
2016-02-02 16:04:49 +00:00
Adam Harrison c393b23b31 Merge pull request #1918 from weaveworks/issues/1906-plugin-no-weave
Return an error when weave isn't running, on RequestPool
2016-02-02 15:54:39 +00:00
Matthias Radestock 6bebce0b5a tiny refactor 2016-02-02 14:03:01 +00:00
Bryan Boreham 71da517e88 Refactor to collect all code that touches alloc.owned 2016-02-02 13:57:12 +00:00
Matthias Radestock faa7bad8d8 refactor with_container_netns
make it set CONTAINER_NETNS instead of CONTAINER_PID (well, it still
sets the latter, but not for effect), which reduces coupling.
2016-02-02 13:37:17 +00:00
Matthias Radestock 710c13ced9 correct typo in comment 2016-02-02 13:02:33 +00:00
Adam Harrison 6bd8da905e Refactor: uniform use of weave_container_addresses 2016-02-02 11:30:36 +00:00
Adam Harrison 839f534350 Merge branch '1.4' 2016-02-01 15:30:51 +00:00
Adam Harrison 955fbca44a Merge pull request #1943 from weaveworks/1942-mcast-iface-up
don't set the interface 'up' before it is fully configured
2016-02-01 15:29:46 +00:00
Matthias Radestock 18c26e9fbb don't set the interface 'up' before it is fully configured
This was causing container entrypoints to execute too early,
e.g. before the interface had been given an IP address. But only when
running with --no-multicast-route, since otherwise weavewait is
waiting for the multicast route to appear.

Fixes #1942.
2016-02-01 12:04:15 +00:00
Bryan Boreham 0a4b3a04ba Wait for plugin status via unix socket 2016-02-01 10:11:46 +00:00
Bryan Boreham 78f2d82984 Extract function to listen on Unix socket 2016-02-01 10:11:46 +00:00
Matthias Radestock f8fa37c895 Merge branch '1.4' 2016-01-30 11:16:30 +00:00
Matthias Radestock b54efbde69 fix typo in comment 2016-01-30 11:15:57 +00:00
Bryan Boreham c2a869491f Check State.Restarting as well as State.Running 2016-01-29 17:41:02 +00:00
Bryan Boreham a750ef8033 Don't check if container is running when we only want its ID.
This avoids trying to decide if "restarting" is as good as "running".
In wait_for_status we now explitly check_running, and
in dns_add/remove we add an extra check_running test.
2016-01-29 17:41:02 +00:00
Matthias Radestock 30fef10afa Merge remote-tracking branch 'upstream/master' 2016-01-29 16:08:00 +00:00
Matthias Radestock 2e9c1ee046 Merge branch '1.4' 2016-01-29 16:07:20 +00:00
Adam Harrison 81c49e6005 Merge pull request #1938 from weaveworks/issues/1827-stopped-version
Check if container is running before using its image to ask for version
2016-01-29 15:57:15 +00:00
Adam Harrison 11ccada740 Merge pull request #1939 from weaveworks/issues/1937-dont-rm
Don't rm old containers, in case we want the log
2016-01-29 15:47:40 +00:00
Matthias Radestock be9d64b2cc Merge pull request #1936 from weaveworks/issues/1934-rm-socket
Remove Unix domain sockets on shutdown

Fixes #1934.
2016-01-29 15:46:24 +00:00
Matthias Radestock b2c9802aa2 Merge branch '1.4' 2016-01-29 15:25:50 +00:00
Matthias Radestock c6f356a167 Merge pull request #1935 from weaveworks/issues/1757-volumes-container
Reduce docker volumes for weavewait to just one set per release

Fixes #1757.
2016-01-29 15:24:42 +00:00
Adam Harrison 5fbceb0f78 Merge pull request #1777 from weaveworks/remove-plugin-nameserver-option
Remove 'nameserver' option from plugin
2016-01-29 15:24:04 +00:00
Bryan Boreham 3c6211f9f2 Don't rm old containers, in case we want the log 2016-01-29 15:07:14 +00:00
Bryan Boreham b9502ee1cd Check if container is running before using its image to ask for version 2016-01-29 14:43:02 +00:00
Adam Harrison 4f97b3ac85 Merge pull request #1916 from weaveworks/issues/1734-fixed-ip
Support requesting a specific IP from the plugin
2016-01-29 14:22:23 +00:00
Bryan Boreham e4828ad30a Remove 'nameserver' option 2016-01-29 14:03:04 +00:00
Matthias Radestock 20dab1f8fe Merge branch '1.4' 2016-01-29 12:46:08 +00:00
Matthias Radestock eae45ebc94 Merge pull request #1921 from weaveworks/issues/1745-plugin-ps
Make weave script scan veths with prefix 'ethwe'

Fixes #1745
2016-01-29 12:45:10 +00:00
Bryan Boreham ea50b3d5cc Create a different weavevolumes container for each Weave version.
They will be named 'weavevolumes-v1.4.3', 'weavevolumes-latest', etc.
Use a label to identify these containers so they can all be removed on `weave reset`.
2016-01-29 12:22:22 +00:00
Bryan Boreham 3297b93edb Smoke-test 'weave ps' and restarting when using plugin 2016-01-29 12:13:00 +00:00
Bryan Boreham 6d0e867ad0 Capture addresses from veths with prefix 'ethwe'
This is to address the plugin case, where the veth will have a name like 'ethwe0'.
Previously we only looked at the device named exactly 'ethwe'.
Covers `weave ps` and reclaim of addresses for IPAM and WeaveDNS.
2016-01-29 12:13:00 +00:00
Bryan Boreham 1cea9c1c87 Extract function to detect container running in host namespace 2016-01-29 12:13:00 +00:00
Bryan Boreham 3320a9e7d4 Re-organise code so we can clean up using defer and return error codes to top level 2016-01-29 11:41:24 +00:00
Bryan Boreham 9b90a938f5 Remove Unix domain sockets on shutdown 2016-01-28 18:26:34 +00:00
Bryan Boreham c0ece16881 Don't need to rm the network here because 'weave reset' does it 2016-01-28 17:55:27 +00:00
Matthias Radestock 95a4ca8e3e Merge branch '1.4' 2016-01-28 17:51:20 +00:00
Matthias Radestock c6d0149ba6 add missing dependency
The plugin image derives from the weaveexec image.
2016-01-28 17:50:26 +00:00
Bryan Boreham 598efe5d1a Reduce docker volumes for weavewait to just one set.
- Create an auxilliary container 'weavevolumes' to hold the '/w/w'
  files, and map into that instead of creating new volumes every time.
- Show "/bin/false" as its command in `docker ps` instead of
"/home/weave/sigproxy".
- Remove volumes when cleaning up smoketest containers.
2016-01-28 15:57:22 +00:00
Matthias Radestock cab4e37ef8 Merge pull request #1924 from weaveworks/update-mesh
Update mesh
2016-01-28 10:04:40 +00:00
Peter Bourgon 0dff2e66c6 vendor: update mesh
Now, broadcast operations cannot fail. So, update various broadcast-y
methods to no longer return errors.
2016-01-28 10:43:32 +01:00
Matthias Radestock 6680a8a054 Merge branch '1.4' 2016-01-27 22:04:09 +00:00
Matthias Radestock 3679065258 cope with nil route.Dst
Fixes #1932.
2016-01-27 22:02:07 +00:00
Bryan Boreham 482045aed8 Send back an http error code with any plugin errors. 2016-01-27 14:53:26 +00:00
Bryan Boreham 610a90c727 Claim address requested by caller 2016-01-27 12:11:01 +00:00
Matthias Radestock 31f736b37e fix errors spotted by usage analysis 2016-01-26 18:13:29 +00:00
Matthias Radestock d220379ad3 Merge branch '1.4' 2016-01-26 16:57:28 +00:00
Matthias Radestock 4649f1158a Merge pull request #1926 from weaveworks/issues/1905-fix-negative-fragment
Negative fragment fix

Fixes #1905.
2016-01-26 16:56:03 +00:00
Bryan Boreham 952e9de265 Remove superfluous line and fix comment typo 2016-01-25 18:05:43 +00:00
Bryan Boreham ef1b8d6237 Merge pull request #1927 from weaveworks/revert-1808-1803-plugin-mac
Revert "Refactor plugin to create veths in CreateEndpoint"
2016-01-25 18:04:56 +00:00
Bryan Boreham 2970df4505 Revert "Refactor plugin to create veths in CreateEndpoint" 2016-01-25 17:57:53 +00:00
Adam Harrison 87f793f0e0 Merge pull request #1808 from weaveworks/1803-plugin-mac
Refactor plugin to create veths in CreateEndpoint
2016-01-25 11:53:17 +00:00
Adam Harrison de17a44f35 Fix fragmentation test
The assumptions on which this test was based were violated by the
introduction of fast datapath. A new rule is required to block fast
datapath traffic, to ensure that sleeve is selected for forwarding; the
rules must also be moved from the FORWARD chain to INPUT as the router
now runs in the host netns (NB we use INPUT instead of OUTPUT as the
latter results in sleeve receiving an 'operation not permitted' udpv4
write error when it tries to send a packet that is too big, rather than
the packet just being silently dropped as required)
2016-01-25 10:58:31 +00:00
Adam Harrison 52ce4df18e Increase the lowest possible good PMTU
The current minimum PMTU we can detect is eight bytes, which, being
lower than the minimum IPv4 MTU of 68 bytes, can cause an exception in
the sleeve packet fragmentation implementation. We increase that minimum
to 552, the lowest PMTU value that Linux will cache.
2016-01-25 10:53:10 +00:00
Matthias Radestock 1a590b3ffa document --name 2016-01-23 09:01:41 +00:00
Matthias Radestock e249a7ef0c tweak plugin docs 2016-01-22 13:44:49 +00:00
Matthias Radestock 83412e4514 Merge pull request #1915 from weaveworks/issues/1806-plugin-subnet
Support subnet and iprange arguments on network create

Closes #1806.
2016-01-22 13:39:52 +00:00
Bryan Boreham 1a59734cdb Support subnet and iprange arguments on network create 2016-01-22 13:37:36 +00:00
Matthias Radestock 7f3dc6f202 Merge branch '1.4' 2016-01-22 13:35:58 +00:00
Matthias Radestock f1ed5bf838 Merge branch 'latest_release_doc_updates' into 1.4 2016-01-22 13:35:27 +00:00
Matthias Radestock 256a801d16 typo 2016-01-22 13:34:59 +00:00
Matthias Radestock c416cf8da5 tidying of plugin docs 2016-01-22 13:27:22 +00:00
Matthias Radestock efffbe6de1 Merge pull request #1913 from weaveworks/fix-smoketests-docker-1.10
Fix smoke tests for docker 1.10
2016-01-21 17:30:52 +00:00
Adam Harrison a64435a9a5 Adjust tests to accomodate docker/docker#14012 2016-01-21 17:28:54 +00:00
Bryan Boreham c2fba38c46 Merge pull request #1902 from weaveworks/vendored-dep-management-doc
Document vendored dependency management commands
2016-01-21 14:14:47 +00:00
Matthias Radestock d2ba647f68 Merge pull request #1920 from weaveworks/1893-make-testrunner
move smoke test dependencies from 'all' to 'testrunner' target

Fixes #1893.
2016-01-21 13:46:34 +00:00
Matthias Radestock a6aad6dc49 move smoke test dependencies from 'all' to 'testrunner' target
That way a plain 'make' works out-of-the-box.

Fixes #1893.
2016-01-21 13:00:32 +00:00
Bryan Boreham 7455a699c4 Use more chars from endpointID to reduce clashes 2016-01-21 12:36:58 +00:00
Matthias Radestock 0872623ca5 Merge branch '1.4' 2016-01-21 12:30:32 +00:00
Matthias Radestock 75e812a061 Merge branch 'latest_release_doc_updates' into 1.4 2016-01-21 12:30:14 +00:00
Matthias Radestock 4cc7b01940 Merge pull request #1907 from weaveworks/systemd-timeout
Suggest disabling systemd timeout if using Weave Net plugin
2016-01-21 12:29:42 +00:00
Matthias Radestock 4d05775e11 Merge branch '1.4' 2016-01-21 11:30:05 +00:00
Matthias Radestock a2ff7e5981 Merge pull request #1919 from weaveworks/issues/1900-dont-stop-stoppin
Warn, don't error, if unable to remove network in 'weave stop'

Fixes #1900.
2016-01-21 11:22:21 +00:00
Matthias Radestock d5bfc61a73 use hashicorp's wily64 images instead of ubuntu's
The latter suffer from https://github.com/mitchellh/vagrant/issues/6653
2016-01-21 11:08:14 +00:00
Bryan Boreham 7ec17ab2ef Merge branch '1.4' 2016-01-21 10:18:01 +00:00
Bryan Boreham cda98a6375 Merge pull request #1917 from weaveworks/issues/1911-fix-unexpected-eof
Fix unexpected EOF with Docker 1.10-rc1 and proxy --rewrite-inspect
2016-01-21 10:15:20 +00:00
Matthias Radestock 03ac917567 Merge branch '1.4' 2016-01-20 18:56:59 +00:00
Matthias Radestock 3b7a754b0a Merge branch 'latest_release_doc_updates' into 1.4 2016-01-20 18:56:26 +00:00
Anita Buehrle c01c6bcb91 fixed logo image in header 2016-01-20 12:48:31 -06:00
Bryan Boreham 5d598a1015 Refactor to make suffix part clearer 2016-01-20 16:50:42 +00:00
Bryan Boreham adafb79e34 Move endpoint creation into CreateEndpoint so we can return the MAC address 2016-01-20 16:45:08 +00:00
Bryan Boreham e47360f8dc Warn, don't error, if unable to remove network in 'weave stop' 2016-01-20 16:18:09 +00:00
Bryan Boreham 6035b54277 Send back an http error code in case of error, so Docker is clear something went wrong 2016-01-20 15:36:42 +00:00
Bryan Boreham a238130613 Give more explanation if we can't find weave to talk to 2016-01-20 15:36:34 +00:00
Bryan Boreham 998be42a52 Don't crash if no default subnet available 2016-01-20 15:36:25 +00:00
Matthias Radestock bafa3f4f4e Merge pull request #1912 from weaveworks/wily-vagrant
Update Vagrant to use Wily 15.10
2016-01-20 14:59:40 +00:00
Adam Harrison 14944da396 Ignore stderr in proxy_addrs 2016-01-20 14:24:59 +00:00
Adam Harrison a3974c2aeb Abort inspect exec rewrite unless Containers node is present 2016-01-20 14:24:28 +00:00
Bryan Boreham 6570b0ba1a Merge branch '1.4' 2016-01-20 14:06:00 +00:00
Bryan Boreham 13ec517f94 Merge pull request #1910 from weaveworks/1909-forEachRoute-panic
cope with errors during route traversal
2016-01-20 14:05:10 +00:00
Adam Harrison 2a2b2da097 Update Vagrant to use Wily 15.10 2016-01-20 09:17:07 +00:00
Matthias Radestock 43419815f4 bypass netlink.LinkByIndex
since we are seeing some cases where it returns "Link not found" when
the link is in fact there.
2016-01-19 16:36:16 +00:00
Matthias Radestock b5256f7b71 refactor: inline
This eliminates the unnecessary indirection via interface names,
instead identifying the interface by its index.
2016-01-19 16:36:16 +00:00
Matthias Radestock 0caa9dd652 cope with errors during route traversal
Fixes #1909.
2016-01-19 15:28:31 +00:00
Bryan Boreham dd7271aaa2 Merge pull request #1866 from weaveworks/901-peername-from-machine-id
Derive peer name from product_uuid; LGTM
2016-01-18 15:29:44 +00:00
Matthias Radestock 133c16f989 document new reboot behaviour
...and generally tidy up IPAM stop/restart docs.
2016-01-18 14:57:03 +00:00
Matthias Radestock e631fb0d69 derive the bridge MAC from the system (aka BIOS) UUID
...if possible. This provides a stable peer identity across
reboots. If we cannot determinbe the system UUID then we revert to a
random MAC, as before.

Fixes #901.
2016-01-18 14:56:55 +00:00
Bryan Boreham 5e1e8ec543 Suggest user disables systemd timeout if using plugin 2016-01-18 11:45:17 +00:00
Adam Harrison 432c1904da Merge pull request #1890 from weaveworks/1889-vendor-mesh
Change import location for mesh
2016-01-15 17:18:31 +00:00
Adam Harrison 8a691814e2 Document vendored dependency management commands 2016-01-15 16:17:07 +00:00
Peter Bourgon 553c8b734d git submodule add weaveworks/mesh 2016-01-15 16:03:42 +01:00
Peter Bourgon 3767a680e8 Makefile doesn't need to build mesh/*.go anymore 2016-01-15 15:57:01 +01:00
Peter Bourgon e27b320ede Update import location for mesh 2016-01-15 15:57:01 +01:00
Peter Bourgon 90afa7db93 git rm -rf mesh 2016-01-15 15:57:01 +01:00
Bryan Boreham efd4fc4704 Merge pull request #1901 from weaveworks/1897-weaveutil-plugin-network
move plugin network creation/removal into weaveutil
2016-01-15 11:07:38 +00:00
Matthias Radestock d770532b08 improve error handling 2016-01-15 08:53:04 +00:00
Matthias Radestock 31b303a419 move plugin network creation into weaveutil
Note that we remove the ability to set the weavemesh network name, or
disabling it altogether. This was always poorly support, since the
removal operation only ever operated on the default name. The option
was also not listed in the usage, though it was in the docs.
2016-01-15 08:52:57 +00:00
Matthias Radestock 9578798ec0 move plugin network removal into weaveutil
This does require starting containerised weaveutil with docker.sock
volume mounts.
2016-01-15 07:58:21 +00:00
Matthias Radestock 8061ea4079 don't attempt to delete the mesh network on plugin termination
It's pointless and inconsistent. Firstly, deletion will fail if there
are any attached containers. Secondly, we run the plugin with
restart=always, so it will get restarted and the network re-created.

Removal of the network does still happen on `weave stop|reset`, if
possible.
2016-01-15 06:21:11 +00:00
Tom Wilkie a83b58cd27 Merge pull request #1896 from weaveworks/tweak-circle
Improve build times on CircleCI
2016-01-14 08:57:20 -08:00
Bryan Boreham 8eeb6dd836 Only rebuild without coverage if we're going to publish 2016-01-14 15:33:46 +00:00
Bryan Boreham bd7e5d6921 Do a build before the 'go test'; perversely this runs faster 2016-01-14 15:29:58 +00:00
Bryan Boreham 7c1e80ca89 Don't do coverage on vendored directories 2016-01-14 14:16:28 +00:00
Bryan Boreham 9aae1fa3c9 Save the ~/docker directory in cache because rebuild_image stores things there 2016-01-14 13:02:32 +00:00
Adam Harrison 5bf440d558 Merge branch '1.4' 2016-01-14 12:07:21 +00:00
Adam Harrison c391092ea6 Add release v1.4.2 2016-01-14 11:40:17 +00:00
Matthias Radestock d97c385b4e make 'make lint' run gocyclo (again) 2016-01-13 17:02:52 +00:00
Matthias Radestock 1d3ca061ad tiny refactor: tweak init order for better grouping 2016-01-13 16:48:49 +00:00
Matthias Radestock d50975a185 refactor: extract password determination 2016-01-13 16:23:00 +00:00
Matthias Radestock 6261ce0865 extract our peer name creation 2016-01-13 16:23:00 +00:00
Tom Wilkie b4682bbc8c Fresh clones need git submodule update --init 2016-01-13 08:22:35 -08:00
Adam Harrison d9a32e563c Merge pull request #1861 from weaveworks/1657-1656-vendor-and-build-in-container
Build in a container by default, using go 1.5 and vendored dependencies.
2016-01-13 15:55:51 +00:00
Adam Harrison b0e98f99d0 Merge pull request #1888 from weaveworks/refactor-overlay-init
refactor overlay creation
2016-01-13 15:35:11 +00:00
Tom Wilkie 6684ae8316 Do a git submodule update every time we enter the build container. 2016-01-13 05:58:41 -08:00
Matthias Radestock 9b4a5d1cb4 tiny refactor: just move around some code
The router name derivation uses the result of createOverlay, so move
it closer to that.
2016-01-13 13:52:09 +00:00
Matthias Radestock 9f79e5be54 refactor: rename
Conceptually, an OverlaySwitch is just a single Overlay.
2016-01-13 13:52:09 +00:00
Matthias Radestock aa44b66a31 refactor: extract overlay creation 2016-01-13 13:52:09 +00:00
Matthias Radestock 3a367595d7 derive routerName from networkConfig.Bridge.Interface() 2016-01-13 13:52:00 +00:00
Matthias Radestock e5c256daa1 add Bridge.Interface() 2016-01-13 13:50:18 +00:00
Matthias Radestock f12ec3b295 refactor(ish): make fastdp hold on to interface
rather than just the MTU
2016-01-13 13:50:18 +00:00
Matthias Radestock 9f0399f27e refactor: extract DNSServer creation 2016-01-13 13:48:38 +00:00
Matthias Radestock cc72f7d3ee cosmetic 2016-01-13 13:20:17 +00:00
Tom Wilkie c098aefed9 Build in a container by default, using go 1.5 and vendored dependancies.
- Use submodules for vendoring.
- Don't go clean, now that everything is in .pkg.
- sudo -E as we need the environment variables.
- Install -race version of std so the tests can run without sudo.
- Cache the build image on circle, use the rebuild-image script from tools.
2016-01-13 04:40:18 -08:00
Matthias Radestock 6a103aef27 cosmetic 2016-01-13 11:49:15 +00:00
Matthias Radestock 80df5a7906 cosmetic 2016-01-13 11:39:32 +00:00
Adam Harrison 28561237ab Merge branch '1.4' 2016-01-13 11:10:30 +00:00
Adam Harrison b3a29bec1b Merge pull request #1886 from weaveworks/issues/1869-leave-plugin
Allow plugin to keep running on 'weave launch'
2016-01-13 11:08:54 +00:00
Bryan Boreham b055c9a4a2 Fool-proofing 2016-01-13 10:33:49 +00:00
Matthias Radestock 799160c5c2 remove "encryption -> pcap" cruft
As of e12dbb460 (#1758) we no longer force the usage of pcap when
encryption is enabled. Hence...

- we no longer need to figure out whether the router was started with
  a password when re-attaching it from the proxy. We therefore remove
  the code for that.

- there is no longer any mode in which we pass both `--datapath` and
  `--iface` options to the router. Previously this would only happen
  when encryption was enabled and the only overlay used for
  connections was sleeve. It is not clear what the behaviour is when
  these conditions do not hold, so, to be safe, we prevent the
  specification of both flags.
2016-01-13 10:27:25 +00:00
Bryan Boreham 3daceac668 Allow pre-existing plugin on 'weave launch-plugin' 2016-01-13 10:05:02 +00:00
Adam Harrison 29ebeeaff5 Merge pull request #1191 from weaveworks/1047-same-ip-on-restart
Don't delete record of IP allocation immediately after container death
2016-01-13 09:46:12 +00:00
Matthias Radestock 257d88f48e Merge branch '1.4' 2016-01-13 09:26:13 +00:00
Matthias Radestock 4611e8825a Merge branch 'latest_release_doc_updates' into 1.4 2016-01-13 09:25:34 +00:00
Matthias Radestock 00e4729533 Merge pull request #1872 from weaveworks/issues/1871-address-docs
Documentation on IP addresses, routes and networks
2016-01-13 09:24:31 +00:00
Bryan Boreham 517a2e0e0a Fix nonzero exit code for a pre-existing plugin on launch;
do this purely for the 'plugin running' case, not 'restarting' etc.
2016-01-12 17:06:38 +00:00
Bryan Boreham bb8c7c599c Revert "don't launch anything when plugin is running"
This reverts commit 3ade796e8d.
2016-01-12 16:51:49 +00:00
Bryan Boreham 0d0fc39236 More review feedback 2016-01-12 15:35:34 +00:00
Bryan Boreham e468399616 Extend the timeout for dead containers to 30 seconds,
but remove them if they are destroyed, to reduce starvation
when users are creating and destroying containers quickly.
2016-01-12 14:38:44 +00:00
Bryan Boreham b2b293a8ee Added 'ContainerDestroyed()' callback from docker client 2016-01-12 14:38:44 +00:00
Bryan Boreham 2f885a7906 Reclaim all addresses on restart 2016-01-12 14:38:44 +00:00
Bryan Boreham 7985e43e68 Add 'weave restart' command 2016-01-12 14:38:44 +00:00
Bryan Boreham f84b933d7c Leave container allocations for a time after death
so they will be reclaimed if the container is restarted.
Still cancel pending operations immediately a container dies
2016-01-12 14:38:44 +00:00
Bryan Boreham 4672e9ec1f Generalise ticker so we can use it for more than paxos,
and call tryPendingOps() from it so we eventually re-try operations
2016-01-12 14:38:44 +00:00
Adam Harrison a5ddba03f7 Merge branch '1.4' 2016-01-12 14:28:16 +00:00
Adam Harrison 302a5a4efc Merge pull request #1884 from weaveworks/issues/1882-check-after-subscribe
Fix race condition in weavewait
2016-01-12 14:28:03 +00:00
Bryan Boreham 3b29e8e6f2 Check for existing interfaces and routes after subscribing to receive new ones 2016-01-12 12:27:55 +00:00
Bryan Boreham a1dff70ba2 Review feedback 2016-01-11 11:55:11 +00:00
Matthias Radestock 9336cc4121 Merge branch '1.4' 2016-01-11 11:49:49 +00:00
Matthias Radestock 12671be260 Merge branch 'latest_release_doc_updates' into 1.4 2016-01-11 11:49:22 +00:00
Matthias Radestock d2ad5ddb01 oops 2016-01-11 11:47:22 +00:00
Tom Wilkie 73df093e48 Merge pull request #1864 from weaveworks/shrink-travis-usage
Shrink travis usage
2016-01-11 11:27:02 +00:00
Bryan Boreham 9a4adccec6 Remove inconsistent information about restart policy 2016-01-11 11:20:40 +00:00
Matthias Radestock abea21245d rename Makefile target
since travis is no longer using it
2016-01-11 10:33:33 +00:00
Bryan Boreham f90390974a Add page explaining IP addresses, networks and routes 2016-01-11 10:30:37 +00:00
Matthias Radestock 0b4f1b5af0 cosmetic: whitespace 2016-01-11 00:42:14 +00:00
Matthias Radestock 9933a4a368 refactor: tweak overlay & bridge initialisation sequence
for clarity
2016-01-11 00:13:29 +00:00
Matthias Radestock c3f2150b5b cosmetic: whitespace 2016-01-11 00:03:37 +00:00
Matthias Radestock 46566e2159 refactor: extract sleeve crypto initialisation 2016-01-10 23:52:46 +00:00
Matthias Radestock 1d8d098450 for Travis, this no longer is a go project
Travis insists that one picks a project language. There is no go left
in the steps executed by travis. Instead we have Python, Ruby and
shell. Let's pick the first...

Picking Python makes travis unhappy with "Can not perform a '--user'
install. User site-packages are not visible in this
virtualenv". Dropping the '--user' flag fixes that.
2016-01-09 14:21:23 +00:00
Matthias Radestock 1038cbd1a3 shrink Travis usage
There is no point running builds, tests, lints on Travis, since we
already do that on Circle.

The only thing we aren't doing (and can't do) on Circle is doc
publishing, so now Travis does just that.
2016-01-09 14:01:27 +00:00
Matthias Radestock 21a2cdd579 Merge branch '1.4' 2016-01-08 18:14:56 +00:00
Matthias Radestock f598ae297b Merge branch 'latest_release_doc_updates' into 1.4 2016-01-08 18:14:23 +00:00
Bryan Boreham 4b0fe502f0 Document the --no-multicast-route flag 2016-01-08 17:12:20 +00:00
Matthias Radestock d9b9ce6bcd simplify gitignore 2016-01-08 15:23:37 +00:00
Matthias Radestock 4fffa6fa43 fix typo 2016-01-08 15:11:21 +00:00
Tom Wilkie c0cd9dffc2 Merge pull request #1862 from weaveworks/1651-pause-differently
Fix race condition in ipam TestHTTPCancel
2016-01-08 14:07:06 +00:00
Bryan Boreham f91d7bb7e4 Rewrite TestHTTPCancel to avoid fiddling inside Allocator 2016-01-08 13:37:15 +00:00
Matthias Radestock 3e6f31c8e2 add missing dependencies and netgo checks 2016-01-08 13:27:37 +00:00
Matthias Radestock 19b53cdeb1 refactor: get rid of superfluous rule 2016-01-08 12:06:38 +00:00
Matthias Radestock c6cc10169f refactor: put all dependencies in one place 2016-01-08 12:05:48 +00:00
Bryan Boreham 987d89632d Merge pull request #1847 from weaveworks/1613-weaveutil
extract script utilities into single binary; LGTM
2016-01-07 18:53:25 +00:00
Bryan Boreham 8804f88c93 Merge pull request #1856 from weaveworks/no-gossip-sender-gc
get rid of GossipSender gc; LTGM
2016-01-07 17:29:54 +00:00
Bryan Boreham 3c654bc036 Merge pull request #1561 from weaveworks/proxy-retry-attach
Proxy retry attaching containers; fixes #1556
2016-01-07 17:27:19 +00:00
Paul Bellamy 8ddbb3d8af [proxy] Keep retrying container attaches until they succeed. 2016-01-07 17:09:34 +00:00
Tom Wilkie 422e9b58cd Merge pull request #1857 from weaveworks/issues/864-gce-retry
Stop masking failures in gce hosts destroy
2016-01-07 14:53:02 +00:00
Matthias Radestock 64a017c972 Merge branch '1.4' 2016-01-07 14:36:08 +00:00
Matthias Radestock e4295a2da9 don't attach rewrite_etc_hosts helper container to weave
...since that is a) inefficent and b) can block when IPAM hasn't had
consensus.

We can only end up in this situation when DOCKER_HOST is pointing at
the weave proxy and we are running `weave run|attach` with
`--local`. So it's very much an edge case.

Fixes #1858.
2016-01-07 14:32:52 +00:00
Matthias Radestock 216a0fe4fc refactor: WEAVE_CIDR=none is redundant when --net=host 2016-01-07 14:29:51 +00:00
Bryan Boreham 604f5c599a Check if there are any machines to destroy, and stop masking failures 2016-01-07 13:40:34 +00:00
Matthias Radestock 9aa4313d37 refactor 2016-01-06 17:38:40 +00:00
Matthias Radestock 969dc4e527 get rid of GossipSender gc
With the per-broadcast-source GossipSenders gone, we can get rid of
GossipSender gc...

Instead of maintaining a Connection->GossipSender map in the
GossipChannels - which we then need to gc when connections get closed
- we keep gossip_channel_name->GossipSender maps in LocalConnections.

Access to the map is guarded by a separate lock, rather than re-using
the LocalConnection lock. This reduces lock contention and risk of
deadlock.

In the GossipSenders, we replace the Stop() method with a signalling
channel, i.e. senders stop when that channel gets closed. Handily, the
LocalConnection.finished channel fits that description. So when a
LocalConnection's run loop terminates, any existing and future
associated GossipSenders will end up terminating too.
2016-01-06 17:38:40 +00:00
Bryan Boreham bbd0b15792 Merge pull request #1855 from weaveworks/gossip-broadcast-stall-3
don't stall gossip broadcasting when there are blocked connections; LGTM
2016-01-06 16:43:37 +00:00
Matthias Radestock 99b7fbbc71 optimisation: stop GossipSender on send error 2016-01-05 17:18:41 +00:00
Matthias Radestock 486eb740b5 optimisation: abort GossipSender.deliver when stopped 2016-01-05 17:18:41 +00:00
Matthias Radestock c6a73b8a75 don't stall broadcasting when there are blocked connections
Previously broadcasts were being handled by one GossipSender per
broadcast source (and channel), which sends the broadcast to all next
hops, and hence can stall when a single destination is stalled.

Here we get rid of these per broadcast source GossipSenders. Instead
broadcasts are sent to per-connection GossipSenders for all next hops.

For this we use the existing GossipSenders we have set up for ordinary
gossip. In order to deal with broadcasts they need one GossipData cell
per broadcast source, since only broadcasts from the same source can
be Merge()ed. So we add a PeerName->GossipData map of cells, in
addition to the existing cell for ordinary gossip.

The GossipSender goroutine picks one of the cells at a time, Encode()s
the contents and sends it. It prefers the ordinary gossip cell over
the broadcast cells since typically ordinary gossip is more important.

To reduce coupling, the GossipSenders don't actually know how to
construct protocol messages. They just invoke a couple of functions
for that - one for ordinary gossip and one for broadcast - which are
supplied by the GossipChannel.

There are two downsides to this change:

1. broadcasts get encoded per connection, rather than just once

2. we can potentially end up with O(n_peers^2) cells, each containing
accumulated (via GossipData.Merge()) broadcasts. For this to happen,
the peer must

- deal with gossip from most nodes. This doesn't happen in
  (near)complete connection topologies. Hypercube topologies are
  probably the worst case uniform topology. And a star topology is the
  worst case for a single (the centre) peer.

- have backlogged connections to most of its neighbours, without
  those connections being completely stalled (since that would cause
  heartbeat timeouts to terminate them).

Furthermore, for this to matter in practise, the accumulated broadcast
GossipData must be sizeable:

- For topology gossip, GossipData is just a set of PeerNames. Which
  takes very little space and is bounded, since there is a finite
  number of peers. And, if we could get rid of workaround for #1793
  (cbaa92dcb), then topology broadcasts would only ever contain
  information about the source peer, so the GossipData would contain
  just one PeerName.

- IPAM only employs broadcast during initialisation and shutdown.

- DNS broadcasts contain DNS entries for containers on the source
  peer. Each entry will typically be 100-200 bytes. The accumulated
  broadcast GossipData from a peer will contain entries for all the
  peer's DNS entries, worst case. This includes tombstones,
  i.e. entries for containers that have died. If there is churn,
  i.e. DNS entries being added and removed continuously, and the churn
  rate exceeds the rate at which we can forward those entries, then
  the accumulated broadcast GossipData can grow unbounded. Note that
  this is the case on master too; the difference here is that we can
  have up to n_peers copies of that GossipData.
2016-01-05 17:18:19 +00:00
Bryan Boreham 262f8915a8 Merge pull request #1826 from weaveworks/cleaner-gossip-sender
clean up GossipSender
2016-01-05 16:36:26 +00:00
Ilya Dmitrichenko b623e914c9 update year in copyright notices 2016-01-05 12:19:00 +00:00
Matthias Radestock 70bfcd033b Merge branch '1.4' 2016-01-04 11:14:28 +00:00
Matthias Radestock 80770d39e5 oops 2016-01-04 10:53:41 +00:00
Matthias Radestock beb15fa32c don't fail weave launch when plugin is disabled
Fixes #1851.
2016-01-04 10:35:44 +00:00
Matthias Radestock 1bec425510 Merge branch '1.4' 2016-01-04 09:46:35 +00:00
Matthias Radestock 0adf7626d0 Merge branch 'latest_release_doc_updates' into 1.4 2016-01-04 09:45:56 +00:00
Matthias Radestock 9c17fe259c add ToC to build instructions 2016-01-04 09:41:39 +00:00
Matthias Radestock ecab4b4716 correct image names 2016-01-04 09:35:17 +00:00
Matthias Radestock c3e6669d18 Merge branch '1.4' 2016-01-03 16:45:41 +00:00
Matthias Radestock 7660ad761a oops
I broke this in 370212609.

Fixes #1848.
2016-01-03 16:42:39 +00:00
Matthias Radestock d010000583 fall back to invoking weaveutil in a container
As a result, `weave --local ...` now runs both netcheck and
docker-tls-args.
2016-01-02 14:13:29 +00:00
Matthias Radestock 419f2ff71b move fastdp helpers into weaveutil
so the weave script can invoke them w/o having to run a container
2016-01-02 14:00:44 +00:00
Matthias Radestock 4ebcd355f6 move docker_tls_args into weaveutil
and also give users a clue what went wrong when docker isn't running
2016-01-02 14:00:44 +00:00
Matthias Radestock ec872d7b45 move netcheck into weaveutil 2016-01-02 14:00:44 +00:00
Matthias Radestock 9801e00ba6 add weaveutil
just a placeholder for now
2016-01-02 14:00:44 +00:00
Matthias Radestock 79452d3a9a cosmetic(ish) 2016-01-02 14:00:23 +00:00
Matthias Radestock 0ee22af32d refactor: further simplify fastdp initialisation 2016-01-02 13:17:40 +00:00
Matthias Radestock 13f37edb64 refactor: simplify fastdp initialisation 2016-01-02 13:17:28 +00:00
Matthias Radestock 75d9e95b15 appease linter 2016-01-02 12:35:10 +00:00
Matthias Radestock d59594c6b0 Revert "refactor: pass procfs location to docker_tls_args on command line"
changed my mind

This reverts commit be8260ae79.
2016-01-02 10:50:13 +00:00
Matthias Radestock 4a6b72c649 Revert "cosmetic"
changed my mind

This reverts commit 20a8488a15.
2016-01-02 10:49:22 +00:00
Matthias Radestock 20a8488a15 cosmetic
PROCFS is always set
2016-01-02 00:14:18 +00:00
Matthias Radestock be8260ae79 refactor: pass procfs location to docker_tls_args on command line
...rather than via an env var. This is cleaner.
2016-01-01 23:52:46 +00:00
Matthias Radestock 9c31de9cb9 refactor: replace some 'if's with && and || expressions 2015-12-31 15:36:18 +00:00
Matthias Radestock c1e8c9c537 Merge branch '1.4' 2015-12-31 13:26:55 +00:00
Matthias Radestock c8ff2de3b3 properly deal with unavailable docker server api version
Fixes #1845.
2015-12-31 12:51:16 +00:00
Matthias Radestock 24d1c73012 Merge branch '1.4' 2015-12-31 12:32:30 +00:00
Matthias Radestock 24a2e43547 Merge pull request #1841 from weaveworks/1840-weave-stop-plugin-complaint
don't complain in `weave stop` when plugin is not enabled

Fixes #1840.
2015-12-31 12:32:05 +00:00
Matthias Radestock 2816899543 refactor: extract helper to invoke fastdp functions from script 2015-12-31 12:19:51 +00:00
Matthias Radestock 394d2add68 Merge branch '1.4' 2015-12-31 10:59:10 +00:00
Matthias Radestock a9d212c888 don't fail on missing docker_tls_args
instead just don't auto-detect TLS args in that case.

This makes `weave --local launch` work (again).

Fixes #1844.
2015-12-31 10:43:46 +00:00
Matthias Radestock c1b1276aaf refactor: simplify 2015-12-31 10:16:37 +00:00
Matthias Radestock 370212609c Show expected error message when docker_tls_args fails.
And also make the error message more meaningful.

Fixes #1843.
2015-12-31 10:05:41 +00:00
Matthias Radestock 159bad54b0 prettier usage 2015-12-31 01:42:01 +00:00
Matthias Radestock 1cc7ca18ba Merge branch '1.4' 2015-12-31 01:11:06 +00:00
Matthias Radestock 281937cf82 document weave launch-router --trusted-subnets
and eliminate duplication

Fixes #1842.
2015-12-31 01:09:51 +00:00
Matthias Radestock d11b6e8075 don't complain in weave stop when plugin is not enabled 2015-12-30 23:40:27 +00:00
Matthias Radestock 4e22922256 refactor: rename netcheck.go -> main.go, for consistency 2015-12-30 23:17:48 +00:00
Matthias Radestock 8f01f6e85c make some rules more generic, depending on *.go instead of main.go 2015-12-30 23:14:53 +00:00
Matthias Radestock 27f477a075 refactor: introduce a small helper so we don't repeat ourselves 2015-12-30 22:40:30 +00:00
Matthias Radestock 82ac69be4e cosmetic 2015-12-30 22:23:16 +00:00
Matthias Radestock 0f357cdf7c Merge branch '1.4' 2015-12-30 20:27:18 +00:00
Matthias Radestock 7709c6d0bd Merge branch 'latest_release_doc_updates' into 1.4 2015-12-30 20:26:06 +00:00
Matthias Radestock ef3e478506 Merge pull request #1804 from weaveworks/1774-trouble
Update 'reboots' info

Fixes #1774.
2015-12-30 19:51:09 +00:00
Matthias Radestock 93eef26d0b reword 2015-12-30 19:38:13 +00:00
Matthias Radestock 14d78cf08c Update 'reboots' info 2015-12-30 19:32:18 +00:00
Matthias Radestock 872d88acb6 Merge branch '1.4' 2015-12-30 19:14:51 +00:00
Matthias Radestock e96a63f550 Merge branch 'latest_release_doc_updates' into 1.4 2015-12-30 19:14:33 +00:00
Matthias Radestock 7a5b69f850 cosmetic 2015-12-30 19:13:57 +00:00
Matthias Radestock a71d2a1682 move things around on troubleshooting page
- level 2 headings for top-level instead of level 3
- put all status reporting as L3s under one L2 heading
- add 'Reboots' to ToC
- move 'Stopping weave' into its own section and and move that
2015-12-30 19:06:04 +00:00
Matthias Radestock f0f0e6f36d reword "Contact Us" 2015-12-30 18:37:57 +00:00
Matthias Radestock 6ecdf69b88 replace partially broken link soup 2015-12-30 17:42:49 +00:00
Matthias Radestock 58de14ff65 optimisation: don't re-assign our ShortID if nothing got gc'ed 2015-12-30 14:07:23 +00:00
Matthias Radestock 4d304146f3 refactor: inlining 2015-12-30 12:29:23 +00:00
Matthias Radestock e9520215a0 refactor: introduce a helper
which has a very narrow purpose, and can use 'defer' to release the
lock, which is nice.
2015-12-30 12:09:19 +00:00
Matthias Radestock a2b192c472 we no longer need the GossipChannel lock around GossipSender.Send 2015-12-30 12:09:19 +00:00
Matthias Radestock 52575915d0 clean up GossipSender and make it more self-contained
In particular don't require Send() to be serialised by the caller.

We split up the triple(!) purpose 'cell' channel into:

1) a 'cell' member, holding pending GossipData or nil
2) a 'more' channel, for signalling that 'cell' has been filled
3) a 'stop' channel, for requesting termination
2015-12-30 12:09:19 +00:00
Matthias Radestock 0ecc0ee02e tiny refactor 2015-12-30 12:07:56 +00:00
Matthias Radestock 8101dea338 remove some noisy logging 2015-12-24 21:25:25 +00:00
Matthias Radestock 373f8a4463 oops 2015-12-24 21:23:35 +00:00
Matthias Radestock 8846274c42 optimisation: terminate connection actorLoop asap on error 2015-12-24 14:25:25 +00:00
Matthias Radestock c2356ebcde optimisation: stop sending gossip on dead connections
An error in SendProtocolMsg indicates that the connection is
permanently broken. So there is no point continuing to attempt to send
gossip on it.

The connection will eventually be removed from LocalPeer, and any
associated GossipSenders will be gc'ed, but that doesn't happen
straight away, so this change is about not doing unnecessary work in
the meantime.
2015-12-24 12:27:33 +00:00
Matthias Radestock 33812f7666 tiny refactor: rename 2015-12-23 18:44:09 +00:00
Matthias Radestock f58e3bf2a9 refactor: relocate an optimisation -> reduce duplication 2015-12-23 18:27:59 +00:00
Matthias Radestock 5473995305 remove maxFeasibleMessageLen check
since the root cause got fixed by 3cd199e85
2015-12-23 15:29:35 +00:00
Bryan Boreham 1796582032 Merge pull request #1773 from weaveworks/1761-lazy-route-calculation-1
lazy route calculation; LGTM
2015-12-23 12:27:02 +00:00
Bryan Boreham 4214a09392 Merge branch '1.4' 2015-12-23 11:09:13 +00:00
Bryan Boreham e833ab672d Merge branch '1.4' 2015-12-23 11:08:23 +00:00
Bryan Boreham 257b1a5353 Add the plugin to the list of images to tag and push 2015-12-23 11:00:58 +00:00
Matthias Radestock 39e29fd40b refactor(ish): cleaner / more idiomatic GossipSender flush 2015-12-23 10:57:36 +00:00
Bryan Boreham ec0c5f0375 Merge pull request #1800 from weaveworks/1568-release-process
Add more steps to the release process; fixes #1568 and #1506
2015-12-23 10:52:02 +00:00
Bryan Boreham b45ac75735 Merge pull request #1825 from weaveworks/1824-idempotent-env-restore
make `eval $(weave env)` idempotent; LGTM.  Fixes #1824
2015-12-23 10:48:35 +00:00
Bryan Boreham ac53d7d47b Merge pull request #1801 from weaveworks/1723_publish_plugin
Add the plugin to the list of images to tag and push. Fixes #1723
2015-12-23 10:46:15 +00:00
Matthias Radestock c7c669fd11 make eval $(weave env) idempotent
so that `weave $(env --restore)` does the right thing regardless of
how many times `eval $(weave env)` was invoked previously.

Fixes #1824.
2015-12-23 09:08:56 +00:00
Bryan Boreham fdc7e15192 Merge branch '1.4' 2015-12-22 17:36:06 +00:00
Bryan Boreham ba266ef8d3 Add release v1.4.1 2015-12-22 17:25:47 +00:00
Bryan Boreham f434fad3be Merge pull request #1822 from weaveworks/1820-unix-only
Only pass $DOCKER_HOST if it is a Unix socket - fixes #1820
2015-12-22 17:16:40 +00:00
Bryan Boreham bab758ebf9 Revert "Launch the proxy via unix socket in last test"
- since we won't now be copying $DOCKER_HOST

This reverts commit d8cfbc4e08.
2015-12-22 17:01:04 +00:00
Bryan Boreham 800f4663b6 Only pass through $DOCKER_HOST in exec_remote() if it is a Unix socket;
a TCP socket may be secured by TLS, in which case we can't use it.
2015-12-22 17:01:04 +00:00
Matthias Radestock 78ba69ef9f Merge branch '1.4' 2015-12-22 15:25:48 +00:00
Matthias Radestock b1b62afa90 Merge pull request #1812 from weaveworks/1810-warn-with-dns
Issue a warning on --with-dns option to proxy, because it was removed

Fixes #1810
2015-12-22 15:12:27 +00:00
Bryan Boreham 6b90ef7078 Clarify message 2015-12-22 14:56:40 +00:00
Matthias Radestock 593e3d3593 Merge remote-tracking branch 'upstream/1.4' 2015-12-22 14:02:15 +00:00
Matthias Radestock 2ed4b45c24 Merge pull request #1817 from weaveworks/1815-docker-version
Check we have Docker 1.9 or newer before trying to remove a network

Fixes #1815.
2015-12-22 14:01:55 +00:00
Matthias Radestock 716f50c4e4 Merge remote-tracking branch 'upstream/1.4' 2015-12-22 13:50:10 +00:00
Matthias Radestock 47ba9748b4 Merge pull request #1814 from weaveworks/1778-check-running
Handle weave containers in 'restarting' state

Fixes #1778.
2015-12-22 13:49:19 +00:00
Bryan Boreham 077ad4208f Merge pull request #1813 from weaveworks/1797-plugin-version
Show plugin version; Fixes #1797
2015-12-22 13:12:38 +00:00
Bryan Boreham c19edec364 Add 'weave stop-xxx' instructions for 'already running' case 2015-12-22 13:04:06 +00:00
Bryan Boreham 0c2aa494ae Reduce duplication 2015-12-22 13:03:04 +00:00
Bryan Boreham 73e0a6bb0a Inform user about weave containers in state 'restarting' 2015-12-22 13:01:00 +00:00
Bryan Boreham abf1db0045 Merge pull request #1819 from weaveworks/1818-dont-launch-when-plugin-running
don't launch anything when plugin is running; fixes #1818 . LGTM.
2015-12-22 12:55:57 +00:00
Matthias Radestock 2f94d727ea Merge remote-tracking branch 'upstream/1.4' 2015-12-22 12:49:00 +00:00
Matthias Radestock b40b78ece0 refactor docker_sock_volume_mount() 2015-12-22 12:47:36 +00:00
Matthias Radestock 3ade796e8d don't launch anything when plugin is running
...just as we don't launch anything if either the router or proxy are
running.

Fixes #1818.
2015-12-22 12:30:53 +00:00
Bryan Boreham 7c2e808924 Check we have Docker 1.9 or newer before trying to remove a network 2015-12-22 12:10:48 +00:00
Bryan Boreham 7d2227c5a4 Add plugin version to 'weave version' 2015-12-22 10:50:02 +00:00
Bryan Boreham 8a517d5c7c Issue a warning on --with-dns option to proxy, because it was removed 2015-12-22 10:00:06 +00:00
Matthias Radestock cb6176fd8a tweak ProtocolSender API
make SendProtocolMsg return an error; this isn't used at any call
sites (yet) but is TRTTD.
2015-12-21 18:24:22 +00:00
Matthias Radestock b93ce1cea5 refactor: no need for GossipSender.sent 2015-12-21 18:09:50 +00:00
Matthias Radestock 3be28523c9 cosmetic 2015-12-21 17:56:38 +00:00
Matthias Radestock 592335092c refactor: tweak GossipChannel API 2015-12-21 17:42:20 +00:00
Matthias Radestock 6c4e9fccd3 cosmetic 2015-12-21 17:28:22 +00:00
Matthias Radestock 6903b8d458 refactoring for consistency 2015-12-21 17:18:12 +00:00
Matthias Radestock 274265f001 typo 2015-12-21 17:03:03 +00:00
Bryan Boreham ceac3c3d83 Merge branch '1.4' 2015-12-18 09:54:22 +00:00
Bryan Boreham 48658f011f Merge pull request #1805 from weaveworks/script-indentation
Fix indentation of weave script
2015-12-18 09:53:12 +00:00
Bryan Boreham 4ebb13fa94 Fix indentation of netcheck if-statement 2015-12-17 16:23:42 +00:00
Bryan Boreham 5580b7a522 Add more steps to the process 2015-12-17 13:55:26 +00:00
Adam Harrison bda8cff7c1 Merge branch '1.4' 2015-12-17 13:09:20 +00:00
Adam Harrison ff9a6b91a4 Merge branch 'latest_release_doc_updates' into 1.4 2015-12-17 13:07:48 +00:00
Adam Harrison 86fc37a968 Merge pull request #1799 from weaveworks/plugin-docs
Extend plugin docs
2015-12-17 12:24:12 +00:00
Bryan Boreham 37ae169323 Merge remote-tracking branch 'origin/master' into latest_release_doc_updates 2015-12-17 11:48:23 +00:00
Bryan Boreham 1ce0df4e94 Explain multiple networks 2015-12-17 11:42:41 +00:00
Bryan Boreham db5ba61915 Improve formatting 2015-12-17 11:41:44 +00:00
Bryan Boreham 31006002f3 Add the plugin to the list of images to tag and push 2015-12-17 11:08:00 +00:00
Bryan Boreham db120fb9be Add release v1.4.0 2015-12-17 10:30:06 +00:00
Adam Harrison ea6e171a7f Merge pull request #1794 from weaveworks/warn-stop-plugin
Warn user if weave network is in use on stop or reset of plugin
2015-12-17 10:27:58 +00:00
Bryan Boreham 246cb76e50 Add note to docs about not removing the plugin 2015-12-17 10:26:08 +00:00
Bryan Boreham ecf4a82b99 Warn user if weave network is in use on stop or reset 2015-12-17 10:05:36 +00:00
Bryan Boreham 357f67255e Move logging of Docker API info to callers 2015-12-17 08:25:51 +00:00
Adam Harrison 7015ab8717 Merge pull request #1780 from weaveworks/1748-no-with-dns
Remove WITH_DNS variable from weave script
2015-12-16 15:59:24 +00:00
Bryan Boreham 67195bc9f3 Remove WITH_DNS variable and deprecate --with-dns option to 'weave run' 2015-12-16 14:55:35 +00:00
Adam Harrison ce18509aa7 Merge pull request #1781 from weaveworks/1754-no-with-dns
Remove --with-dns option from proxy
2015-12-16 14:02:30 +00:00
Bryan Boreham cbaa92dcb2 Revert "don't broadcast-gossip other peer when adding a connection"
while we consider how to fix it properly.

This reverts commit cbb2ad018d.
2015-12-16 13:46:37 +00:00
Bryan Boreham f09d87c112 Merge pull request #1796 from weaveworks/gossip-test-connection-mistake
fix gossip test connection peer initialisation and connection deletion mistakes
2015-12-16 13:36:50 +00:00
Adam Harrison 7a8bba4d95 Merge pull request #1776 from weaveworks/1752-plugin-multicast
Plugin optional multicast route
2015-12-16 13:28:03 +00:00
Bryan Boreham e6e414a017 Merge pull request #1795 from weaveworks/issues/1772-fix-fastdp-address-already-in-use
Introduce limited retry on vxlan vport creation. LGTM; fixes #1772.
2015-12-16 13:22:50 +00:00
Matthias Radestock 81df06b3f4 fix DeleteTestGossipConnection
This is a one-sided operation, so we shouldn't be touching the
remote's Peers.

Also fix the associated test... When both 1 and 2 have lost their
connection to 3, they no longer have a route to 3 and hence gc it.

And because they no longer have a route, gossip from them won't get
through to 3.
2015-12-16 13:18:05 +00:00
Matthias Radestock 5401037743 refactor: inline mockGossipConnection.Connect
Also change Start() order in AddTestGossipConnection to be more
pleasing to the eye; the order isn't actually important.
2015-12-16 12:45:12 +00:00
Matthias Radestock 9d9768ee6f fix incorrect peer initialisation on test gossip connections
We were creating peers with NewPeerFrom, which copies the Version (but
not connections). That's not what happens for a real connection, where
remote peers are always created with an initial version of 0.

The mistake results in brokenness: when we subsequently receive a
topology update for that peer with the same version then we ignore it,
even though the update contains connection information which is new to
us.

Related, it is conceptually wrong to call FetchWithDefault on the
remote router. That is not what happens for a real connection - the
FetchWithDefault occurs in the symmetric counterpart.
2015-12-16 12:33:07 +00:00
Bryan Boreham 3043217b2c Extend --no-multicast-route test to plugin 2015-12-16 12:17:25 +00:00
Bryan Boreham afcb84d42c Set up static route for multicast, with option to turn off 2015-12-16 12:17:25 +00:00
Adam Harrison d5aad8f8d2 Introduce limited retry on vxlan vport creation
The kernel processes vport deletion asynchronously, meaning that we can
sometimes fail to recreate vxlan vports on startup with an EADDRINUSE
error. We compensate by retrying a small number of times with a short
sleep on encountering this error, failing as before on a different error
or exhaustion of retries.
2015-12-16 11:51:28 +00:00
Bryan Boreham c46febd7df Fix Makefile so weavewait* are statically linked
- the `-tags netgo` was being ignored by an interaction with the newer tags
2015-12-16 11:45:10 +00:00
Bryan Boreham f880da4827 Merge pull request #1722 from weaveworks/fdp-high-level-overview
Add fast datapath high level overview
2015-12-16 10:49:31 +00:00
Bryan Boreham 85c9cf43f7 Merge pull request #1689 from weaveworks/1586-alternate-docker-sock
Support weave script running against non-standard DOCKER_HOST.
2015-12-16 10:35:46 +00:00
Adam Harrison ce90d2389b Merge pull request #1790 from weaveworks/1783-veth-name
Prefix interface names with 'veth' so NetworkManager ignores them
2015-12-16 10:34:32 +00:00
Bryan Boreham d8cfbc4e08 Launch the proxy via unix socket in last test
- proxy copies permissions from $DOCKER_HOST socket if available, so in
   this case it was not accessible because we were booting via a TCP
   socket
2015-12-16 10:14:44 +00:00
Paul Bellamy 88fad251aa add test for proxy against docker on non-standard unix socket
Means we need to rebuild the gce images

(also small improvement re tmpdir)
2015-12-16 10:14:15 +00:00
Bryan Boreham 1a1d8b7c74 Prefix interface names with 'veth' so NetworkManager ignores them 2015-12-16 10:01:57 +00:00
Paul Bellamy a4ef96690e support alternate DOCKER_HOST settings when launching the plugin 2015-12-15 18:12:31 +00:00
Paul Bellamy f28ad350bd make weave and the proxy work with tcp-only dockers via DOCKER_HOST 2015-12-15 18:02:59 +00:00
Paul Bellamy 0afc3db383 First pass at passing DOCKER_HOST=unix://* through to the weave and proxy 2015-12-15 18:02:27 +00:00
Paul Bellamy ca1cce3232 Makefile should use DOCKER_HOST env var 2015-12-15 18:02:27 +00:00
Adam Harrison f9228eeb46 Merge pull request #1738 from weaveworks/1727-local-plugin
"mesh mode" plugin
2015-12-15 17:53:26 +00:00
Adam Harrison 0c077b8bb1 Merge pull request #1782 from weaveworks/1709-json-func
Add a 'json' function for 'weave report -f'
2015-12-15 17:09:02 +00:00
Bryan Boreham 0e9991f7d4 Make plugin create 'weave' network by default 2015-12-15 16:52:37 +00:00
Bryan Boreham 41482aff01 Update plugin README and documentation 2015-12-15 16:52:37 +00:00
Bryan Boreham 791fc9d6b1 Return fake 'gateway address' to avoid requiring consensus during initialization 2015-12-15 16:52:37 +00:00
Bryan Boreham 776ccac00a Pin docker API version to 1.21 2015-12-15 16:52:30 +00:00
Bryan Boreham 1539009362 Simple smoke-test for 'local' plugin network 2015-12-15 16:47:33 +00:00
Bryan Boreham 9542b77a34 Extend smoke-test framework for weaveplugin 2015-12-15 16:47:33 +00:00
Bryan Boreham b709cdeab5 Create local and global network from the same driver and create local-scope weave network by default on weave launch 2015-12-15 16:47:18 +00:00
Bryan Boreham e2f936fde3 Rework version check
- extract function so we can use the check elsewhere
- use shell variable expansion rather than exec-ing 'cut'
2015-12-15 16:40:43 +00:00
Bryan Boreham a4ca389f2e Make the plugin scope (local or global) an option 2015-12-15 16:31:07 +00:00
Bryan Boreham c973808b20 Merge pull request #1758 from weaveworks/issues/82-optional-encryption
Make encryption optional; fixes #82, #1788. LGTM.
2015-12-15 15:23:58 +00:00
Adam Harrison e12dbb4605 Disable pcap optimisation of encrypted sleeve
Prior to optional encryption support, enabling encryption disabled the
fast datapath overlay (because it doesn't support encryption) but left
the OVS datapath netdev in place for bridging (so that users could
switch encryption on and off without resetting the bridge). In this
situation the ODP miss handler is guaranteed to be invoked for every
packet, so as an optimisation the weave script configured the router to
use pcap to capture packets from the bridge as that is slightly more
efficient. The introduction of optional encryption means the guarantee
no longer holds, and so the optimisation must be removed.
2015-12-15 14:51:21 +00:00
Bryan Boreham c341399498 Document 'json' function 2015-12-15 13:52:28 +00:00
Bryan Boreham d1ba4ab7f4 Merge pull request #1755 from weaveworks/issues/1741-weave-no-multicast-route
Add options to disable multicast route - LGTM; fixes #1741
2015-12-15 10:17:09 +00:00
Adam Harrison 85d4b1f137 Smoke test trusted subnets 2015-12-14 12:13:16 +00:00
Adam Harrison b9792f8f96 Document trusted subnets
Update features and troubleshooting markdown.
2015-12-14 12:13:16 +00:00
Adam Harrison e0cb9cf24d Restore leading whitespace to weave status 2015-12-14 12:13:16 +00:00
Adam Harrison 4e41d4d451 Add trusted subnets to weave status
`weave status` now displays the list of specified trusted subnets, and
`weave staus connections` shows the encryption state of individual
connections.
2015-12-14 12:13:16 +00:00
Adam Harrison 059cc65b55 Fallback to encrypted sleeve on a per-connection basis
If overlay encryption is required between peers, the fast datapath
forwarder returns an error rather than aborting the process, allowing
the overlay switch to fall back gracefully to an encrypted sleeve
overlay connection.
2015-12-14 12:13:11 +00:00
Adam Harrison d434b50dfc Include trust level in features exchange
Add a 'Trusted' feature to the protocol exchange which indicates whether
the remote considers us to be reachable via a secure network; overlay
encryption will be disabled in the event that both peers agree. For
backwards compatibility purposes a default value of untrusted is assumed
if the feature is missing.
2015-12-14 12:12:25 +00:00
Adam Harrison 96f69583e7 Smoke test --no-multicast-route 2015-12-14 11:53:06 +00:00
Adam Harrison ce25f58639 weave launch-proxy accepts --no-multicast-route 2015-12-14 11:53:06 +00:00
Adam Harrison 367b73e6e3 Introduce nomcast weavewait 2015-12-14 11:53:06 +00:00
Adam Harrison 98a7d3fc99 weave run and weave attach accept --no-multicast-route 2015-12-14 11:53:06 +00:00
Bryan Boreham 6fd0f121a0 Add a 'json' function for 'weave report -f' 2015-12-12 14:44:54 +00:00
Bryan Boreham 68d6c262d1 Remove --with-dns option from proxy 2015-12-12 14:12:39 +00:00
Bryan Boreham 1d9ef76080 Remove mention of --with-dns option; see #1748 and #1754 2015-12-12 13:58:14 +00:00
Bryan Boreham b51b1adfcd Merge pull request #1767 from weaveworks/1765-test-gossip-surrogate-failure
better emulation of connections in gossip tests. Fixes #1765.
2015-12-11 17:20:23 +00:00
Matthias Radestock b1cb0c298d refactor 2015-12-10 14:37:30 +00:00
Matthias Radestock d7835eabfb lazy route calculation
Instead of calculating all routes in one go, we calculate them when
needed.

Except for unicast routes, and broadcast routes from ourself. We still
calculate those eagerly because they are needed to route locally
captured/fdp-missed packets, and performing route calculcations in
that critical path increases the chances of dropping packets due to
not keeping up.

Well, technically only the established & symmetric routes are needed
for the data plane, but we might as well calculate the equivalent
routes for the control plane - it keeps the code simple and uniform.

Calculating all routes is O(n_peers^2), so this change represents a
huge saving in situations where not all of them are needed, which is
quite common, especially when the topology is evolving rapidly.

One downside of this new approach is that we can no longer suppress
OnChange callbacks when the data plane routes remain unchanged. This
means we will be purging the FDP flows more frequently than before,
e.g. when only the control plane topology changed, e.g. new
connections appeared that haven't been marked as 'established'
yet. It's a small price to pay, fixable if we really care, and in any
case making FDP flow invalidation more fine-grained would be a better
approach.

Fixes #1761.
2015-12-10 14:20:59 +00:00
Matthias Radestock ab902b45aa refactor: introduce a helper to reduce duplication 2015-12-10 10:56:18 +00:00
Matthias Radestock ed14561afd refactor: rename 2015-12-10 10:54:20 +00:00
Matthias Radestock 86d2db5cc2 better emulation of connections in gossip tests
real Connections do not process gossip until after AddConnection.
mockChannelConnection wasn't behaving in that way, which resulted in
some sporadic test failures since it would cause some gossip to get
processed too early, which in turn would trigger gc of some of the
just-received peers, which we would then find missing in the test
assertions.

To fix this we introduce a latch on mockChannelConnection which closes
when the remote end is ready to receive gossip. Effectively this
emulates the entering of LocalConnection.receiveTCP after the call to
AddConnection completes.

Unfortunately an open latch will cause sendPendingGossip to block. We
get around that by abandoning checks in "half-connected" connection
states.

Fixes #1765.
2015-12-10 10:54:10 +00:00
Bryan Boreham 700851cdd5 Add a note about connecting up peers 2015-12-10 10:40:48 +00:00
Adam Harrison c3e1f5a6c6 .gitignore tls binary 2015-12-10 10:08:04 +00:00
Bryan Boreham 9bf18b1761 Merge pull request #1769 from weaveworks/ditch-run-with-timeout
Wins the prize for "best add-to-delete ratio in a PR this year"
2015-12-09 13:56:54 +00:00
Matthias Radestock 1374e4c4de ditch RunWithTimeout test helper
It breaks stack traces on failure.

We can just rely on running `go test -timeout ...` instead, which we
already do in tools/test.
2015-12-09 13:20:57 +00:00
Matthias Radestock 0ef57a102f cosmetic: remove unnecessary comment 2015-12-09 12:37:53 +00:00
Adam Harrison 1c7954a43d Merge pull request #1728 from weaveworks/1676-ipam-plugin
Docker IPAM plugin
2015-12-09 11:07:46 +00:00
Matthias Radestock be1dc8ef96 Merge branch '1.3' 2015-12-09 10:34:52 +00:00
Matthias Radestock 18fc6ccc03 remove redundant code in test 2015-12-09 10:32:14 +00:00
Matthias Radestock 7ec46983aa Merge branch '1.3' 2015-12-08 23:08:35 +00:00
Matthias Radestock eddcf93942 oops 2015-12-08 23:08:19 +00:00
Matthias Radestock 42807f7b8a Merge branch '1.3' 2015-12-08 23:07:06 +00:00
Matthias Radestock 0b521272ae prevent peer duplication in tests
and correct the test assertions accordingly - they make more sense
now.

Fixes #1766.
2015-12-08 23:06:02 +00:00
Bryan Boreham ecd93bbfe4 Resolve weave IP every time we need it, in case it changed 2015-12-08 16:59:34 +00:00
Bryan Boreham a6f07fbaac Move baseUrl usage up to httpVerb 2015-12-08 16:59:34 +00:00
Bryan Boreham f87876c1c3 Fetch the default subnet from weave to use as the ipam driver 'pool' 2015-12-08 16:59:34 +00:00
Bryan Boreham ec3de1a072 Introduce ipam plugin 2015-12-08 16:59:32 +00:00
Bryan Boreham c1d2c159f0 Expand listener skeleton to support IPAM driver 2015-12-08 16:58:55 +00:00
Bryan Boreham 9f86e2ba43 Moved net plugin to its own directory 2015-12-08 16:58:53 +00:00
Adam Harrison d0be36dc9b Merge branch '1.3'
Conflicts:
	Makefile
2015-12-08 16:53:47 +00:00
Adam Harrison af604a1477 Merge pull request #1760 from weaveworks/make-test-tls
Move test/tls program into Makefile so it builds inside the build container
2015-12-08 16:41:59 +00:00
Bryan Boreham c981cff450 Move build of test/tls program into Makefile so it builds in the build container 2015-12-08 16:14:53 +00:00
Bryan Boreham ab1033c26c Merge pull request #1736 from weaveworks/remove-unknown-peer-error
remove UnknownPeerError for quicker convergence and efficiency. LGTM.
2015-12-04 11:00:05 +00:00
Adam Harrison 01706df7c8 Merge pull request #1753 from weaveworks/1751-remove-unused-vars
remove CLIENT_TLS_ENABLED and DOCKER_CLIENT_TLS_VERIFY, as they're unused
2015-12-04 10:19:09 +00:00
Adam Harrison 827a7c1cf1 Merge branch '1.3' 2015-12-04 10:09:15 +00:00
Adam Harrison d14d9933b4 Merge pull request #1750 from weaveworks/add-some-quotes
quote $@
2015-12-04 10:08:34 +00:00
Adam Harrison af946893f0 Merge pull request #1749 from weaveworks/remove-eqeq-non-posixism
'==' is not POSIX
2015-12-04 10:08:26 +00:00
Paul Bellamy 245ae5e987 remove CLIENT_TLS_ENABLED and DOCKER_CLIENT_TLS_VERIFY, as they're unused 2015-12-02 17:17:04 +00:00
Matthias Radestock 29f3d711c6 Merge branch '1.3' 2015-12-02 15:34:07 +00:00
Matthias Radestock 3909936cc8 cosmetic(ish) use PROXY_PORT 2015-12-02 15:33:38 +00:00
Matthias Radestock 0602c91c54 quote $@ 2015-12-02 15:28:41 +00:00
Matthias Radestock a7bdb02a2b Merge remote-tracking branch 'upstream/master' 2015-12-02 14:33:28 +00:00
Matthias Radestock 2cfaf5a119 Merge branch '1.3' 2015-12-02 14:23:28 +00:00
Matthias Radestock 20a48f05b3 fix (harmless) typo 2015-12-02 14:22:23 +00:00
Matthias Radestock 4e70fb7f9d '==' is not POSIX 2015-12-02 14:20:29 +00:00
Adam Harrison 1f438dbf71 Merge pull request #1740 from weaveworks/1694-symlink-into-var-run-2
Symlink sockets to /var/run/weave/weave.sock from inside the proxy
2015-12-02 14:12:02 +00:00
Adam Harrison 619d0e2bdd Merge pull request #1730 from weaveworks/1725-plugin-dns
Fix DNS integration in Weave docker plugin
2015-12-02 09:49:21 +00:00
Bryan Boreham ec420c66d4 Review feedback 2015-12-01 16:47:47 +00:00
Paul Bellamy ac1cf633c7 clarify some variable shadowing 2015-12-01 16:16:39 +00:00
Paul Bellamy 6f25d2170d [proxy] have symlinking respond to WEAVE_DEBUG not DEBUG 2015-12-01 15:51:16 +00:00
Paul Bellamy 295a2ced32 [proxy] treat addrs prefix with / as unix addrs 2015-12-01 15:45:32 +00:00
Matthias Radestock cbb2ad018d don't broadcast-gossip other peer when adding a connection
This is more efficient since broadcasting about other peers is
strictly redundant. Any change to the peers will be broadcast by
those peers anyway. And SendAllGossipDown takes care of informing new
peers about others on first connect, and periodic gossip take care of
missed broadcasts.

The only reason we did broadcast about the remote peer is to reduce
the liklihood of UnknownPeerError and the associated throwing away of
gossip. This was always a bit of kludge, and is no longer necessary
since UnknownPeerError is gone.

Now peers only ever broadcast information about themselves. Which,
unlike information about other peers, is always authorative and most
up-to-date. Which is nice.
2015-12-01 13:10:06 +00:00
Matthias Radestock 7e15eabe65 remove UnknownPeerError
when encountering an unknown peer in received gossip, rather than
ignoring the entire gossip we create a placeholder Peer. This has
version 0 and uid 0, which means it will be replaced by any complete
peer information subsequently received via gossip.
2015-11-30 16:17:16 +00:00
Bryan Boreham eb9b5b535f Merge branch '1.3' 2015-11-30 16:16:09 +00:00
Bryan Boreham a13351a9eb Merge pull request #1712 from weaveworks/issues/1577-interpose-bridge-netdev
Optional intermediary bridge netdev. Fixes #1577.
2015-11-30 15:54:14 +00:00
Bryan Boreham 74fdf6beec Merge pull request #1732 from weaveworks/1731-merge-peer-has-short-id
update Peer.HasShortID as part of topology merge
Fixes #1731
2015-11-30 15:53:23 +00:00
Paul Bellamy cd7c88e5a5 [proxy] Symlink sockets to /var/run/weave/weave.sock from inside the proxy
We copy docker.sock owner to symlinks. Permissions are not copied,
because the permissions will inherit from the target.

use versioned exec image to create symlinks
2015-11-30 15:45:30 +00:00
Bryan Boreham a22b88ed89 Track endpoints so we can register the right address with DNS 2015-11-30 14:27:33 +00:00
Bryan Boreham 5eb99fe5ef Get container IP for various networks 2015-11-30 14:27:33 +00:00
Bryan Boreham 85e465cfa4 Eliminate 'dockerer' 2015-11-30 14:27:33 +00:00
Bryan Boreham e101dde62e Extract 'api' package 2015-11-30 14:27:33 +00:00
Adam Harrison 1980ffea30 Merge pull request #1702 from weaveworks/issues/1639-ipam-diagnostics
Show some IPAM stats with `weave status ipam`
2015-11-30 14:20:13 +00:00
Adam Harrison 0935e0a13d Merge branch '1.3' 2015-11-30 14:09:44 +00:00
Adam Harrison b2b68119fc Merge pull request #1719 from weaveworks/issues/1653-make-dir
Ensure /var/run/weave directory exists before telling Docker to use it
2015-11-30 13:57:37 +00:00
Adam Harrison 4420057d4f Merge pull request #1716 from weaveworks/issues/1714-complete-addr-1.3
Ensure `weave connect` attempts connection immediately
2015-11-30 13:52:13 +00:00
Bryan Boreham bd2b8df7c5 Refactor to use Weave's docker client and watcher 2015-11-30 13:25:20 +00:00
Matthias Radestock 068bbe0837 Merge branch '1.3' 2015-11-30 13:19:21 +00:00
Bryan Boreham 7e0e1fbaad Adjust formatting after review feedback; hostnames up to 14 chars will now align 2015-11-30 12:07:59 +00:00
Bryan Boreham 9723476392 Merge pull request #1708 from weaveworks/gce-connect-fix
Connect to gce boxes as vagrant so we can access docker unix socket
2015-11-30 11:45:30 +00:00
Matthias Radestock 9dee2f2230 update Peer.HasShortID as part of topology merge
This was missing.

There are two parts to this change:

1. updating the Peers.byName mapping when HasShortID changed (in
addition to the existing update on ShortID change). We need to be
careful about the sequencing here - both ShortID and HasShortID must
be set between the calls to deleteByShortID and addByShortID, since
the former is meant to delete the existing entry (hence use the old
values) and the latter add the new entry (hence use the new values).

2. update a peer when the received info has the same version and UID
but the current record has HasShortID=false, and the received info has
HasShortID=true. This caters for the case where we receive an update
about a weave 1.2+ peer first via a pre-1.2 peer (which does not
transmit ShortIDs, and always sets HasShortID=false) and subsequently
via a 1.2+ peer. The former update will force us to communicate with
that peer over the 'sleeve' overlay. We want to accept the latter
update, even though the version is the same, in order to update the
ShortID and HasShortID, so we can switch to fastdp.

Fixes #1731.
2015-11-29 16:32:50 +00:00
Matthias Radestock 175f38414e cosmetic 2015-11-28 20:15:57 +00:00
Bryan Boreham 8bbf8231d2 Show which range is being allocated in weave report 2015-11-26 17:24:41 +00:00
Bryan Boreham 2fbbb802bd Don't assert invariants when printing status
- if it's broken you might appreciate being able to print it out
2015-11-26 17:24:41 +00:00
Bryan Boreham cb65a80dce Reworded IPAM service description in weave status
following review in #1702
2015-11-26 17:24:41 +00:00
Bryan Boreham 3a9bcbcf6b Remove specialised knowledge of IPAM from weave status formatter
and unnecessary info from `weave report` output
2015-11-26 17:24:40 +00:00
Bryan Boreham e38018ab1e Add warning to main ipam status if all IPs owned by unreachable peers 2015-11-26 17:23:49 +00:00
Bryan Boreham 044c6474b2 Remove counting of ring tokens, since it isn't useful to end-user.
Previously the count of tokens was claimed to be a count of addresses in use,
which is incorrect.
Also rename `appendAddresses` to `appendOwned` since it doesn't involve addresses.
2015-11-26 17:23:49 +00:00
Bryan Boreham 5f42a4d95e Hold stats by peer identity not nickname
so we can print the peer name for each ownership.
Also avoid crashing if we don't own anything
2015-11-26 17:23:49 +00:00
Bryan Boreham 6d3fd6da07 Simplify ipam status format
Don't use the word "universe" in user-visible output; it is an internal term.
Removed everything but owned ranges from 'weave status ipam' results, for consistency with similar functions
2015-11-26 17:23:49 +00:00
Alvaro Saurin 34e7996f2f Show some IPAM status at /status/ipam 2015-11-26 17:23:47 +00:00
Bryan Boreham f2d7a28258 Add docker plugin README 2015-11-26 17:18:59 +00:00
Adam Harrison ba6f8da1e4 Merge pull request #1670 from weaveworks/issues/1634-block-6783-6784
Forbid traffic to the Weave port from containers
2015-11-26 16:52:34 +00:00
Adam Harrison 0a5e79891d Merge pull request #1724 from weaveworks/1674-move-plugin
Move Weave docker plugin into this repo
2015-11-26 15:34:15 +00:00
Bryan Boreham 901bf63cb8 Fix printf error caught by lint 2015-11-26 15:19:57 +00:00
Bryan Boreham 350b8efb0b Move Weave docker plugin into this repo 2015-11-26 14:40:28 +00:00
Adam Harrison 2f69b4d190 Mention WEAVE_MTU 2015-11-26 10:39:41 +00:00
Adam Harrison 57a15a4e96 Add fast datapath high level overview 2015-11-26 10:36:52 +00:00
Adam Harrison 13042002d7 Merge pull request #1663 from weaveworks/issues/1592-fdp-miss-counter
Add FDP miss counter to reports
2015-11-25 17:21:03 +00:00
Adam Harrison 8ac745b4e5 Lock read of miss counter 2015-11-25 17:05:19 +00:00
Adam Harrison 8a4f038ec4 Merge pull request #1662 from weaveworks/issues/1571-upstream-dns-report
DNS upstream servers report
2015-11-25 16:47:14 +00:00
Adam Harrison 890522f6f4 Add hidden weave bridge-type command 2015-11-25 16:31:32 +00:00
Adam Harrison c8aa032051 Eliminate function name stutter 2015-11-25 16:31:32 +00:00
Adam Harrison 9830c146d0 The bridge netdev is always named weave 2015-11-25 16:31:32 +00:00
Adam Harrison 00c9164fdb Pass WEAVE_NO_BRIDGED_FASTDP to remote for testing 2015-11-25 16:31:32 +00:00
Adam Harrison a31e7118b4 Optional intermediary bridge netdev 2015-11-25 16:31:32 +00:00
Matthias Radestock 2058ce3f3a refactor: change Routes.RandomNeighbours return for consistency
PeerNameSet -> []PeerName, which is what the other functions
return. This is also easier to deal with at the call site.
2015-11-25 14:46:41 +00:00
Matthias Radestock 61e3bf4a20 cosmetic(ish) 2015-11-25 14:32:34 +00:00
Bryan Boreham ea5bae711b Ensure /var/run/weave directory exists before telling Docker to use it 2015-11-25 13:56:09 +00:00
Bryan Boreham 44a2c5fdff Merge pull request #1718 from weaveworks/constant-spacetime-connection-shutdown
LGTM. prevent unbounded number of goroutines for connection shutdown
2015-11-25 11:22:08 +00:00
Matthias Radestock 3b43960779 prevent unbounded number of goroutines for connection shutdown
We need Connection.Shutdown to be non-blocked, and the way we achieved
this is by spawning a goroutine. However, there can be a potentially
unbounded number of Connection.Shutdown invocations. For example, if
the TCP connection has gone bad then any Connection.SendProtocolMsg
invocation will end up invoking Connection.Shutdown. There can be many
such invocations until the Connection has been removed from the
various data structures (e.g. LocalPeer.connections and
GossipSender.senders). Hence we can end up with with an unbounded
number of spawned goroutines.

To fix this, we introduce a one-element error channel on the
connection. Connection.Shutdown does a non-blocking send on that, and
the Connection.actorLoop reads from it and terminates.

This will throw away all but the first error encountered, but that is
fine and not much different from what was happening before (where we'd
throw away all but one of the errors encountered).
2015-11-25 11:06:20 +00:00
Bryan Boreham 89f27ec99a Set default port number on address before checking in InitiateConnections, to fix #1714 2015-11-24 14:55:21 +00:00
Adam Harrison 82cf4358ce Add release v1.3.1 2015-11-23 12:06:10 +00:00
Paul Bellamy 0f9b117744 Connect to gce boxes as vagrant so we can access docker unix socket 2015-11-20 16:54:41 +00:00
Adam Harrison c420c21219 Merge pull request #1707 from weaveworks/revert-1696-1694-symlink-into-var-run
Revert "Automatically symlink /var/run/*.sock sockets to /var/run/weave/*.sock"
2015-11-20 16:27:04 +00:00
Paul Bellamy 3bae4b0d93 Revert "Automatically symlink /var/run/*.sock sockets to /var/run/weave/*.sock" 2015-11-20 16:23:40 +00:00
Adam Harrison 1432bd7a81 Merge pull request #1696 from weaveworks/1694-symlink-into-var-run
Automatically symlink /var/run/*.sock sockets to /var/run/weave/*.sock
2015-11-20 16:23:12 +00:00
Adam Harrison bdcf930e25 Merge branch '1.3' 2015-11-20 11:08:49 +00:00
Adam Harrison 2e42d74c59 Merge pull request #1706 from weaveworks/1683-update-docker-1.3
Raise minimum Docker version to 1.6
2015-11-20 11:06:00 +00:00
Bryan Boreham bbf26fc3e8 Raise minimum Docker version to 1.6 to address #1683 2015-11-20 10:44:45 +00:00
Bryan Boreham 6dcc42cdeb Merge branch '1.3' 2015-11-20 10:33:38 +00:00
Bryan Boreham 385b0aa07f Fix typo in -tls info string 2015-11-20 10:33:20 +00:00
Bryan Boreham f2b1ee3398 Merge branch 'latest_release_doc_updates' into 1.3 2015-11-20 10:30:28 +00:00
Bryan Boreham 2a2c60201f Merge pull request #1699 from weaveworks/issues/1693-fix-proxy-docs-tls-args
Fix erroneously hyphenated Docker TLS arguments; Fixes #1693.
LGTM
2015-11-20 10:27:34 +00:00
Matthias Radestock 53749156a7 Merge branch '1.3' 2015-11-19 20:58:14 +00:00
Matthias Radestock ee12b34334 eliminate a gossip inefficiency and dormant bug
Fixes #1704
2015-11-19 20:57:27 +00:00
Matthias Radestock b5a4aefe8b never broadcast empty nameserver gossip 2015-11-19 18:28:37 +00:00
Bryan Boreham c2d5cab1b8 Merge remote-tracking branch 'origin/1.3' 2015-11-19 15:30:20 +00:00
Bryan Boreham f25af8f7d6 Merge pull request #1698 from weaveworks/1697-copy-on-write-gossip-data
make GossipData immutable; Fixes #1697. Fixes #1450. Fixes #1452.
2015-11-19 14:58:32 +00:00
Paul Bellamy 33648b083c SSH into test vms on gce as 'vagrant' user 2015-11-19 14:10:52 +00:00
Alvaro Saurin eb79711e0a Added flow misses count 2015-11-19 15:05:16 +01:00
Alvaro Saurin 03ce6052cc Updated docs 2015-11-19 14:54:37 +01:00
Alvaro Saurin 7992bf4177 DNS upstream servers report 2015-11-19 14:54:23 +01:00
Alvaro Saurin ddb390d5ec Forbid traffic to the Weave port from other containers
Make sure we have the Docker bridge IP before adding/removing iptables rules
2015-11-19 14:46:28 +01:00
Matthias Radestock 1500b1dc00 refactor: extract nameserver GossipData.copy
and remove a self-evident comment
2015-11-18 11:30:40 +00:00
Adam Harrison 9263d3e82c Fix erroneously hyphenated Docker TLS arguments 2015-11-18 10:24:46 +00:00
Adam Harrison 02b7fd53ed Merge tag 'v1.3.0' into latest_release_doc_updates
Resetting doc update branch for 1.3.0 release.
2015-11-18 10:14:10 +00:00
Matthias Radestock 3cd199e852 make GossipData immutable
The same piece of GossipData can be shared and subject to different
Merge operations. We either need to copy the data when we share it, or
create copies on modification, i.e. copy-on-write.

We choose the latter, since it is more efficient and there is just one
mutating operation.

Fixes #1697.
2015-11-17 20:13:46 +00:00
Paul Bellamy 77bc22baf5 [proxy] Auto-symlink /var/run/*.sock in from /var/run/weave/*.sock
Avoids the obscure warning for users
2015-11-17 17:25:21 +00:00
Paul Bellamy f57988761c Revert "Revert "Merge pull request #1580 from weaveworks/1579-launch-proxy-mount-h""
This reverts commit 7987d09438.
2015-11-17 17:15:28 +00:00
Adam Harrison 7987d09438 Revert "Merge pull request #1580 from weaveworks/1579-launch-proxy-mount-h"
This reverts commit 262352f8bb, reversing
changes made to 312691376a due to a bug
whereby `weave env` returns a unix domain socket with an incorrect path.

This change will be superceeded by #1694.
2015-11-17 16:28:31 +00:00
Adam Harrison 262352f8bb Merge pull request #1580 from weaveworks/1579-launch-proxy-mount-h
[proxy] dynamically mount -H dirs into the proxy when launching
2015-11-17 14:52:17 +00:00
Paul Bellamy e8c56a8e8e Review Feedback 2015-11-17 14:49:50 +00:00
Matthias Radestock 312691376a Merge remote-tracking branch 'upstream/master' 2015-11-17 13:57:08 +00:00
Matthias Radestock a9611c782b cosmetic: move comment 2015-11-17 13:56:18 +00:00
Adam Harrison bcc70b36fd Merge pull request #1679 from weaveworks/1539-no-detect-tls-flag
[proxy] add --no-detect-tls flag, and proxy always tries to detect TLS.
2015-11-17 13:55:43 +00:00
Matthias Radestock 9ee3b1bfbd add some timestamps to multiweave 2015-11-17 10:28:28 +00:00
Paul Bellamy e80a83b30b adding work around to the proxy /var/run warning 2015-11-17 09:40:34 +00:00
Paul Bellamy d80e72dfcd [proxy] dynamically mount -H dirs into the proxy when launching
This lets you use -H unix://*.sock outside /var/run/weave. Using a
socket directly in /var/run (i.e. /var/run/foo.sock), will reintroduce
the bug with namespaces not being GCed, so that is a warning.
2015-11-17 09:40:34 +00:00
Matthias Radestock d01c26e618 cosmetic: remove outdated comment
The deadlock described for SendProtocolMsg (if it was going via the
actor) cannot occur since all sending of broadcasts and gossip by
LocalPeer is mediated by GossipSenders, the interaction with which is
non-blocking.
2015-11-17 09:27:49 +00:00
Matthias Radestock cab2e11ca9 refactor: simplify per-connection GossipSender gc and creation
by putting it in one place and inlining some helper functions
2015-11-16 23:21:33 +00:00
Matthias Radestock b48994b1b3 cosmetic: move some functions 2015-11-16 23:01:20 +00:00
Matthias Radestock fb48acddb2 cosmetic: update comment 2015-11-16 19:27:31 +00:00
Paul Bellamy 7d627f7af4 Merge pull request #1673 from weaveworks/1440-cleanup
Move some netlink code to upstream library
2015-11-16 14:24:10 +00:00
Paul Bellamy f458491d88 [proxy] add --no-detect-tls flag, and proxy always tries to detect TLS. 2015-11-13 15:27:27 +00:00
Bryan Boreham de802f9d76 Work round docker-py assuming busybox is present (https://github.com/docker/docker-py/issues/852) 2015-11-13 11:44:08 +00:00
Bryan Boreham 804e6ba586 Cope with changes in docker-py structure.
Tests are now in a different directory,
and get sharded by module rather than individually.
2015-11-13 11:08:57 +00:00
Adam Harrison af3fc82b77 Add release v1.3.0 2015-11-12 16:49:33 +00:00
Adam Harrison 3bb7036cfd Runner depends on tools 2015-11-12 16:48:56 +00:00
Bryan Boreham d802eb485b Merge pull request #1664 from weaveworks/weave-launch-plugin
Add plugin support to weave script. LGTM.
2015-11-12 16:04:41 +00:00
Adam Harrison b4dd9c2490 Add plugin to features doc 2015-11-12 16:01:01 +00:00
Adam Harrison 04ab198e95 Set restart policy to 'always'
Docker attempts to recreate networks on startup which means the plugin
container has to be started. If it isn't started automatically by Docker
with a restart policy, it's not possible to start it manually because
Docker is blocked.
2015-11-12 14:58:54 +00:00
Adam Harrison c345700963 Add plugin to weave status 2015-11-12 14:58:54 +00:00
Adam Harrison b21afcb78f Implement weave launch-plugin and weave stop-plugin 2015-11-12 14:56:13 +00:00
Adam Harrison 7f65530b26 weave setup fetches plugin 2015-11-12 14:56:13 +00:00
Bryan Boreham e230eeb486 Use upstream netlink code 2015-11-12 13:08:56 +00:00
Bryan Boreham b1b03f3a97 Revert "Remove code coverage as temporary work-around to Docker 1.9 issue"
This reverts commit 65fe753a58.
2015-11-12 11:27:48 +00:00
Bryan Boreham 36ef6d8da2 Merge remote-tracking branch 'origin/1.2' 2015-11-12 11:27:01 +00:00
Bryan Boreham 28bb0dd3b0 Merge pull request #1671 from weaveworks/1666-remove-cont-dir
Remove containers directory bind-mount from proxy; fixes #1647 and #1666
2015-11-12 11:25:34 +00:00
Bryan Boreham 79f8a8f909 Merge remote-tracking branch 'origin/1.2' 2015-11-12 10:43:01 +00:00
Bryan Boreham bfe2513540 Merge pull request #1669 from dpw/fdp-fix-npd
Handle the case where Forward returns nil. Fixes #1661.
2015-11-12 10:38:29 +00:00
Bryan Boreham 2536aef737 Proxy doesn't need to mount the containers dir 2015-11-12 10:28:58 +00:00
Adam Harrison 0661ccdea9 Revert "Revert "Disable restart of docker""
This reverts commit 76db732f1b.
2015-11-11 10:10:17 +00:00
Adam Harrison 29f7015e58 Merge pull request #1665 from weaveworks/move-odp-helpers
Move ODP helper functions out to their own package
2015-11-11 09:56:24 +00:00
David Wragg 7dc1b50d3b Handle the case where Forward returns nil
Forward can return nil if the remote peer has HasShortID false.  That
can happen if we learn about a 1.2 peer from a 1.1  peer and attempt to
connect to it.

This change just fixes the panic.  HasShortID will never be set, so we'll
fall back to sleeve.  But if that occurs, if can be fixed by a restart of
the affected routers.
2015-11-10 23:17:01 +00:00
Bryan Boreham 682133a56a Move ODP helper functions out to their own package 2015-11-10 17:09:17 +00:00
Adam Harrison 76db732f1b Revert "Disable restart of docker"
This reverts commit a400a3dd09.
2015-11-10 10:24:58 +00:00
Matthias Radestock 64aa2b5cc3 refactor: remove weave overlay-isms from mesh 2015-11-09 20:56:04 +00:00
Matthias Radestock 1eed5fd271 cosmetic: don't mention UDP in mesh 2015-11-09 19:47:27 +00:00
Matthias Radestock dd7ffa4501 code docs: warn against nonce re-use by overlay connection 2015-11-09 19:46:53 +00:00
Adam Harrison 5e79da0c9c Merge pull request #1658 from weaveworks/tweak-circle
Upgrade CI to Docker 1.9 and work round issues
2015-11-09 17:55:27 +00:00
Bryan Boreham 65fe753a58 Remove code coverage as temporary work-around to Docker 1.9 issue 2015-11-09 17:18:59 +00:00
Bryan Boreham 17c835e672 Compress weave.tar to save upload time 2015-11-09 17:18:58 +00:00
Bryan Boreham fa5bcd0457 Lump some commands together to reduce CircleCI waiting overhead 2015-11-09 17:18:58 +00:00
Bryan Boreham 499d6312b7 Don't need --add-host except in non-FDP case because we put the
mappings in the outer /etc/hosts
2015-11-09 17:18:58 +00:00
Bryan Boreham 20d5903696 Update test template name to pull in new Docker version 2015-11-09 17:18:57 +00:00
Adam Harrison f039221ec9 Merge remote-tracking branch 'origin/create-mesh'
Closes #1659.
2015-11-09 17:16:35 +00:00
Matthias Radestock dc9f8762ca move generic communication substrate into its own 'mesh' package
This is mostly a matter of moving some files, changing package names,
changing some imports, and changing some type references.

We duplicate the odd constant & global var, and the intmac/macint
functions, since neither 'router' or 'mesh' nor, really,' common' are
a natural home for them.
2015-11-09 16:37:39 +00:00
Adam Harrison e5c69801a7 Merge remote-tracking branch 'origin/separate-overlay'
Closes #1648.
2015-11-09 16:17:41 +00:00
Matthias Radestock ab458368de refactor: move NetworkRouterStatus into its own file 2015-11-09 15:51:11 +00:00
Matthias Radestock 8eb680fcc9 refactor: separate out NetworkRouter-specific status 2015-11-09 15:51:11 +00:00
Matthias Radestock 71b05972f4 refactor: move NetworkRouter into its own file 2015-11-09 15:50:55 +00:00
Matthias Radestock 7deeb8dba5 refactor: separate NetworkRouter from Router 2015-11-09 15:47:08 +00:00
Matthias Radestock daad190188 refactor: split overlay.go to extract network overlay stuff 2015-11-09 15:47:08 +00:00
Matthias Radestock 7cc0052451 refactor: separate NullNetworkOverlay from NullOverlay 2015-11-09 15:47:07 +00:00
Matthias Radestock 18f8e29af8 refactor: separate NetworkOverlay from Overlay
...since connections only need to know about the latter.
2015-11-09 15:47:07 +00:00
Matthias Radestock d78f6614cc refactor: separate forwarder from overlay connection
...since the main connections only need to know about the former.

We make LocalConnection.Overlay (formerly '.forwarder') public since
the router needs access to it, and it shouldn't be doing that via a
private field.
2015-11-09 15:45:06 +00:00
Bryan Boreham 53ac43202a Merge pull request #1641 from weaveworks/1554-converge-on-peer-uid-change
better convergence when peers restart; fixes #1554.
2015-11-09 15:09:59 +00:00
Matthias Radestock bfb050c9cc better convergence when peers restart
Previously when a peer restarted, information about the new
incarnation (i.e. with a different UID) was not accepted by other
peers (and connections would be dropped) unless all knowledge of the
previous incarnation had been purged. This could result in a lot of
connection churn and hence connectivity disruption, and, in some
pathological cases, very slow convergence and hence acceptance of the
new incarnation into the network.

We now no longer drop connections when encountering different
incarnations of a peer. There are two situations when that can happen:

1) on connection establishment

we simply proceed

2) on receipt of gossip

to ensure convergence we

a) treat the UID as an additional discriminator when deciding whether
we should update our information about a peer with that which was
gossiped. Specifically, we update the information we hold when a) the
gossiped version is greater, or b) is the same and the UID is
greater.

b) include the UID in the information we update

c) move our own version number beyond any we receive for ourselves, if
the received UID differs from ours.

With (a) we establishes a total order of peer information across
several incarnations of the same peer. i.e. we consider information to
be fresher if it has a higher version, or the same version and higher
UID. This may seem somewhat counter intutive, since it will generally
treat information about new incarnations as older than old
incarnations, since incarnations always start life with version 1. But
to do better we'd need to establish a total order of incarnations that
matches their temporal occurrence. Which requires some sort of durable
state.

So instead we have (c). Through that we learn the highest version
number of any old incarnation of ourselves that other peers still
hold, and then make sure that our version is greater than
that. Essentially we continue where the old incarnations left
off. It's as if instead of restarting we had simply changed UIDs. And
due to (a) and (b) the information about the new incarnation of
ourselves, now with a higher version, will supersede that of the old
incarnations.

Fixes #1554.
2015-11-09 14:58:33 +00:00
Matthias Radestock 97622b961c remove cruft 2015-11-08 13:06:29 +00:00
Matthias Radestock b7e7c11a57 refactor: make Overlay setting more explicit 2015-11-08 12:29:36 +00:00
Matthias Radestock 59e11e4e8a refactor: more flexible Routes API 2015-11-08 11:15:31 +00:00
Matthias Radestock 39b0357517 Merge branch '1.2' 2015-11-08 11:04:48 +00:00
Matthias Radestock 878a12002c set http listen address solely through the weave script
Previously it was set by the script only in fastdp mode; and in the
router's main.go otherwise. Yet every interaction of the script with
weave assumes the port is the script's HTTP_PORT=6784. By always
starting the router with options to listen on that port we ensure that
the router is in fact listening where the script expects it to.

In doing this get rid of router.HTTPPort. We do need to hard-code the
port in the proxy instead, but relying on router.HTTPPort was flawed
anyway, for the above reasons.
2015-11-07 18:01:12 +00:00
Matthias Radestock d3d2863d52 refactor: get rid of const.go 2015-11-07 16:32:23 +00:00
Matthias Radestock f3f23b43b5 refactor: crypto doesn't need to be a generic overlay feature 2015-11-07 16:14:31 +00:00
Matthias Radestock 006262ed8f refactor: Connections don't need to know about overlay crypto 2015-11-07 16:10:00 +00:00
Matthias Radestock 519aef86fa refactor: split crypto code 2015-11-07 15:59:15 +00:00
Matthias Radestock 8bd77c0d47 refactor: get rid of router/utils.go
most functions end up in other files in the router package, but a few
land in common.
2015-11-07 15:45:29 +00:00
Matthias Radestock 7a5c910cd5 tiny refactor: inline a tiny single-use fun and move another 2015-11-07 12:44:13 +00:00
Matthias Radestock 4e34f2001c cosmetic 2015-11-07 11:14:11 +00:00
Matthias Radestock 54b7e2c874 tiny refactor: use checkWarn in a few more places 2015-11-07 11:08:44 +00:00
Matthias Radestock 19f89f7122 remove duplicate test
this is already covered in dns_fallback_test
2015-11-07 07:30:53 +00:00
Matthias Radestock 9f25d72a4a cosmetic 2015-11-07 05:43:20 +00:00
Adam Harrison 3e99b71e0f Merge pull request #1643 from weaveworks/refactor-forwarder-remote-address
Refactor: remove knowledge of overlay connectivity details from Local{Peer,Connection}
2015-11-06 16:02:10 +00:00
Matthias Radestock fb3b690c5f refactor: reduce coupling between LocalConnection and Forwarder 2015-11-05 21:27:14 +00:00
Matthias Radestock 18fe553d23 LocalConnection shouldn't have to know about remote UDP address
...and generally know less about how overlays establish connectivity.
2015-11-05 20:43:52 +00:00
Matthias Radestock e7ff6a2191 LocalPeer shouldn't have to know about remote UDP address
...and LocalConnection shouldn't have to remember it
2015-11-05 19:32:49 +00:00
Matthias Radestock ad15e5a234 cosmetic 2015-11-05 19:01:34 +00:00
Matthias Radestock 094c7aa438 cosmetic 2015-11-05 17:24:38 +00:00
Adam Harrison 472ed5a7d3 Merge pull request #1640 from weaveworks/1588-disable-docker-restart
Disable restart of docker in test 640
2015-11-05 15:40:01 +00:00
Adam Harrison f284300870 Merge pull request #1636 from weaveworks/1635-notation
Drop use of interval notation when printing ranges
2015-11-05 15:38:40 +00:00
Adam Harrison ab5f4410b6 Add release v1.2.1 2015-11-05 14:34:13 +00:00
Bryan Boreham a400a3dd09 Disable restart of docker 2015-11-05 14:20:38 +00:00
Bryan Boreham c4855e8123 Merge branch '1.2' 2015-11-05 12:41:39 +00:00
Adam Harrison 3abb657777 Document port security 2015-11-05 12:23:17 +00:00
Adam Harrison 4dd63d8f72 Bind the HTTP listener to localhost when fastdp enabled
Prevent containers from accessing the weave router control port when
fast datapath is in use.
2015-11-05 12:23:17 +00:00
Bryan Boreham 6c0bdec2c9 Merge pull request #1637 from weaveworks/issues/1632-http-localhost-bind
Bind router HTTP listener to localhost when fastdp enabled
LGTM.  Fixes #1632
2015-11-05 12:20:20 +00:00
Adam Harrison d6dd1f269a Document port security 2015-11-05 12:16:57 +00:00
Bryan Boreham 2bd23f3709 Merge branch '1.2' to pull in latest_release_doc_updates 2015-11-05 12:05:25 +00:00
Bryan Boreham 79dc464b83 Merge branch 'latest_release_doc_updates' into 1.2 2015-11-05 12:04:54 +00:00
Bryan Boreham 3dbd5b11d8 Segregate discussion of range and subnet, and explain subnet a bit 2015-11-05 11:32:06 +00:00
Bryan Boreham 549fd5fe29 Merge branch '1.2' 2015-11-05 11:30:53 +00:00
Bryan Boreham 0ab5c65185 Merge pull request #1630 from weaveworks/issues/1588-improve-proxy-restart-reattach-test
Improve proxy restart reattach test reliability
2015-11-05 11:25:31 +00:00
Bryan Boreham 5f4753f881 Segregate discussion of range and subnet, and explain subnet a bit 2015-11-05 10:13:06 +00:00
Bryan Boreham e03a45f8c5 Update docs to match loss of interval notation 2015-11-05 10:11:43 +00:00
Adam Harrison 67c2d53e59 Bind the HTTP listener to localhost when fastdp enabled
Prevent containers from accessing the weave router control port when
fast datapath is in use.
2015-11-04 17:42:24 +00:00
Bryan Boreham 7b01dd9794 Drop use of interval notation 2015-11-04 16:45:16 +00:00
Bryan Boreham 04e50ff02c Merge branch '1.2' 2015-11-04 16:40:30 +00:00
Bryan Boreham e57ccdc858 Merge branch 'latest_release_doc_updates' into 1.2 2015-11-04 16:39:43 +00:00
Bryan Boreham a73a65b48a Removed obsolete text referring to mixed auto-manual allocation, and clarify Range printout 2015-11-04 16:36:44 +00:00
Adam Harrison 781c805e10 Merge branch '1.2' 2015-11-04 15:32:17 +00:00
Adam Harrison 7c4af88911 Merge pull request #1606 from weaveworks/issues/1578_ufw_ubuntu
Add an iptables rule for letting weaveDNS requests in
2015-11-04 15:30:34 +00:00
Alvaro Saurin 0aca173e96 Add an iptables rule for letting weaveDNS requests in 2015-11-04 14:00:26 +01:00
Matthias Radestock 60db57a41c refactor: remove duplicate isKnownPeer function 2015-11-03 18:11:53 +00:00
Matthias Radestock df68f7dcb9 Merge branch '1.2' 2015-11-03 17:56:36 +00:00
Matthias Radestock e95e3cc29d Merge pull request #1624 from weaveworks/1593-more-peers
Better choice of peers for IPAM to transfer ownership to on `weave reset`

Fixes #1593.
2015-11-03 17:55:40 +00:00
Bryan Boreham 67e9310cc1 Review feedback 2015-11-03 17:01:27 +00:00
Adam Harrison 94984df047 Merge branch '1.2' 2015-11-03 16:57:15 +00:00
Adam Harrison 861bf953bf Merge pull request #1629 from weaveworks/1626-expose-names
Always add 'weave expose -h' argument to DNS
2015-11-03 16:32:13 +00:00
Adam Harrison 06eaac8690 Don't assert ethwe carrier via the proxy
The test script runs commands inside containers via docker exec to
ensure the ethwe carrier is up. We must not run these commands via the
proxy because it will interpose weavewait, which will block forever if
attachment has failed (e.g. due to #1556).
2015-11-03 15:42:37 +00:00
Adam Harrison 6b9e8816d1 Wait for proxy to become available after docker is restarted 2015-11-03 15:33:37 +00:00
Bryan Boreham cf9f715a28 Merge branch '1.2' 2015-11-03 15:31:51 +00:00
Bryan Boreham 08e043fea7 Always add 'weave expose -h' argument to DNS, and add smoke-test for this also 2015-11-03 15:23:28 +00:00
Bryan Boreham 54ba1009d3 Merge pull request #1608 from weaveworks/1600-start-networkmode
LGTM.  Fixes #1600
2015-11-03 15:14:15 +00:00
Adam Harrison 4a6a46fd7b Merge pull request #1627 from tomwilkie/mv-scheduler
Move scheduler to build-tools.
2015-11-03 14:44:52 +00:00
Adam Harrison 0eb7414f72 Merge pull request #1583 from weaveworks/move-runner-to-tools
Remove test runner; it now lives in build-tools.git
2015-11-03 14:44:46 +00:00
Tom Wilkie c02691a70c Move scheduler to build-tools. 2015-11-03 14:38:42 +00:00
Bryan Boreham 8742957f75 Tweak naming to be closer to code changes in nameserver 2015-11-03 14:15:49 +00:00
Bryan Boreham ace372cfc6 More extensive choice of transferee 2015-11-03 12:03:28 +00:00
Bryan Boreham 27c5f5f49f Fix title of test 2015-11-03 12:03:00 +00:00
Paul Bellamy ec5a1a3977 When container is started in host (or container) networkMode, we mount a noop weavewait, so it can continue
review feedback
2015-11-03 10:18:05 +00:00
Adam Harrison abc653c87d Fix merge breakage 2015-11-03 10:13:43 +00:00
Matthias Radestock 30a128c00b Merge branch '1.2' 2015-11-02 20:58:15 +00:00
Matthias Radestock 77c7963bde Merge pull request #1615 from weaveworks/1603-resort-in-encode
Hold DNS entries sorted case-insensitively until just before sending

Fixes #1603 and #1610.
2015-11-02 20:57:40 +00:00
Bryan Boreham b80c1343c3 Take steps to avoid the test timing out 2015-11-02 20:40:17 +00:00
Bryan Boreham e5c5fbcea3 Hold on to the lower-case version of a hostname, rather than re-computing it every time 2015-11-02 20:40:05 +00:00
Bryan Boreham fc7d04ce73 Condense Entries unit tests with helper function 2015-11-02 20:03:10 +00:00
Bryan Boreham 35f57b3ed2 Move decoding code next to encoding code 2015-11-02 20:01:40 +00:00
Bryan Boreham ed9ade05ea Improve merge asserts 2015-11-02 20:01:40 +00:00
Bryan Boreham f485b729bc Hold all entries sorted case-insensitively until just before sending, when we re-sort case-sensitively in Encode() 2015-11-02 20:01:40 +00:00
Bryan Boreham 64f7953423 Add unit test to check outbound mixed-case merging 2015-11-02 20:01:40 +00:00
Bryan Boreham fc1d837501 Extend unit test to cover mixed-case hostnames and daisy-chained gossip;
reduce mock gossip timer to 2 seconds to trigger more often during tests.
2015-11-02 20:01:40 +00:00
Matthias Radestock 6a238818da Merge branch '1.2' 2015-11-02 19:58:37 +00:00
Matthias Radestock 9800c43bfa refactor(ish): don't use reference in method that doesn't modify 2015-11-02 19:57:17 +00:00
Bryan Boreham b3cda39b0b Let IPAM pick any peer we know about to transfer ownership to, when shutting down 2015-11-02 18:34:58 +00:00
Adam Harrison 7e1b7a2fcd Merge branch '1.2' 2015-11-02 17:28:31 +00:00
Adam Harrison ccae8d42fd Merge remote-tracking branch 'dpw/fdp-probe-vxlan' into 1.2
Fixes #1599
2015-11-02 17:24:52 +00:00
David Wragg 38f78286c7 Probe whether the kernel has ODP vxlan support
It's possible to build that kernel with openvswitch, and vxlan, but
without the vport_vxlan module that glues them together.  And at
least one distro has actually done this.
2015-11-02 15:53:16 +00:00
Adam Harrison c3a53a6ec5 Merge remote-tracking branch 'upstream/1.2' 2015-11-02 15:21:06 +00:00
Bryan Boreham 2bbe6a2ad8 Merge pull request #1622 from weaveworks/fix-miekg-dns-truncation-test
LGTM
2015-11-02 15:09:57 +00:00
Adam Harrison f64f63f675 Handle truncated responses from upstream servers 2015-11-02 15:00:02 +00:00
Adam Harrison f0fb44f6d4 Update unit test for miekg DNS API change 2015-11-02 13:24:04 +00:00
Paul Bellamy fa972615e6 Merge pull request #1616 from weaveworks/1549-inspect-wait
Make inspect-rewrite wait for start
2015-11-02 11:00:23 +00:00
Bryan Boreham f7cb2ef25d have waitForStartByIdent() return an error 2015-10-30 13:46:30 +00:00
Bryan Boreham 949f8bb2e7 Move updateContainerNetworkSettings() into proxy 2015-10-30 13:34:16 +00:00
Bryan Boreham 5eaff802d4 Make inspect-rewrite wait if the start operation is still in progress 2015-10-30 13:34:16 +00:00
Matthias Radestock b37d428726 Merge branch '1.2' 2015-10-30 01:31:16 +00:00
Matthias Radestock a6336149f8 guard against chef not running
Provisioning on ubuntu/wily64 was tripping over this.
2015-10-30 01:29:21 +00:00
Matthias Radestock 12f5ec40b5 refactor: reduce coupling of nameserver to router
The nameserver no longer knows anything about router.Peers and
router.Peer. That only leaves PeerName, Gossip and GossipData.
2015-10-29 23:21:07 +00:00
Matthias Radestock 6a672cf8bc tiny refactor: more idiomatic referal to process' /proc 2015-10-28 18:23:15 +00:00
Matthias Radestock 036b7d9f66 Merge branch '1.2' 2015-10-28 09:40:50 +00:00
Matthias Radestock ca6bce3820 Merge branch 'latest_release_doc_updates' into 1.2 2015-10-28 09:20:46 +00:00
Matthias Radestock 9b4f2297b0 drop quotes in eval "$(weave env)"
They are unnecessary and unwieldy.

Fixes #1596
2015-10-28 09:19:10 +00:00
Matthias Radestock 355c4bc58e Merge branch '1.2' 2015-10-28 08:52:01 +00:00
Matthias Radestock a31b2876d0 Merge pull request #1598 from weaveworks/issues/1584-improved-proxy-router-restart
Improved detection of router container restart

Fixes #1584
2015-10-28 08:51:06 +00:00
Matthias Radestock b697b6e57b Merge pull request #1597 from weaveworks/issues/1516-weavedns-ignore-foreign-domains
Check weaveDNS subdomain on REST PUT

Fixes #1516
2015-10-28 08:50:25 +00:00
Adam Harrison 4792fe6391 Improved detection of router container restart
Use the container name in addition to the entrypoint to avoid triggering
reattachment unnecessarily.
2015-10-27 14:41:26 +00:00
Adam Harrison 7408f72de2 Check weaveDNS subdomain on REST PUT 2015-10-27 14:37:57 +00:00
Tom Wilkie 203a3cfdd1 Remove test runner; it now live in build-tools.git 2015-10-23 13:02:00 +00:00
Ilya Dmitrichenko 3a029686e3 Add Pardot script 2015-10-22 15:07:52 -07:00
Matthias Radestock 9fa7b3956d Merge remote-tracking branch 'upstream/master' 2015-10-22 16:17:55 +01:00
Matthias Radestock b888ace508 remove superfluous code in ApplyUpdate
If the local peer's short ID was updated, we broadcastPeerUpdate at
the end (in unlockAndNotify), so there is no need to include the local
peer in the current update.

Also, reading peers.ourself.Version is bad here - we don't take a lock
and it's written by other goroutines. Doesn't actually break anything
though since it's a uint64 and hence atomic.
2015-10-22 16:12:37 +01:00
Bryan Boreham 2e54efe34d Stop the proxy last, so we can stop the router
before being unable to communicate with docker
when $DOCKER_HOST is pointing at the proxy
2015-10-22 15:45:54 +01:00
Bryan Boreham 94d7f33a03 Merge pull request #1541 from weaveworks/weave-1.2-readme-updates
Update README for 1.2 release
2015-10-22 13:22:54 +01:00
Bryan Boreham 11598295cf Add release v1.2.0 2015-10-22 12:53:57 +01:00
Bryan Boreham 383c3769aa Try en even bigger sleep 2015-10-22 12:19:57 +01:00
Adam Harrison caccba18e9 Mention fast datapath port 2015-10-22 11:58:14 +01:00
Paul Bellamy 95ce00e551 moving boot2docker instructions into the readme 2015-10-22 11:58:14 +01:00
David Wragg 85dad58cfe Pass --privileged for the temporary container in rewrite_etc_hosts
Otherwise we run into selinux issues on fedora23 (and probably other
selinux distros).
2015-10-22 11:44:17 +01:00
Bryan Boreham acdc70f72a Merge pull request #1560 from weaveworks/1542-proxy-bug-weave-not-running
LGTM. Fixes #1542
2015-10-22 10:19:32 +01:00
Paul Bellamy bc9db72212 [proxy] Add notifyWaiters to fix anticipated race condition.
* User makes /start request, and blocks on the waiter
* ContainerStarted fires with ID
* Container goes away
* We try to inspect the container to get the entrypoint, which fails
* Previously, this wouldn't call notifyWaiters and the /start would hang (I expect)
2015-10-22 09:50:12 +01:00
Adam Harrison 7905f81d7e Merge pull request #1570 from dpw/mac-invalidate-routes
Do InvalidateRoutes when a forwarded packet updates a MAC cache entry
2015-10-21 23:54:56 +01:00
Matthias Radestock 2ef9cc6a1c start temporary containers without networking when possible
This is more efficient and TRTTD

Closes #1572.
2015-10-21 16:52:19 +01:00
Matthias Radestock 2357b69a5f nicer interface name
and more likely to be ignored by NetworkManager

Closes #1567.
2015-10-21 16:22:16 +01:00
Matthias Radestock 98b47f866b Merge pull request #1569 from weaveworks/issues/1565-docker-1.9.0-workaround
Reorder inspect template to work around docker/docker#17026

Fixes #1565.
2015-10-21 15:29:59 +01:00
David Wragg d2dfb0d15d Do InvalidateRoutes when a forwarded packet updates a MAC cache entry
When we get a forwarded packet, we put its source MAC into the MAC cache,
overriding any existing entry.  But we could have a flow which says
to forward packets destined to that MAC based on the old entry.  Such
a flow could be prolonged indefinitely by attempts to send to the MAC.
This is obviously bad, so do InvalidateRoutes in such cases.
2015-10-21 13:46:18 +01:00
Paul Bellamy 63339c026d [proxy] return errors when attaching new containers
I had implemented this with a promise, but was informed that as
waitForStart is only called once, we are safe to just put the error into
the channel.
2015-10-21 13:05:05 +01:00
Adam Harrison 40922b88f7 Reorder inspect template to work around docker/docker#17026 2015-10-21 12:39:55 +01:00
Bryan Boreham 674c617c16 Merge branch '1.1' 2015-10-21 11:52:49 +01:00
Bryan Boreham 2884b6deca Add release v1.1.2 2015-10-20 17:06:14 +01:00
Adam Harrison 720862dafb Merge pull request #1562 from dpw/fdp-create-bridge
'weave --local create-bridge' is not compatible with fastdp
2015-10-20 16:37:20 +01:00
David Wragg 5120b4b468 'weave --local create-bridge' is not compatible with fastdp 2015-10-20 16:34:50 +01:00
Adam Harrison c5f5d4543e Merge pull request #1518 from weaveworks/401-reattach-weave2
Get proxy to re-attach weave router if it restarts
2015-10-20 15:31:13 +01:00
Paul Bellamy baf92da9f2 Merge pull request #1534 from weaveworks/1531-check-hostconfig
Take more care over HostConfig on start request in proxy
2015-10-20 12:18:49 +01:00
Paul Bellamy 526c9c3d73 Add test for {"HostConfig":{}} overriding previous settings, but still connecting to weave 2015-10-20 11:26:29 +01:00
Bryan Boreham 119d87b795 Extract repeated test into function 2015-10-20 11:26:29 +01:00
Bryan Boreham 17b030cca1 Cope with client sending a HostConfig named HostConfig 2015-10-20 11:26:29 +01:00
Bryan Boreham 81c9b3f327 Check that HostConfig parameters supplied on /start are passed to Docker,
also what happens when you supply a HostConfig named HostConfig
2015-10-20 11:26:29 +01:00
Bryan Boreham 50198a2159 Don't create a HostConfig accidentally if none was passed in 2015-10-20 11:26:29 +01:00
Bryan Boreham 20c8b1eaf6 Reverse the sense of a test, to simplify the next change
and remove unused struct
2015-10-20 11:26:21 +01:00
Bryan Boreham faf94b033d Extend test to check we don't overwrite HostConfig 2015-10-20 11:25:06 +01:00
Adam Harrison 342b3d3d08 Merge pull request #1557 from weaveworks/issues/1497
Add container FQDN to /etc/hosts
2015-10-20 11:22:22 +01:00
Bryan Boreham 26d43f193e Move docker restart test above the place where we stop part of weave 2015-10-20 07:07:04 +00:00
Alvaro Saurin f04ae91c82 Add container FQDN to /etc/hosts 2015-10-19 21:51:38 +02:00
Bryan Boreham bb5515113f Make attach-router work in fastdp+encryption case 2015-10-19 15:49:07 +00:00
Bryan Boreham c09d84efc6 Move setup_router_iface call so we don't kill an already-running router on attach-router 2015-10-19 15:49:07 +00:00
Bryan Boreham 2a99a2a597 Don't fail if the arg we're looking for isn't there 2015-10-19 15:47:44 +00:00
Bryan Boreham 08f6dcf08d Missing format 2015-10-19 15:47:44 +00:00
Bryan Boreham 284d78c6b2 Update fetch_router_args in line with changes elsewhere 2015-10-19 15:47:44 +00:00
Bryan Boreham b8b5fb9eae Review feedback 2015-10-19 15:47:43 +00:00
Bryan Boreham 697ee62d9a Use entrypoint to detect weave router 2015-10-19 15:47:43 +00:00
Bryan Boreham 20ac0edda8 Try a bigger sleep to get Docker restarted 2015-10-19 15:46:48 +00:00
Bryan Boreham a1bbb06e2f Don't need depreciation warnings on internal-only command 2015-10-19 15:46:47 +00:00
Bryan Boreham a87cc5c3b1 Get the proxy to re-attach the weave router if it sees it restart 2015-10-19 15:46:47 +00:00
Matthias Radestock 5ff740cddc cosmetic 2015-10-19 15:43:49 +01:00
Matthias Radestock db9229f485 Merge pull request #1551 from weaveworks/1547-proxy-restart-no-kill-containers
Proxy restart shouldn't kill containers

Fixes #1547.
2015-10-19 13:55:48 +01:00
Paul Bellamy ace6c01b00 Review feedback 2015-10-19 13:53:20 +01:00
Bryan Boreham 2f4d460c04 Merge pull request #1517 from weaveworks/1385-non-container-dns-add
LGTM. Fixes #1385
2015-10-19 12:52:09 +01:00
Matthias Radestock d5401ae3cb Merge pull request #1550 from dpw/weave2-eexist
Don't fail in launch-router if weave2 already exists

Fixes #1548.
2015-10-16 21:36:45 +01:00
David Wragg 3482a7f1f1 Don't fail in launch-router if weave2 already exists
And delete weave2 on stop-router.
2015-10-16 20:59:06 +01:00
David Wragg 23762e0639 Move repeated 'stop' code into functions 2015-10-16 20:55:44 +01:00
Bryan Boreham 50cc15af3b Merge pull request #1477 from weaveworks/weave-1374
LGTM.  Fixes #1374
2015-10-16 18:02:16 +01:00
Paul Bellamy a0f0367e60 [proxy] don't kill containers when starting the proxy 2015-10-16 15:33:43 +01:00
Adam Harrison 3f08ddefe9 Correct DisplayName implementation 2015-10-16 12:24:38 +01:00
Adam Harrison debe656f9f Merge pull request #1522 from dpw/fdp-compat
Fast datapath compatibility with 1.1
2015-10-16 11:26:20 +01:00
Alvaro Saurin 4350b6402f Updated docs 2015-10-16 11:47:07 +02:00
Alvaro Saurin 5d2892f6fc Test we respect --add-host when rewriting /etc/hosts
Simplify some tests
2015-10-16 11:47:07 +02:00
Alvaro Saurin 91f27ddd66 Removed weavehosts 2015-10-16 11:47:07 +02:00
Alvaro Saurin 6a674d0d67 Add hosts when attaching 2015-10-16 11:47:07 +02:00
Alvaro Saurin 0d165487b8 Rewrite /etc/hosts in the containers 2015-10-16 11:47:07 +02:00
Matthias Radestock bacc5836ea log listeners 2015-10-16 09:34:20 +01:00
Matthias Radestock 230931a2c9 prevent accidental var shadowing
Fixes #1544
2015-10-16 01:05:04 +01:00
Matthias Radestock 61d289f414 Merge branch '1.1' 2015-10-15 18:14:20 +01:00
Matthias Radestock 44255862a9 prevent spurious errors from showing up
silly mistake
2015-10-15 18:12:56 +01:00
Matthias Radestock ed9577150b suppress spurious errors 2015-10-15 18:01:06 +01:00
Matthias Radestock 80319e7087 Merge branch '1.1' 2015-10-15 17:41:49 +01:00
Matthias Radestock 379048d8fc make test/setup.sh work under go 1.5
Fixes #1543.
2015-10-15 17:40:51 +01:00
Matthias Radestock 9ac655d774 Merge pull request #1526 from weaveworks/fdp-docs
Document fast data path feature

Fixes #1526.
2015-10-15 17:29:29 +01:00
Adam Harrison 9b17470129 Document fast data path feature 2015-10-15 17:19:13 +01:00
Matthias Radestock 5c114fc6fe Merge pull request #1536 from weaveworks/1515-print-json
Print request and response json when debugging weaveproxy

Fixes #1515
2015-10-15 15:59:35 +01:00
Bryan Boreham efb12f41b2 Also print intercepted responses 2015-10-15 15:07:02 +01:00
Adam Harrison 813edcfe0a Merge branch '1.1' 2015-10-15 14:59:29 +01:00
Adam Harrison dea1405d71 Remove hardcoded docker bridge IP from proxy test 2015-10-15 14:39:56 +01:00
Ilya Dmitrichenko e7f91b7529 Update screencast preview image 2015-10-15 14:26:39 +01:00
Matthias Radestock 5e8a64508e Merge remote-tracking branch 'upstream/master' 2015-10-15 14:19:50 +01:00
Matthias Radestock 21ebb7a585 Merge branch '1.1'
Conflicts:
	Makefile
2015-10-15 14:19:14 +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
Ilya Dmitrichenko 34606e0f9f Link to the new screencast (close #1402) 2015-10-15 14:07:54 +01:00
Matthias Radestock 5f62f9edc7 Merge branch '1.1' 2015-10-15 13:05:35 +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
Matthias Radestock 207ee8667b Merge pull request #1538 from dpw/detect-no-fastdp-mismatch
signal mismatches between WEAVE_NO_FASTDP and the bridge type

Fixes #1533.
2015-10-14 17:17:35 +01:00
David Wragg 5984ed921e signal mismatches between WEAVE_NO_FASTDP and the bridge type 2015-10-14 16:33:23 +01:00
Matthias Radestock aac5fb8c24 Merge pull request #1537 from weaveworks/1502-flakey-test
Wait until container exits in test to remove race condition

Fixes #1502
2015-10-14 16:19:20 +01:00
Matthias Radestock 8cfc8b3132 Merge pull request #1528 from weaveworks/weave-env-bug
[proxy] Fix bug in weave env/config when passing multiple -H flags

Fixes #1527
2015-10-14 15:50:42 +01:00
Paul Bellamy 0b5ebd7b1d Wait until container exits in test to remove race condition 2015-10-14 14:53:23 +01:00
David Wragg 35141a4aef Forward a packet with sleeve if the source or dest peer lacks a short ID 2015-10-14 13:53:59 +01:00
David Wragg e702234fdc Don't use a nil FlowOp to mean "discard the packet" 2015-10-14 13:53:34 +01:00
Bryan Boreham 05dbe23563 Print request and response json when debugging 2015-10-14 13:45:51 +01:00
Paul Bellamy fd07f59d16 [proxy] Fix bug in weave env/config when passing multiple -H flags
The echo in proxy_addr was not preserving newlines, so the multiple
addrs were all getting returned
2015-10-14 11:58:10 +01:00
Paul Bellamy 36de840c91 [proxy] only attempt to rewrite successful inspects 2015-10-14 11:28:43 +01:00
David Wragg b36ffe1c9d Support peers that don't have short IDs 2015-10-14 11:11:34 +01:00
David Wragg 1f1451e666 Fall back to sleeve when "Overlays" not present in features 2015-10-14 11:11:34 +01:00
David Wragg 1000839309 Merge issues/1505-fast-datapath-weave-status' (PR #1525)
Fast datapath weave status
2015-10-14 11:08:09 +01:00
Adam Harrison ed4ed5fdcd Include short peer ID in report JSON 2015-10-13 17:04:56 +01:00
Adam Harrison eaf1f7cc13 Include overlay diagnostics in report JSON 2015-10-13 17:04:56 +01:00
Adam Harrison ddfc8c2fa4 Handle JSON report marshalling error 2015-10-13 17:04:56 +01:00
Adam Harrison 91afa7f7f4 Include selected overlay type in connection status 2015-10-13 17:04:56 +01:00
Paul Bellamy da49e71eb8 Merge pull request #1529 from weaveworks/expose-proxy-tls
Expose some tls functions from the proxy for use elsewhere.
2015-10-13 16:09:27 +01:00
Tom Wilkie 5b8ce8ebae Expose some tls functions from the proxy for use elsewhere. 2015-10-13 14:56:11 +00:00
Adam Harrison 827bcd898e Merge pull request #1438 from weaveworks/fdp
Fast datapath
2015-10-13 10:34:49 +01:00
Matthias Radestock 54a4add40f cosmetic 2015-10-13 09:02:03 +01:00
David Wragg 0093eb1220 A smoke test for WEAVE_NO_FASTDP
Partly for the side effect of restoring coverage of
router/ethernet_decoder.go
2015-10-12 21:27:11 +01:00
David Wragg b56ff7678c Make code coverage work through the proxy
Previously, the proxy would run the weave script in ways that did
not run the weaver executable.  Now they can.  This is a problem because
of the contortions involved in using golang's code coverage support
in the integration tests, which require the weaver command line args to
be slightly mangled.
2015-10-12 21:27:11 +01:00
David Wragg 431197042d Weave script changes to enable fast datapath
This means:

* The 'weave' netdev is an OVS datapath

* The weave router container runs with --net=host in order to access
  the datapath.

* The MTU is set to a smaller value, to allow vxlan encapsulation.

Setting the WEAVE_NO_FASTDP environment variable disables these
things, effectively running the router without fast datapath.  It is
an environment variable rather than an option to 'weave launch'
because it takes effect in create_bridge, which is called from many
subcommands, and it doesn't seem practical to add option processing to
all of them.
2015-10-12 21:27:11 +01:00
David Wragg 295876e1d1 Fast datapath 2015-10-12 21:27:11 +01:00
David Wragg e8f975e44f Introduce checkFatal in prog/weaver/main.go 2015-10-12 21:27:11 +01:00
David Wragg bc026ab49a Show the overlay name in sleeve log messsages 2015-10-12 21:27:11 +01:00
David Wragg f56457271d OverlaySwitch 2015-10-12 21:27:11 +01:00
David Wragg bc5250c899 Replace OverlayForwarderListener with channels
It's more robust to signal the conditions asynchronously via channels
rather than callbacks.
2015-10-12 21:27:11 +01:00
David Wragg 971511e1c5 Introduce PeerShortIDs
These are needed to support vxlan encapsulation.  In a vxlan packet,
the only place we can straightforwardly hold the source and
destination peer identifiers used by the weave router is in the
24-bit VNI (vxlan network identifier) field.  This gives us 12 bits to
indicate a peer. The resulting limit of 4096 peers on a weave network
does not seem like a problem in the near future.  But it does mean
that decentralized allocation makes collisions fairly likely even in
weave networks of sizes that are common today.  Fortunately, the
problem is much more tractable than IPAM because we can detect when
collisions occur and take action to resolve them.
2015-10-12 21:27:11 +01:00
David Wragg 51317dca70 Introduce PeersPendingNotifications 2015-10-12 21:27:11 +01:00
David Wragg 91dda08165 Rename Peers "table" field to "byName" 2015-10-12 21:27:11 +01:00
David Wragg 67bfa5bc90 applyUpdate can return a PeerNameSet 2015-10-12 21:27:11 +01:00
David Wragg 0841f4a27d Tidy broadcastPeerUpdate 2015-10-12 21:27:11 +01:00
David Wragg c6edf8421f Handle the not-found case implicitly in Broadcast and BroadcastAll 2015-10-12 21:27:11 +01:00
David Wragg 97fb90c37a Always include local peer in Peers 2015-10-12 21:27:11 +01:00
Matthias Radestock 1d00bdd2a4 a better way to restrict coverage
this better fixes #1524.
2015-10-12 18:04:07 +01:00
Matthias Radestock 0ff01871f3 Merge remote-tracking branch 'upstream/master' 2015-10-12 17:43:41 +01:00
Matthias Radestock e00a675e6e update tools to latest version 2015-10-12 17:43:06 +01:00
Paul Bellamy d5e63b875b Merge pull request #1395 from weaveworks/1371-proxy-no-dockerclient
[proxy] all request modification is done through map[string]interface{}
2015-10-12 16:42:44 +01:00
Matthias Radestock a31ccef99b only produce coverage for packages under github.com/weaveworks/weave
Fixes #1524.
2015-10-12 16:06:26 +01:00
Paul Bellamy 375fd9140b review feedback
* Opted to remove json path traversal, as it added more code than it saved.
2015-10-12 15:53:07 +01:00
Paul Bellamy fbb2c213a9 [proxy] all request modification is done through map[string]interface{}
That way we are less likely fall victim to go-dockerclient, or the API changing.
2015-10-12 15:53:07 +01:00
Bryan Boreham d323de3c21 Merge pull request #1520 from weaveworks/1519-rebind-status-sock
LGTM. Fixes #1519
2015-10-09 17:58:33 +01:00
Paul Bellamy 18872cc8ae [proxy] remove status.sock before binding status.sock 2015-10-09 17:44:16 +01:00
Tom Wilkie 33085e3798 Merge pull request #1499 from weaveworks/1463-ipam-seed-mismatch
detect when IPAM has been seeded by different peers
2015-10-09 14:46:55 +01:00
Matthias Radestock e42c811797 docs 2015-10-08 22:43:47 +01:00
Matthias Radestock 6b321e4d02 associate non-container dns entries with 'weave:extern'
...instead of the weave container. This is cleaner.

'weave:extern' because typically these entries will refer to external
(non-weave) IP addresses. And because it's the same length as
'weave:expose', which is desirable for 'weave status dns' output.
2015-10-08 22:21:38 +01:00
Matthias Radestock e6b17c701d dns-{add,remove} can add/remove non-container DNS records
...by omitting the container name/id

Fixes #1385.
2015-10-08 17:37:35 +01:00
Bryan Boreham 60bda7ca25 Merge pull request #1512 from weaveworks/1459-ipam-early-container-death
LGTM. Fixes #1459
2015-10-07 16:01:45 +01:00
Adam Harrison b37d2ec6d1 Merge pull request #1494 from weaveworks/1468-template-on-demand
Build GCE template on demand
2015-10-07 15:42:39 +01:00
Matthias Radestock 751ccd02f6 don't stall in ipam on early container death
When a container died before we got into the allocation code (inside
the allocator run loop) we would not cancel the allocation since the
container death event will have been processed by the allocator before
it had any knowledge of the container.

The fix is to move the container-aliveness check inside the allocation
code. That way we still detect the death even if the event has already
flown past.

We only need to perform the check once, since any subsequent death
will result in an event that is processed by the allocator when it has
recorded the container in its state.

Fixes #1459.
2015-10-07 15:20:22 +01:00
Matthias Radestock 431d04bd40 refactor: move all dataplane code out of LocalPeer 2015-10-06 19:50:41 +01:00
Matthias Radestock e756f07cad Merge branch '1.1' 2015-10-06 16:25:45 +01:00
Matthias Radestock 0ef548b9c9 prevent dropping of large multicast packets
Fixes #1507.
2015-10-06 16:25:02 +01:00
Ilya Dmitrichenko b9e025b50e Merge branch '1.1' 2015-10-06 15:28:54 +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 7a83a71a02 Merge branch '1.1' 2015-10-06 15:24:25 +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 8aaf4cfaf0 include nicknames in error message, if we have them 2015-10-06 14:41:41 +01:00
Ilya Dmitrichenko 8a62d13cee Merge pull request #1500 from weaveworks/1443-dont-assume-docker
allow router exe to be run w/o access to Docker
2015-10-06 14:28:26 +01:00
Matthias Radestock 5a45471c68 more readable errors on ring.Merge
There are three significant changes here:

- rewrite ring.ErrDifferentSeeds errors
- remove the pre-checking of ranges and instead rewrite
  ring.ErrDifferentRange errors
- don't pruneNicknames() and signal ringUpdated() when there was an
  error

We don't rewrite other errors since our current belief is that only
ErrDifferentSeeds and ErrDifferentRange can arise from user error.
2015-10-06 14:20:42 +01:00
Matthias Radestock 6dc21bf433 Merge pull request #1503 from weaveworks/860-detach-hide-no-ipalloc
don't allocate IPs on 'detach' and 'hide'

Fixes #860.
2015-10-06 12:53:51 +01:00
Matthias Radestock 1da24c68ca don't allocate IPs on 'detach' and 'hide'
Instead of POSTing to IPAM in order to obtain IPs, we GET existing
IPs. We ignore 404s, so detaching/hiding remains idempotent.

Fixes #860
2015-10-06 12:35:55 +01:00
Matthias Radestock 3d3b7a5672 Merge branch '1.1'
Conflicts:
	router/ethernet_decoder.go
	router/local_peer.go
2015-10-05 20:02:32 +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 f221a6d953 Merge branch '1.1' 2015-10-05 12:08:54 +01:00
Matthias Radestock de95859e0d add release v1.1.1 2015-10-05 11:26:24 +01:00
David Wragg bcf71c0fee Merge branch '1.1' 2015-10-04 20:25:31 +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 a689317696 make 'no Docker API access' the default in the exe
...and instead enable it in the script, via the (better named) option.
2015-10-03 17:52:57 +01:00
Matthias Radestock 14a5c12404 allow router to be run w/o access to Docker
Fixes #1443.
2015-10-03 17:52:57 +01:00
Matthias Radestock 35b2968b60 Merge branch '1.1' 2015-10-03 17:20:21 +01:00
Matthias Radestock dac932f553 fix multi-ip attach
This got broken in f7dfe9d
2015-10-03 17:09:25 +01:00
Matthias Radestock 7e0ae6112c detect when IPAM has been seeded by different peers
This is an early detector for a multitude of other symptoms, some of
which cause panics.

When creating the ring we record the paxos-supplied normalised list of
peers used for seeding. This subsequently gets gossipped around as
part of the Ring data structure, and checked in ring.Merge that it is
the same for the recipient.

There are some subtleties due to the desire to maintain backward
compatibility and deal with empty rings

- The gossip gob decoder will ignore the Ring.Seeds field when an old
  weave receives a Ring from a new weave. So everything on the old
  weave will just continue to work as before.

- The gossip gob decoder will set the Ring.Seeds field to nil when a
  new weave receives a Ring from an old weave. We therefore omit the
  seed equivalence check when the received Seeds slice is empty.

- Our ring may not have any seeds - either because it is empty or was
  created from a ring received from an old weave. We therefore a) omit
  the seed equivalence check in that situation, and b) set our seeds
  to those received. Note that this allows us to learn about the seeds
  well after ring creation - a situation which may arise when
  receiving gossip from a mixture of old and new weaves.

Fixes #1463.
2015-10-02 16:33:28 +01:00
Bryan Boreham 9ad1ccf19f Don't listen to SIGUSR1, since we stopped handling it a few months back 2015-10-02 13:52:23 +01:00
Bryan Boreham 5b7599e1b0 Merge pull request #1496 from weaveworks/953-backoff-late-connection-failures
LGTM.  The timing choices are all very arbitrary, so we should wait for more experience in the wild before trying to tune them further.

Fixes #953
2015-10-02 12:44:52 +01:00
Matthias Radestock 19c44b83d2 refactor: better 'try' method names 2015-10-02 11:31:11 +01:00
Matthias Radestock 41691957d2 refactor: simplify target status reporting 2015-10-01 20:05:12 +01:00
Matthias Radestock e3182624fd refactor: more obviously handle all target states in reporting 2015-10-01 20:05:12 +01:00
Matthias Radestock b8b3e6f9cd refactor: better representation of 3-valued target state 2015-10-01 20:05:12 +01:00
Matthias Radestock 520c7286c4 backoff retries for late-failing connections
If a connection gets through all the handshake and subsequent checks -
i.e. it ends up getting added to the LocalPeer's connection list - but
gets terminated within one minute (of the start of the successful
connection attempt), then we apply the existing backoff logic to
schedule a retry, instead of retrying immediately.

In order to do this we retain the 'Target' data structure for such
connections, marking it as 'connected' instead of deleting it (as we
did previously).

Fixes #953.
2015-10-01 20:05:12 +01:00
Matthias Radestock d547829c5f Merge pull request #1495 from weaveworks/1492-proxy-remove-var-run-mount
Remove /var/run mount from exec_remote. Proxy uses /var/run/weave/weave.sock

Fixes #1492.
2015-10-01 16:58:37 +01:00
Matthias Radestock 49459cfc9b Merge pull request #1462 from weaveworks/1461-dns-case-sensitive
DNS lookups should not be case sensitive.

Fixes #1461.
2015-10-01 16:52:00 +01:00
Paul Bellamy 827ba446ab Remove /var/run mount from exec_remote. Proxy uses /var/run/weave/weave.sock
It was left in for backwards compatibility, in 1.1.
2015-10-01 15:52:29 +01:00
Tom Wilkie e5316221bb Review feedback 2015-10-01 14:14:15 +00:00
Tom Wilkie 357174e351 DNS lookups should not be case sensitive.
- On-the-wire gossip messages are sorted case sensitive, but in memory they are sorted case-insensitive.
- Add test for case insensitive match on multiple names.
2015-10-01 12:19:49 +00:00
Tom Wilkie 5fc2f3236e Build GCE template on demand 2015-10-01 11:49:31 +00:00
Matthias Radestock a3484cce43 Merge pull request #1488 from weaveworks/1481-proxy-null-hostconfig
[proxy] Handle null HostConfigs gracefully in start

Fixes #1481.
2015-10-01 12:06:51 +01:00
Matthias Radestock cdd107b06b Merge branch '1.1'
Conflicts:
	weave
2015-10-01 12:04:44 +01:00
Bryan Boreham 6619b584bc Merge pull request #1483 from weaveworks/1478-cm-termination-race
LGTM.  Fixes #1478
2015-10-01 12:01:55 +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
Alfonso Acosta c24dc6609d [proxy] Handle null HostConfigs gracefully in start 2015-10-01 11:40:50 +01:00
Adam Harrison b5e7e9fc5c Merge pull request #1451 from dpw/sleeve-compat
Restore sleeve compatibility with 1.1
2015-10-01 11:24:31 +01:00
Tom Wilkie 58dec7334b Merge branch '1.1' 2015-10-01 08:23:15 +00:00
Tom Wilkie 0b7af28c86 Typo in Makefile. 2015-10-01 08:21:55 +00:00
Matthias Radestock 725f99ea4c Merge branch '1.1' 2015-10-01 08:23:52 +01: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 4b43cac093 Merge branch '1.1' 2015-09-30 23:34:57 +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
Matthias Radestock 0159e26631 store connections as a set instead of map-of-remote-addresses
...since it is theoretically possible that the lifecycle events from
two consecutive inbound connections from the same remote address
overlap.
2015-09-30 17:29:13 +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
Tom Wilkie 19cb1ae8e1 Merge branch '1.1' 2015-09-30 15:06:26 +00: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
David Wragg f8e06f9dbc Merge 1286-tool (PR #1470): Use test script from build-tools.git 2015-09-30 14:15:20 +01:00
Matthias Radestock e68ca761a9 we no longer need to Refresh() in CM status
since CM now gets an event - ConnectionCreated - for new connections.
2015-09-30 14:00:32 +01:00
Matthias Radestock fc6f3993bd refactor(ish): obtain local connection status from CM alone 2015-09-30 14:00:32 +01:00
Matthias Radestock f8b074f696 a better way to clean up after established connections
...than 3db4e86
2015-09-30 14:00:32 +01:00
Matthias Radestock 66f14099ed prevent ConnectionMaker.ConnectionTerminated race
Get the ConnectionMaker to maintain its own knowledge of the local
connections, based on events emitted in the connection lifecycle.

Fixes #1478.
2015-09-30 14:00:32 +01:00
Tom Wilkie f3dc681f61 Only clean weave packages. 2015-09-30 10:15:50 +00:00
Tom Wilkie 62f62e1fd5 tools.git is now called build-tools.git 2015-09-30 08:21:19 +00:00
Tom Wilkie f3360e61e1 Remove cover tool, this lives in tools.git now. 2015-09-30 08:21:12 +00:00
Tom Wilkie 5208dcd67e Review feedback
- Use git submodule for tools.
- Update Makefile to use submodules.
- Put submodule at tools/
- Tidy up some obsolete references to tools in .gitignore.
2015-09-30 08:21:08 +00:00
Tom Wilkie 6f7d4a7a01 Use lint from tools.git
- Do lint first, on circle.
2015-09-30 08:20:56 +00:00
Tom Wilkie 958a3bbd99 Use test script from tools.git 2015-09-30 07:42:43 +00:00
Matthias Radestock d5c85a3d53 cosmetic: fix typo 2015-09-29 19:40:54 +01:00
Tom Wilkie 5e7b527af2 Make publish from the right place. 2015-09-29 11:02:46 +00:00
Paul Bellamy ddbd33a8e3 Merge pull request #1471 from weaveworks/1295-publish
Publish latest images from CI on successful builds.
2015-09-29 11:37:44 +01:00
Matthias Radestock a7dc368191 Merge pull request #1469 from weaveworks/1204-test-container
Run tests in a separate container.

Fixes #1204.
2015-09-29 11:37:25 +01:00
Matthias Radestock 5b1d0c55a0 Merge pull request #1474 from weaveworks/1472-weave-env-debug
use a container-local unix socket to get the address, instead of logs

Fixes #1453. Fixes #1472.
2015-09-29 11:04:41 +01:00
Matthias Radestock 58515ca36e make weave(proxy) startup death message more generic
...in order to account for `docker logs` not working due to custom
logging drivers.

Partially undoes #958. Partially fixes #1453.
2015-09-29 11:02:05 +01:00
Matthias Radestock 2d753ebf1a cosmetic: reduce confusion w.r.t. meaning of 'connection' 2015-09-29 09:21:39 +01:00
Tom Wilkie 50cd716220 Review feedback. 2015-09-29 07:46:00 +00:00
Matthias Radestock 47c97e8191 refactor: remove some code duplication 2015-09-28 16:10:43 +01:00
Paul Bellamy d704ba175f [proxy] use a container-local unix socket to get the address, instead of logs 2015-09-28 16:08:25 +01:00
Matthias Radestock c1036c5e4f Merge remote-tracking branch 'upstream/master' 2015-09-28 14:53:12 +01:00
Matthias Radestock 356d06915b refactor weave script http calls
- inline http_call into call_weave
- rename http_call_ip to http_call
- make http_call take the IP & port as one single "address" argument
  instead of separate args
2015-09-28 12:43:09 +01:00
Tom Wilkie 2b4fd738da Review feedback 2015-09-28 09:05:10 +00:00
Tom Wilkie f9de6df426 Publish latest images from CI on successful builds.
This time rebuild without insturmentation first.
2015-09-28 08:27:21 +00:00
Tom Wilkie 8ee409d9bd Run tests in a separate container. 2015-09-25 06:19:00 +00:00
Matthias Radestock 0cf3de4541 Merge pull request #1446 from weaveworks/smoke-subdomains
Add smoke-test for subdomains
2015-09-24 15:55:57 +01:00
Bryan Boreham 3a79be7426 Add smoke-test for subdomains 2015-09-24 14:48:39 +01:00
David Wragg 30589bb580 Mention the mailing list 2015-09-24 14:40:20 +01:00
Matthias Radestock e07b18bb18 Merge branch '1.1' 2015-09-24 12:08:13 +01:00
Matthias Radestock 63e3f441d8 cosmetic: link to relevant RFC section for ARP announcements 2015-09-24 12:07:12 +01:00
Tom Wilkie b31eb3db82 Merge remote-tracking branch 'upstream/1.1' 2015-09-24 03:54:09 +00: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
Bryan Boreham da2f98fa8f Remove workaround for upstream, no longer required 2015-09-23 10:15:06 +01:00
Tom Wilkie 7ac532a1d0 Merge pull request #1454 from weaveworks/1433-docker-1.8
New test image using docker 1.8
2015-09-23 10:16:06 +08:00
Matthias Radestock b98ab70517 Merge branch '1.1' 2015-09-22 21:18:32 +01: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 0bdc84d42a Merge branch '1.1' 2015-09-22 16:28:05 +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
Matthias Radestock 7d7c5ce63e Merge pull request #1449 from weaveworks/1368-start-hostconfig
Override sneaky /start HostConfig params

Fixes #1368.
2015-09-22 15:11:36 +01:00
Paul Bellamy 547c9e7f5a Removing confusing variable from getDNSDomain, just return "" when disabled 2015-09-22 15:09:32 +01:00
Paul Bellamy 3e4d8a3ffe review feedback 2015-09-22 15:09:32 +01:00
Paul Bellamy 74c3b0d079 [proxy] Override sneaky /start HostConfig params 2015-09-22 15:09:32 +01:00
Paul Bellamy 846aa98a9c renaming test so it runs 2015-09-22 14:52:28 +01:00
Matthias Radestock 17b7789531 Merge pull request #1456 from weaveworks/fix-race-condition
[proxy] fix race condition when waiting for containers to start
2015-09-22 14:51:43 +01:00
Paul Bellamy b86d9bf1ab [proxy] fix race condition when waiting for containers to start
If ContainerStarted fired before the response handler, then the "waiter"
chan would be nil, and the response handler would hang.
2015-09-22 12:50:36 +01:00
Tom Wilkie 6e06ce2af1 New test image using docker 1.8 2015-09-22 05:31:26 +00:00
David Wragg dc275d7009 Restore sleeve compatibility with 1.1
Addresses #1396
2015-09-21 08:33:11 +01:00
David Wragg a67b9f566a 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.
2015-09-20 19:58:04 +01:00
Michael Bridgen 9344289262 Merge pull request #1445 from weaveworks/docs-ecs-amis
Document ECS integration
2015-09-17 14:43:38 +01:00
Alfonso Acosta 6713282a43 Link to ECS AMIs from README 2015-09-17 13:27:32 +00:00
Matthias Radestock f834626f00 Merge pull request #1414 from weaveworks/1285-autoconfig-boot2docker-tls
Proxy TLS autoconfiguration

Closes #1285.
2015-09-16 15:49:20 +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
Paul Bellamy 0a475bd4cc docker_tls_args should look for '-d' or 'daemon' to handle docker 1.8 change 2015-09-16 13:25:29 +01:00
Paul Bellamy 0820c484d6 [proxy] Documenting TLS autoconfig 2015-09-16 10:44:18 +01:00
Paul Bellamy dbf39403d3 [proxy] Autoconfigure TLS based on daemon settings
With this on OSX you can:
```sh
$ boot2docker init
$ boot2docker up
$ eval $(boot2docker shellinit)
$ weave launch
$ eval $(weave env)
```
2015-09-16 10:44:17 +01:00
Matthias Radestock 14dde9ec32 Merge branch '1.1' 2015-09-15 16:47:05 +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 3c266dce8c Merge branch '1.1' 2015-09-15 15:51:36 +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 f7be34f5bb Merge branch '1.1' 2015-09-15 15:44:53 +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 64b47ca3c7 Merge branch '1.1' 2015-09-15 13:17:06 +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
Paul Bellamy e39974eb07 Merge pull request #1210 from weaveworks/401-proxy-start-events
make proxy attach network on docker start event
2015-09-15 10:18:48 +01:00
Bryan Boreham 76895c76a1 Use Mutex instead of RWMutex, for simplicity 2015-09-14 17:11:56 +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 98e8ef4e11 Merge remote-tracking branch 'upstream/1.1' 2015-09-14 16:33:12 +01:00
Bryan Boreham 5635ba1fd0 Update out-dated error message 2015-09-14 16:31:37 +01:00
Adam Harrison 2ffe9b53f7 Merge branch '1.1' 2015-09-14 14:21:36 +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
Paul Bellamy 405c2889f0 Merge pull request #1415 from weaveworks/1341_report_snapshot_versions
correctly report snapshot versions
2015-09-14 10:45:29 +01:00
Matthias Radestock 40cf392504 cosmetic: vertical alignment in version output 2015-09-11 15:56:17 +01:00
Matthias Radestock 42baa03985 report the proxy version instead of weaveexec version
That way we no longer rely on the weavexec image version tag, which
may not always be present. Since the proxy is embedded in the
weaveexec image, this effectively versions the image.

Also report the *local* script version instead of the embedded script
version. There is no point in reporting the latter since it will
always match the weaveexec version.

Closes #1341.
2015-09-11 15:52:50 +01:00
Matthias Radestock 016f20b2d4 Merge branch '1.1' 2015-09-11 14:07:59 +01:00
Matthias Radestock 83ef93f3fb detect running proxy regardless of version
Fixes #1413.
2015-09-11 14:06:44 +01:00
Matthias Radestock d5faf31d43 Merge remote-tracking branch 'upstream/master' 2015-09-11 13:36:59 +01:00
David Wragg 12324e3550 Revert "Make weave build under go1.5; use our build flags for go get, and force stuff to be static."
This reverts commit 5860492a38.

Although the build works under 1.4, this change had an unfortunate
impact (see #1412).
2015-09-11 13:31:15 +01:00
Matthias Radestock ff67499562 cosmetic 2015-09-11 13:30:22 +01:00
Matthias Radestock 2ba5abc2bb rename 'VERSION' to 'WEAVE_VERSION'
to avoid potential accidental clashes with user's environment.

Closes #1389.
2015-09-11 11:02:51 +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 3d4a8aaad1 Merge branch '1.1' 2015-09-10 17:24:26 +01:00
Adam Harrison ac145052d6 Correct weave stop advice
Fixes #1408.
2015-09-10 17:23:33 +01:00
Matthias Radestock 4ded1f6193 Merge branch '1.1' 2015-09-09 20:06:34 +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 940a0a67a5 Merge branch '1.1' 2015-09-09 19:54:46 +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 be304365a0 Merge branch '1.1' 2015-09-09 14:26:34 +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
Adam Harrison fc00767cf8 Remove reference to 1.0 from README 2015-09-09 13:56:25 +01:00
David Wragg 2163b39268 Merge weaveworks/go-1.5 (PR #1386)
Make Weave build & work with Go 1.5
2015-09-09 12:23:57 +01:00
Matthias Radestock aa61cbd574 Merge pull request #1388 from weaveworks/alpine
gliderlabs/alpine is now just alpine
2015-09-08 14:01:40 +01:00
Adam Harrison 2a89d53d7d Merge pull request #991 from dpw/fdp-prep
Fast datapath preparations
2015-09-08 13:19:03 +01:00
David Wragg f7ce6a1fdb Injected packets shouldn't happen in handleCapturedPacket
Check for them just in case, but don't take an extra lock to do it.
2015-09-08 10:46:04 +01:00
David Wragg 20b35f3139 Add NewPeerFromSummary
To reduce the number of places that are explicit about which values
go into a new Peer.
2015-09-08 10:46:02 +01:00
David Wragg 46d454730f Notify the Overlay when routes change 2015-09-08 10:44:57 +01:00
David Wragg c2ad4c5633 Flows
For fast datapath, the router core will only be invoked upon datapath
misses.  And it needs to yield routing decisions in a form that can be
used to configure the in-kernel datapath.  So here we make the router
core yield FlowOps, which represent operations which actually do
something with a packet.  The router core obtains these in turn from
the Bridge or the Overlay, depending on what it wants to do with
a packet.

For fast datapath, it's critical that the router makes decisions based
only on the required packet header information (as the same header
information will be used when configuring the ODP flow rules).  So we
pass only that information into the router core, in the form of
PacketKeys.

The overall effect is to curry the router core: Rather than taking a
packet and doing something with it, it takes packet header information
and returns a function that does something with a packet.
2015-09-08 10:44:52 +01:00
David Wragg 6e0795253e Move ICMP frag-needed handling into sleeveForwarder 2015-09-08 10:44:52 +01:00
David Wragg 9956d422f2 Introduce Overlay / sleeve
This introduces interfaces to represent the packet forwarding
mechanism, and brings all the scattered UDP-related code together into
a single implementation.

This is not a pure refactoring, although much of the code in sleeve.go
has been copied from pre-existing code, and the UDP protocol remains
the same in spirit.  The biggest change is the organization of the
forwarder goroutines (there is now one instead of two, and that
goroutine does a lot of auxiliary work as well as forwarding).
Performance testing between VMs on my laptop suggests that packet
throughput has not gone down, and may even have improved slightly.
2015-09-08 10:44:44 +01:00
David Wragg 57e78e2bec Introduce Bridge 2015-09-08 10:44:37 +01:00
David Wragg 5aa58e6043 go 1.5 broke PMTU detection 2015-09-07 17:31:18 +01:00
Adam Harrison 64e3cf04cc Add release v1.1.0 2015-09-07 16:43:03 +01:00
Adam Harrison 4f9185e3fe Merge branch 'weave_1.1_readme_updates' 2015-09-07 16:38:28 +01:00
Adam Harrison 4dbccea5df Add missing quotes 2015-09-07 16:38:02 +01:00
Adam Harrison a412268154 Merge branch '1.0' 2015-09-07 15:59:17 +01:00
Tom Wilkie 5860492a38 Make weave build under go1.5; use our build flags for go get, and force stuff to be static. 2015-09-07 14:45:17 +00:00
Matthias Radestock d79ac3c12c Merge pull request #1387 from weaveworks/issues/1383-switch-release-behaviour-on-type
Only update DockerHub `latest` images on mainline release

Fixes #1383.
2015-09-07 12:53:07 +01:00
Matthias Radestock 85c309eee0 fix broken link 2015-09-05 16:04:21 +01:00
Matthias Radestock f782fb569f Merge pull request #1391 from weaveworks/1390-use-number
Stop marshalling numbers as floats

Fixes #1390.
2015-09-04 20:15:58 +01:00
Bryan Boreham c50968a0a4 Stop marshalling numbers as floats 2015-09-04 20:01:31 +01:00
Matthias Radestock 99b482b363 Merge pull request #1384 from weaveworks/dns-hostname-from-labels
[proxy] Add --hostname-from-label

Closes #1381.
2015-09-04 17:14:44 +01:00
Alfonso Acosta ce5dd847e9 [proxy] Add --hostname-from-label
This allows registering container hostnames based on a label provided when
creating the container.
2015-09-04 17:02:07 +01:00
Adam Harrison 5c0383059e Update documentation 2015-09-04 15:45:27 +01:00
Adam Harrison 6f672f9bc1 Infer release type
Script adjusts its behaviour based on the format of the version tag.
2015-09-04 15:44:48 +01:00
Paul Bellamy e74b6cbcaf gliderlabs/alpine is now just alpine 2015-09-04 14:33:18 +01:00
Matthias Radestock 32a82f2d0e Merge pull request #1376 from weaveworks/1199-proxy-kubernetes
[proxy] add --rewrite-inspect flag

Fixes #117. Fixes #1199.
2015-09-04 14:27:16 +01:00
Matthias Radestock 633df0cdaf refactor: extract docker API endpoint regexp creation 2015-09-04 13:40:07 +01:00
Paul Bellamy 32a12578f3 Don't use go-dockerclient to en/decode inspects in the proxy 2015-09-04 13:40:07 +01:00
Paul Bellamy 11b655154c "Clarifying" proxy --rewrite-inspect documentation 2015-09-04 13:40:07 +01:00
Paul Bellamy 19ceb424c3 [proxy] refactoring out common marshalling logic 2015-09-04 13:40:07 +01:00
Paul Bellamy e21a204eed [proxy] add --rewrite-inspect flag
To return the weave ip/mac for docker inspect calls.
2015-09-04 13:40:06 +01:00
Bryan Boreham 145a527626 Merge pull request #1379 from awh/issues/1369-weave-dns-add-remove-optional-ip
LGTM.  Fixes #1369
2015-09-04 12:13:38 +01:00
Paul Bellamy b33bbdb3f8 Merge commit '704e6a8' 2015-09-04 10:41:27 +01:00
Paul Bellamy 704e6a8676 errcheck says I should handle this case 2015-09-04 10:40:47 +01:00
Matthias Radestock 4c6a8f29c0 Merge pull request #1372 from weaveworks/issues/880-draft-releases
Support draft and pre-releases in `bin/release`

Fixes #880. Fixes #909.
2015-09-03 15:54:07 +01:00
Adam Harrison 5dfe1d28ff Add release 1.0.3 2015-09-03 15:02:57 +01:00
Adam Harrison 5744ed8994 Document release process 2015-09-03 13:01:29 +01:00
Matthias Radestock c71d9b126f Merge pull request #1380 from weaveworks/598-update-docs
Update docs for mixed manual and automatic IP allocation

Missed from #1200.
2015-09-03 12:27:24 +01:00
Bryan Boreham 5b437d2199 Update docs for mixed manual and automatic IP allocation 2015-09-03 12:17:31 +01:00
Adam Harrison 0125e67b35 Implement smoke test 2015-09-03 09:59:37 +01:00
Adam Harrison 1472e35011 Update documentation 2015-09-03 09:59:37 +01:00
Adam Harrison 58ea422ea2 Optional address argument to dns-add/dns-remove 2015-09-02 17:10:48 +01:00
Adam Harrison 3097565664 Merge branch '1.0'
Conflicts:
	site/weavedns.md
2015-09-02 17:09:39 +01:00
Adam Harrison 81134b408d Merge branch 'latest_release_doc_updates' into 1.0 2015-09-02 17:07:48 +01:00
Adam Harrison 26fdd5da03 Remove misplaced sentence 2015-09-02 17:06:23 +01:00
Adam Harrison 6a5df80bda Fix latest_release hash test
Obtain the version and latest_release tag commit hashes before changing
into the cloned repository so that all tagging and pushing happens on
the outer repository.
2015-09-02 14:13:11 +01:00
Bryan Boreham 1e2344341d Wait for container to be attached before returning from {re}start request 2015-09-01 17:48:22 +01:00
Bryan Boreham b712ba1e04 Extend test to cover containers restarting automatically 2015-09-01 17:48:22 +01:00
Bryan Boreham 9ae6435317 Attach existing weave containers at startup 2015-09-01 17:48:22 +01:00
Bryan Boreham 81e8ba223f Do network attach on docker event rather than intercepting start and restart commands.
This means it also works when the docker daemon restarts a container.
2015-09-01 17:48:12 +01:00
Adam Harrison b13baccbd2 Introduce draft step
The publish stage has been split into two pieces - a draft step that
creates a draft version release in Github and a publish step that
publishes the draft, updates `latest_release` and pushes images to
DockerHub.

It is also possible to specify `--pre-release` to draft. Once published
such a release will be marked with a prominent warning in GitHub;
additionally we do not update `latest_release` in GitHub nor push an
update to the `latest` tag in DockerHub.
2015-09-01 17:04:11 +01:00
Adam Harrison 82f2f7b2b9 Check for required tooling at top level
Pull common checks out to top level in preparation for the introduction
of an additional process step.
2015-09-01 17:04:11 +01:00
Adam Harrison f48a4373d1 Allow freeform version tags
To support arbitrarily named pre-releases we no longer impose any
restrictions on the format of the most recent annotated tag - instead we
expect to find a single annotated tag pointing at HEAD of the current
branch and assume this is the version to release.
2015-09-01 17:04:11 +01:00
Adam Harrison ab9d1777a1 Support make UPDATE_LATEST=false publish
When publishing pre-releases via the release script we do not want to
modify the `latest` tag in DockerHub - specifying UPDATE_LATEST=false
causes publish to push to $WEAVE_VERSION only. Omitting the flag
entirely retains the existing behaviour for backwards compatability.
2015-09-01 17:04:11 +01:00
Bryan Boreham 6a34995796 Merge pull request #1370 from weaveworks/docker-py-test-matcher
LGTM. Fixes #1367
2015-09-01 16:47:24 +01:00
Bryan Boreham df25f84011 Merge pull request #1375 from weaveworks/1373-document-no-rewrite-hosts
LGTM.  Fixes #1373
2015-09-01 15:01:51 +01:00
Paul Bellamy cead9579be document --no-rewrite-hosts flag 2015-09-01 11:01:45 +01:00
Paul Bellamy a23c0237c3 using --collect-only so we don't miss tests 2015-09-01 10:50:13 +01:00
Matthias Radestock 5c3efbdca0 Merge pull request #1366 from weaveworks/python-call-changed
Fix docker api proxy smoke-tests after docker-py change
2015-08-28 20:50:35 +01:00
Bryan Boreham 176ee73efe Ensure we have the busybox image 2015-08-28 20:34:43 +01:00
Bryan Boreham 54833195ed Call to docker-py changed upstream 2015-08-28 20:34:43 +01:00
Matthias Radestock 8960a3a898 Merge branch '1.0'
Conflicts:
	proxy/create_exec_interceptor.go
	test/600_proxy_docker_py_test.sh
2015-08-28 20:29:43 +01:00
Matthias Radestock 8184d29d4a Merge pull request #1367 from weaveworks/1.0-python-call-changed
Fix docker api proxy smoke-tests after docker-py change
2015-08-28 20:22:22 +01:00
Matthias Radestock fef91b5339 comment 2015-08-28 18:09:23 +01:00
Matthias Radestock 24de98e188 refactor 2015-08-28 18:08:24 +01:00
Matthias Radestock 6291a89665 Merge pull request #1314 from weaveworks/1209-wait-iface-netlink
Wait for ethwe via netlink, not via polling or signals

Fixes #1209. Fixes #1258. Fixes #1300.
2015-08-28 17:44:55 +01:00
Bryan Boreham a45e5ac152 Test calling 'start' with a HOST_CONFIG not supplied to 'create' 2015-08-28 16:20:31 +01:00
Paul Bellamy 6b5f35e574 [proxy] Only replace the request body if we've modified it.
This is a temporary fix for a failure in docker-py tests:
"test_valid_no_config_specified".
2015-08-28 15:09:33 +01:00
Matthias Radestock 244a679f90 Merge pull request #1349 from weaveworks/issues/1266-detect-adverse-firewall-config
Warn on detection of REJECT rule in FORWARD chain

Fixes #1266.
2015-08-28 12:22:23 +01:00
Matthias Radestock 1a9909e3e2 also warn on weave reset when env's DOCKER_HOST points to proxy
This was missed in #1327.
2015-08-28 09:34:18 +01:00
Matthias Radestock 6655974ef3 cosmetic: tidy up log messages 2015-08-28 09:12:42 +01:00
Matthias Radestock cdf4fb605a Merge branch '1.0' 2015-08-27 20:04:04 +01:00
Michael Bridgen bca31c7335 Merge pull request #1365 from weaveworks/1356_ignore_interface_deletion_errors_in_weave_reset
ignore interface deletion errors during `weave reset`
2015-08-27 15:38:16 +01:00
Bryan Boreham 7652b44c21 Ensure we have the busybox image 2015-08-27 15:14:06 +01:00
Bryan Boreham 6fce798164 Factor out deserializeRoute() func 2015-08-27 15:10:31 +01:00
Bryan Boreham 7801dcd849 Factor out common loop receiving from netlink 2015-08-27 15:10:31 +01:00
Bryan Boreham 2eed101a93 In weavewait, wait for the multicast route to be added before calling container entrypoint.
We have moved the 'route add' command to the end of 'attach', so this
indicates that all network interface set-up is complete.
2015-08-27 15:10:31 +01:00
Bryan Boreham 3d25620d13 In proxy, rewrite /etc/hosts from 'weave attach', via new utility weavehosts 2015-08-27 15:03:41 +01:00
Bryan Boreham 6e89b036e2 Wait for ethwe via netlink, not via polling or signals
('docker kill' breaks restart policy)
2015-08-27 15:03:41 +01:00
Michael Bridgen 8b5992e43f Merge pull request #1290 from weaveworks/labels
Add role label to weave containers so scope can filter
2015-08-27 15:00:15 +01:00
Bryan Boreham 548b4aea40 Call to docker-py changed upstream 2015-08-27 14:54:20 +01:00
Tom Wilkie 42b64f826b Merge pull request #1358 from weaveworks/1357-dns-reverse-tombstone
Make reverse dns lookups honor tombstones.
2015-08-27 14:25:23 +01:00
Tom Wilkie 95379b0c5a Add works.weave.role=system label to weave containers. 2015-08-27 12:22:34 +00:00
Matthias Radestock f5918a3c14 remove dead code
since #1248
2015-08-27 08:42:48 +01:00
Matthias Radestock 1df752cd33 ignore interface deletion errors during weave reset
These can occur when a container dies during `weave reset`.

Fixes #1356.
2015-08-27 07:54:51 +01:00
Tom Wilkie a1f5d90323 Merge pull request #1363 from weaveworks/1362-fix-quoted-params
Fix test 295
2015-08-26 13:46:49 +01:00
Bryan Boreham 5289a380f2 Use $* instead of $@ to get the desired quoting 2015-08-26 12:31:38 +01:00
Tom Wilkie 914c88454d Review feedback 2015-08-25 16:53:21 +00:00
Tom Wilkie 46363f4129 Make reverse dns lookups honor tombstones. 2015-08-25 12:01:09 +00:00
Michael Bridgen bd19b86259 Merge pull request #1352 from weaveworks/doc-format
Small improvements in features doc
2015-08-25 12:56:56 +01:00
Tom Wilkie db2e7e4ba1 Merge pull request #1355 from weaveworks/1343-docker-bridge-in-resolv-conf
Pass docker bridge ip to dns server, and filter it out of upstream dns ips.
2015-08-25 09:48:06 +01:00
Bryan Boreham 760f419e8f Merge pull request #1354 from weaveworks/1347-dns-tombstone-comment
Lgtm.  Closes #1347
2015-08-24 17:05:54 +01:00
Tom Wilkie 58ae0cd113 Pass docker bridge ip to dns server, and filter it out of upstream dns ips. 2015-08-24 16:00:26 +00:00
Tom Wilkie 4809c113b3 Update comment. 2015-08-24 15:43:31 +00:00
Ilya Dmitrichenko 6d0db90f43 Revert "Merge pull request #1337 from weaveworks/1295-push-on-green"
This reverts commit 5054805ac6, reversing
changes made to 396df6bcda.
2015-08-24 14:22:36 +01:00
Ilya Dmitrichenko 75fb8f6ebf Revert "need to be in gopath to run make publish"
This reverts commit 130cf6eb2b.
2015-08-24 14:22:29 +01:00
Bryan Boreham 26739463a4 Escape a minus character to stop it being taken as a bullet, and clarify which example we are talking about 2015-08-24 14:19:14 +01:00
Paul Bellamy 130cf6eb2b need to be in gopath to run make publish 2015-08-24 11:10:59 +01:00
Paul Bellamy 5054805ac6 Merge pull request #1337 from weaveworks/1295-push-on-green
Publish latest images from CI on successful builds.
2015-08-24 10:58:14 +01:00
Adam Harrison ca94cfffe7 Detect REJECT rule in FORWARD chain 2015-08-21 16:25:49 +01:00
Matthias Radestock 396df6bcda Merge pull request #1348 from weaveworks/1345-1332-dns-response-size
Unify logic to tell if DNS response is too big.

Fixes #1345, fixes #1332
2015-08-21 14:03:00 +01:00
Matthias Radestock 58dafbfa9d Merge pull request #1344 from weaveworks/refactor-dns-handlers
Refactor dns handlers
2015-08-21 13:44:57 +01:00
Tom Wilkie 8516ab7c69 Unify logic to tell if DNS response is too big. 2015-08-21 12:39:12 +00:00
Matthias Radestock 2284bc2120 move error response construction to handler
and implement it in terms of existing functions, plus provide a
convenience method for sending the rather common NameError.
2015-08-21 12:09:22 +01:00
Matthias Radestock 31a490bfe6 ensure that make publish publishes up-to-date images
otherwise the git revision based image tag doesn't match what is in
the image.
2015-08-21 09:34:08 +01:00
Matthias Radestock 0b5f5fd74e extract response writing 2015-08-20 20:24:12 +01:00
Matthias Radestock 9a7abe68fd optimise response construction when no truncation is required
no need to do a binary search if all the answers fit
2015-08-20 20:18:56 +01:00
Matthias Radestock 2ea27ec08f simplify response truncation 2015-08-20 19:55:19 +01:00
Matthias Radestock 322441d5c8 inline truncateResponse 2015-08-20 19:55:19 +01:00
Matthias Radestock 7c7c302920 extract response construction 2015-08-20 19:17:03 +01:00
Matthias Radestock 69986e77dd cosmetic 2015-08-20 18:46:55 +01:00
Matthias Radestock 8182022d52 refactor dns handlers
introduce a handler struct, which

- enables lifting of all the handle* closures to methods
- eliminates the passing around of defaultMaxResponseSize
- reduces the number of free-floating functions
2015-08-20 18:27:58 +01:00
Matthias Radestock b075e93319 Merge pull request #1324 from weaveworks/1321_elminate_misleading_flag_parsing_error
eliminate misleading flag parsing error

Fixes #1321.
2015-08-20 17:34:32 +01:00
Matthias Radestock fd6d15e712 eliminate misleading flag parsing error
The standard mflags error reporting produces s.t. like
```
flag provided but not defined: -p
See '/home/weave/weaver --help'.
```
on stderr. This is misleading since the program name is container
local, so not something the user actually invoked.

Fixes #1321.
2015-08-20 17:19:48 +01:00
Matthias Radestock f399c3a888 Merge branch '1.0'
Conflicts:
	ipam/ring/ring_test.go
2015-08-20 16:32:09 +01:00
Matthias Radestock 79d1c404a7 Merge pull request #1342 from weaveworks/1336-fix-ring-fuzztest
Fix ring fuzz-test

Fixes #1336.
2015-08-20 16:25:50 +01:00
Adam Harrison 1e83e7a95c Merge branch '1.0' 2015-08-20 15:33:59 +01:00
Adam Harrison 086ab9d126 Correct MaxUDPPacketSize constant 2015-08-20 15:22:10 +01:00
Tom Wilkie 8a7821a15b Publish latest images from CI on successful builds. 2015-08-20 14:20:32 +00:00
Bryan Boreham 135c34a45a Don't remove peer from table until after we've copied its entries out 2015-08-20 13:11:51 +01:00
Bryan Boreham ca6e54890c Fix Transfer() when removing a peer, so we actually target the other peer. 2015-08-20 13:11:51 +01:00
Tom Wilkie dac219b64a Merge pull request #1339 from weaveworks/revert-1338-1336-check-len
Revert "In ipam ring unit test, check if we have any peers with entri…
2015-08-20 12:23:06 +01:00
Tom Wilkie 790a1757e0 Revert "In ipam ring unit test, check if we have any peers with entries to avoid crash " 2015-08-20 12:18:34 +01:00
Tom Wilkie aafa0f6783 Merge pull request #1338 from weaveworks/1336-check-len
In ipam ring unit test, check if we have any peers with entries to avoid crash
2015-08-20 12:15:27 +01:00
Bryan Boreham df5426dd8b Check if we have any peers with entries, to avoid crash 2015-08-20 11:57:56 +01:00
Adam Harrison 3803d79835 Merge pull request #1335 from weaveworks/1328_handle_invalid_status_sub_command
better error handling for invalid `weave status` sub-command
2015-08-20 11:48:01 +01:00
Matthias Radestock ceff3bed28 better error handling for invalid weave status sub-command
instead of showing '404 page not found'

Fixes #1328.
2015-08-20 11:14:59 +01:00
Matthias Radestock eebdbe226b Merge pull request #1325 from weaveworks/1322_handle_usage_locally
deal with `weave --help|help` locally

Fixes #1322.
2015-08-20 10:13:45 +01:00
Matthias Radestock 8ab639ddaa deal with weave --help|help locally
thus making them unaffected by docker breakages

Fixes #1322.
2015-08-20 10:03:21 +01:00
Matthias Radestock 812579a139 Merge pull request #1326 from weaveworks/576_better_version_check
better docker version check

Fixes #576.
2015-08-19 21:31:43 +01:00
Matthias Radestock 08f31886d6 better docker version check
Fixes #567. Supersedes #1298.
2015-08-19 21:20:14 +01:00
Matthias Radestock f080e5aa5c Merge pull request #1331 from weaveworks/clarify-test-160
clarify test 160
2015-08-19 20:41:59 +01:00
Matthias Radestock d61c719e45 cosmetic 2015-08-19 20:39:16 +01:00
Bryan Boreham 4d49bf3ab9 Add comment to clarify the reason why there is no explicit 'assert' test at the end. 2015-08-19 16:54:24 +01:00
Matthias Radestock f34f837106 Merge branch '1.0'
Conflicts:
	weave
2015-08-19 16:38:55 +01:00
Matthias Radestock 1326994a6d Merge pull request #1319 from weaveworks/dns-tcp
Expose dns server on tcp as well as udp

Fixes #1333.
2015-08-19 16:34:09 +01:00
Matthias Radestock 99ab0d3abc Merge branch '1.0' 2015-08-19 11:29:23 +01:00
Matthias Radestock e61f9afb72 Merge pull request #1330 from weaveworks/1329_plug_gossip_sender_leak
plug GossipSender leak

Fixes #1329.
2015-08-19 11:26:25 +01:00
Matthias Radestock 29c64b1f40 document weave env --restore
leftover from #1327
2015-08-19 11:20:10 +01:00
Bryan Boreham db51b772b4 Merge pull request #1327 from weaveworks/1288_restore_env
Closes #1288
2015-08-19 10:54:43 +01:00
Matthias Radestock 0b764a2a27 plug GossipSender leak
GossipChannel.sendDown is the (only) place which creates
GossipSenders. It has two call sites, Send and SendDown, only the
former of which performed a gc of existing senders. Therefore, in
configurations with

- a lot of connection churn, and
- SendDown invocations for these connections, and
- few or no Send invocations

we can leak GossipSenders.

The most likely scenario for this to occur is a peer that, while
having no other connections, is making/accepting connections which get
torn down post handshake, e.g. because IPAM detected a clash.

Fixes #1329.
2015-08-19 10:22:11 +01:00
Matthias Radestock a93a3e98b9 warn when stopping proxy when the env is using it 2015-08-18 18:08:02 +01:00
Matthias Radestock be94dcc8a3 introduce weave env --restore
`weave env` stashes the existing DOCKER_HOST in ORIG_DOCKER_HOST, and
`weave env --restore` sets DOCKER_HOST to $ORIG_DOCKER_HOST.

Closes #1288.
2015-08-18 17:20:21 +01:00
Matthias Radestock a34b31ad12 refactor: make proxy_addr more single purpose 2015-08-18 15:40:58 +01:00
Matthias Radestock e1d07aa264 cosmetic 2015-08-18 15:34:43 +01:00
Matthias Radestock 0d79a8fc43 cosmetic 2015-08-18 15:08:59 +01:00
Matthias Radestock 5d1411830b Merge branch '1.0' 2015-08-18 13:33:36 +01:00
Matthias Radestock dc91ce9ec6 Merge branch 'latest_release_doc_updates' into 1.0 2015-08-18 13:33:15 +01:00
Matthias Radestock 36a857f343 remove "Contact information" link on docs home page
It's broken, and we have a link in the footer anyway.

Fixes #1260.
2015-08-18 13:31:28 +01:00
Matthias Radestock c1c5450caf more idiomatic logger initialisation, with standard default log level 2015-08-18 12:04:48 +01:00
Bryan Boreham 0b4e8b8754 Merge pull request #1318 from weaveworks/1305_suppress_self_reconnection
lgtm. Fixes #1305.
2015-08-18 11:14:15 +01:00
Matthias Radestock f73dcba306 eliminate spurious warning when --ipalloc-range=""
Fixes #1320.
2015-08-18 09:50:42 +01:00
Ilya Dmitrichenko 147a537b82 We are not using gcloud, but it cause a conflict
https://s3.amazonaws.com/archive.travis-ci.org/jobs/76062893/log.txt
2015-08-18 09:47:37 +01:00
Ilya Dmitrichenko a4844b8ee7 We are not using gcloud, but it cause a conflict
https://s3.amazonaws.com/archive.travis-ci.org/jobs/76062893/log.txt
2015-08-18 09:46:09 +01:00
Ilya Dmitrichenko acde6cb0ee We are not using gcloud, but it cause a conflict
https://s3.amazonaws.com/archive.travis-ci.org/jobs/76062893/log.txt
2015-08-18 09:40:03 +01:00
Paul Bellamy b4e13215c7 expose dns server on tcp as well as udp
issue was discovered when testing scope with master vs 1.0 branches.
2015-08-18 09:35:53 +01:00
Matthias Radestock 4ecaa0f508 don't put blank lines around sub-status
not what I had in mind, and it breaks the tests
2015-08-18 09:00:01 +01:00
Matthias Radestock 86b7e4a6db Merge branch '1.0' 2015-08-18 08:50:41 +01:00
Matthias Radestock aa19028583 Merge branch 'latest_release_doc_updates' into 1.0 2015-08-18 08:50:19 +01:00
Matthias Radestock a6e2296e0a Merge branch '1.0' into latest_release_doc_updates 2015-08-18 08:49:31 +01:00
Matthias Radestock 8c5248da43 Add release 1.0.2 2015-08-18 08:27:26 +01:00
Matthias Radestock 59859c4aed clarify allocation subnet overlap failure
Closes #1317.
2015-08-18 01:50:30 +01:00
Matthias Radestock 0e85783257 cosmetic: add blank lines around weave status output
Closes #1315.
2015-08-18 01:38:51 +01:00
Matthias Radestock d8e8cd6e51 don't reconnect to ourself
When we discover that a connection target address leads to ourself we
set the retry time to the zero time.Time value - the only special
time.Time value. We use that marker to a) suppress subsequent
connection attempts, and b) display the next retry as 'never' in
`weave status|report`.

Closes #1305.
2015-08-18 00:51:33 +01:00
Matthias Radestock bbc91c1273 Merge pull request #1307 from weaveworks/1306-dns-recurse-compress
Compress recursive answers if they are too big.

Fixes #1306.
2015-08-17 19:23:46 +01:00
Tom Wilkie 67f974923b Test for recursive DNS queries & compression.
Note this doesn't test the golang resolver, where the original error
was found, as I can't find a way to point the golang resolver at a
custom dns server during a test.  It does check that a compressed
response from an upstream server is correctly handled.
2015-08-17 18:25:36 +01:00
Tom Wilkie 4f00dab4c4 Compress recursive answers if they are too big. 2015-08-17 18:25:26 +01:00
Matthias Radestock 74e29c8990 Merge branch '1.0'
Conflicts:
	nameserver/server.go
	nameserver/server_test.go
2015-08-17 18:10:56 +01:00
Matthias Radestock 7fb597a8bf Merge pull request #1313 from weaveworks/issues/1306-dns-compress-1-0-2
Try to compress too long replies (when forwarding).

Fixes #1306.
2015-08-17 18:05:04 +01:00
Alvaro Saurin c50c90ea8d Try to compress too long replies (when forwarding). 2015-08-17 18:50:16 +02:00
Paul Bellamy 74883c5da8 Merge pull request #1310 from weaveworks/improve_proxy_ignore_messages
Improve log messages for when the proxy ignores a container
2015-08-17 16:27:45 +01:00
Matthias Radestock 375af0a7b9 Improve log messages for when the proxy ignores a container
- 'ignoring' could be misread as 'dropped request', so change that to
  'leaving container alone'
- more elaborate reasons
2015-08-17 16:15:45 +01:00
Matthias Radestock 8c9679b19c Merge branch '1.0'
Conflicts:
	circle.yml
2015-08-17 15:01:44 +01:00
Tom Wilkie d220542491 Add sudo apt-get update to circle.yml 2015-08-17 13:37:41 +00:00
Alvaro 0a80fdcc1d Merge pull request #1312 from weaveworks/circle
Add sudo apt-get update to circle.yml
2015-08-17 13:52:00 +02:00
Tom Wilkie 5fbcb3f905 Add sudo apt-get update to circle.yml 2015-08-17 08:49:40 +00:00
Matthias Radestock 067f96023a correct option name in log message 2015-08-17 09:37:46 +01:00
Matthias Radestock 9de7c9ed0d Merge pull request #1303 from weaveworks/1302-proxy-net-none
[proxy] attach containers with --net=none to weave

Fixes #1302.
2015-08-14 14:03:36 +01:00
Paul Bellamy 0de292c0d4 [proxy] attach containers with --net=none to weave 2015-08-14 13:48:32 +01:00
Matthias Radestock eaa5385069 refactor: use new proxy_start_container function 2015-08-13 19:54:00 +01:00
Matthias Radestock fa2aa1f791 Merge branch '1.0'
Conflicts:
	test/640_proxy_restart_reattaches_test.sh
2015-08-13 19:46:23 +01:00
Matthias Radestock 181ce4cc60 Merge pull request #1296 from weaveworks/1294_extract_proxy_container_start
extract test functions for "start container via proxy"

Fixes #1294.
2015-08-13 19:40:53 +01:00
Matthias Radestock 65578211ef extract test functions for "start container via proxy"
This also eliminates the redefinition of 'start_container' by some of
the tests, which causes failures when multiple tests are run with
`run_all.sh`.

Fixes #1294.
2015-08-13 15:01:15 +01:00
Matthias Radestock 78df99e7e7 Merge branch '1.0' 2015-08-13 14:37:31 +01:00
Matthias Radestock 90ed76853c fix test breakage
on master, and only when running via `run_all.sh`. Weird.
2015-08-13 14:36:30 +01:00
Matthias Radestock 26f4a41900 Merge branch '1.0' 2015-08-13 14:07:22 +01:00
Matthias Radestock a3b4d6cdbf consistency: use $SMALL_IMAGE instead of $BASE_IMAGE
whenever possible
2015-08-13 14:06:43 +01:00
Matthias Radestock 686500b181 Merge branch '1.0' 2015-08-13 14:05:35 +01:00
Matthias Radestock 84c5c52090 fix broken test silliness 2015-08-13 14:05:17 +01:00
Matthias Radestock d5de0b41f9 Merge branch '1.0'
Conflicts:
	proxy/proxy.go
2015-08-13 13:57:02 +01:00
Matthias Radestock bd41d114b5 Merge pull request #1291 from weaveworks/docker-1.8
Docker 1.8 compatibility.

Fixes #1287.
2015-08-13 13:53:03 +01:00
Matthias Radestock 94d2f84364 refactor: use proxy abstraction 2015-08-13 13:50:29 +01:00
Paul Bellamy bf2b456af1 Don't use .Volumes in tests, as it's gone in docker 1.8 2015-08-13 13:36:47 +01:00
Paul Bellamy 4961e83686 [proxy] support new docker 1.8 --net="default" 2015-08-13 13:36:47 +01:00
Paul Bellamy f70dc6660a [proxy] lock docker api usage to 1.15 2015-08-13 13:36:47 +01:00
Matthias Radestock 2bb84ae28b Merge branch '1.0'
Conflicts:
	weave
2015-08-13 13:18:55 +01:00
Paul Bellamy 360c0cb642 Merge commit '74eef4dedae617' into 1.0 2015-08-13 12:38:51 +01:00
Matthias Radestock e319f54d3f Merge branch '1.0'
Conflicts:
	site/proxy.md
2015-08-13 11:36:01 +01:00
Matthias Radestock 1ce9551ba6 Merge branch 'latest_release_doc_updates' into 1.0 2015-08-13 11:34:56 +01:00
Matthias Radestock 4c566c8587 correct typo 2015-08-13 11:34:16 +01:00
Paul Bellamy 74eef4deda [proxy] mount all tls volumes as readonly 2015-08-13 11:13:22 +01:00
Paul Bellamy 2576e819a7 Revert "fix intermittent test failure"
This reverts commit e2fec3d007.

Was causing a failure on circleci
2015-08-13 11:12:50 +01:00
Tom Wilkie cdab6a71b7 Merge pull request #1289 from weaveworks/move-listvar
Move ListVar into common, so it can be reused elsewhere.
2015-08-12 12:56:25 +01:00
Tom Wilkie 45293fdcac Move ListVar into common, so it can be reused elsewhere. 2015-08-12 11:35:57 +00:00
Paul Bellamy e2fec3d007 fix intermittent test failure
Tests were running in the same shell, so function definitions were
leaking between tests.
2015-08-12 11:14:51 +01:00
Matthias Radestock 7656752d87 unbreak test
caused by faulty merge
2015-08-12 07:40:20 +01:00
Matthias Radestock d0ed225184 Merge branch '1.0'
Conflicts:
	weave
2015-08-11 15:01:54 +01:00
Paul Bellamy 12ed5cc9ee Merge pull request #1284 from weaveworks/1279_proxy_weave_run
prevent proxy from interferring with `weave run`
2015-08-11 14:54:27 +01:00
Matthias Radestock f8639a57e7 prevent proxy from interferring with weave run
...which could result in containers unexpectedly getting multiple IP
addresses.

Fixes #1279.
2015-08-11 14:02:23 +01:00
Adam Harrison c2147f80b7 Merge pull request #1283 from weaveworks/1185_report_pcap_stats
add pcap stats to `weave report`
2015-08-11 13:09:34 +01:00
Matthias Radestock f1b9cf4fc0 Merge pull request #1282 from weaveworks/1281-dns-remove-dead-quick
Remove DNS entries for dead containers when adding correctly.

Fixes #1281.
2015-08-11 13:08:46 +01:00
Matthias Radestock c1d799a06c add pcap stats to weave report
Closes #1185.
2015-08-11 12:57:52 +01:00
Tom Wilkie 6a5044fc70 Make nameserver logging more consistent. 2015-08-11 11:32:19 +00:00
Tom Wilkie 7fa568872c Ensure we delete the fqdn is the container fails to start. 2015-08-11 11:32:17 +00:00
Adam Harrison f3ad81d554 Merge pull request #1248 from weaveworks/issues/1025-enhanced-weave-status
Enhanced weave status
2015-08-11 12:29:29 +01:00
Adam Harrison fc9a1c8664 new weave status, weave status ..., and weave report 2015-08-11 12:15:13 +01:00
Adam Harrison 00ecff09f7 Move status HTTP handlers into prog/weaver/http.go 2015-08-11 12:01:27 +01:00
Adam Harrison 278807a199 Move router HTTP handlers into router/http.go 2015-08-11 12:01:27 +01:00
Matthias Radestock 8bce900170 Merge pull request #1247 from weaveworks/test_frag
add test for PMTU discovery and packet fragmentation
2015-08-10 22:02:07 +01:00
Matthias Radestock cf6d6d0cd3 add test for PMTU discovery and packet fragmentation 2015-08-10 17:50:21 +01:00
Matthias Radestock 94af02fbf4 Merge branch '1.0'
Conflicts:
	weave
2015-08-10 17:37:06 +01:00
Matthias Radestock 9e65cc20cb cosmetic 2015-08-10 17:33:45 +01:00
Tom Wilkie 25c4a2961e Merge pull request #1278 from weaveworks/1276_warn_on_iprange_overlap
warn on -iprange overlap
2015-08-10 17:27:47 +01:00
Matthias Radestock 755a949f6d Merge pull request #1277 from weaveworks/1275-negative-dns
Return NXDOMAIN when we don't have entries

and drop the non-authoritative special case for recursive dns.

Fixes #1275.
2015-08-10 17:19:44 +01:00
Tom Wilkie 42debde746 Merge pull request #1259 from weaveworks/1257-proxy-chunking
Proxy chunking should handle arbitrarily large chunks
2015-08-10 15:57:19 +01:00
Tom Wilkie c2d5b35cd6 Add test for negative DNS queries 2015-08-10 13:13:12 +00:00
Matthias Radestock f4e7c85219 warn on -iprange overlap
Closes #1276.
2015-08-10 13:27:06 +01:00
Tom Wilkie 073836905a Return NXDOMAIN when we don't have entries, and drop the non-authoritative special case for recursive dns. 2015-08-10 12:19:21 +00:00
Matthias Radestock fd2a59417d cosmetic 2015-08-10 12:39:00 +01:00
Paul Bellamy 6d7e784c25 review feedback 2015-08-10 11:02:51 +01:00
Matthias Radestock b2a24d1cbe Merge branch '1.0'
Conflicts:
	nameserver/zone_lookup.go
2015-08-10 10:27:10 +01:00
Tom Wilkie 0a2701bbbc Merge pull request #1268 from weaveworks/1243_fix_claim_test
add a sleep to improve test reliability
2015-08-10 10:23:48 +01:00
Alvaro 475daa82b3 Merge pull request #1273 from weaveworks/1270_mdns_result_race
ignore DuplicateError when inserting mDNS answer in zone
2015-08-10 11:15:47 +02:00
Matthias Radestock c3b653b1b9 ignore DuplicateError when inserting mDNS answer in zone
When we issue two concurrent mDNS queries for the same name, the
answer to the second one encounters a DuplicateError when inserting
into the zone. We would return that error, which causes the query
would fail. And we'd cache that fact. All bad.

So ignore DuplicateError.

Fixes #1270.
2015-08-08 22:01:45 +01:00
Matthias Radestock 1a11b989e7 simplify test 2015-08-07 14:40:34 +01:00
Matthias Radestock 010792f714 cosmetic: more sensible order of weave commands 2015-08-07 11:44:47 +01:00
Matthias Radestock 536369bc12 Merge pull request #1265 from weaveworks/1252-proxy-non-root-hosts
[proxy] rewrite /etc/hosts from outside the container

Fixes #1252.
2015-08-06 13:30:02 +01:00
Paul Bellamy f55655216f [proxy] rewrite /etc/hosts from outside the container
Avoids problems when container user is non-root. Added a test for this
and the --no-rewrite-hosts flag.
2015-08-06 13:14:18 +01:00
Matthias Radestock 43ef3b8515 give routers some time to establish connectivity 2015-08-06 11:54:58 +01:00
Paul Bellamy 3180c67151 -no-rewrite-hosts -> --no-rewrite-hosts 2015-08-06 11:01:35 +01:00
Adam Harrison 457e162d0c Merge branch '1.0'
Conflicts:
	site/ipam.md
2015-08-06 09:56:50 +01:00
Adam Harrison ed3207afe7 Merge remote-tracking branch 'upstream/latest_release_doc_updates' into 1.0 2015-08-06 09:51:31 +01:00
Adam Harrison 8e5b0ceceb Merge pull request #1262 from weaveworks/latest_release_doc_udpates
Fix IPAM doc bug
2015-08-06 09:48:14 +01:00
Tom Wilkie f9127e90db Merge pull request #1263 from weaveworks/integration-tests-no-save-file
don't save the python test file when running test/600
2015-08-05 18:50:22 +01:00
Paul Bellamy 94db0beb25 don't save the python test file when running test/600 2015-08-05 18:04:49 +01:00
Adam Harrison 4a1bb1a33a Fix IPAM doc bug 2015-08-05 17:53:24 +01:00
Adam Harrison 77996158ef Merge branch '1.0' 2015-08-05 14:42:09 +01:00
Adam Harrison 93984e1955 Merge pull request #1261 from weaveworks/arp_all_ips
send ARP update for *all* container IPs; not just the first one
2015-08-05 14:38:16 +01:00
Matthias Radestock 67aae051d6 send ARP update for *all* container IPs; not just the first one
This was missed in #498.
2015-08-05 13:35:35 +01:00
Matthias Radestock 6cc7749cf2 cosmetic: remove debug logging from test 2015-08-05 12:31:20 +01:00
Matthias Radestock c47e57cc29 cosmetic 2015-08-05 11:55:11 +01:00
Matthias Radestock de6f5a93e8 refactor: extract build flags 2015-08-05 11:11:57 +01:00
Paul Bellamy 157910ec9a adding integration test for proxy handling large http chunks 2015-08-05 10:52:06 +01:00
Paul Bellamy b85b90ef4e Proxy chunking should handle arbitrarily large chunks 2015-08-04 17:47:51 +01:00
Paul Bellamy 1d1ebc103d Merge remote-tracking branch 'upstream/1.0' 2015-08-04 14:29:12 +01:00
Paul Bellamy eee13e7dd9 Merge pull request #1253 from weaveworks/1241-no-command-specified
[proxy] Handle case where no command is specified.
2015-08-04 13:11:35 +01:00
Paul Bellamy 7cc53c4c68 [proxy] Handle case where no command is specified.
The docker daemon can't do this because we set /w/w.
2015-08-04 12:32:42 +01:00
Matthias Radestock 9c22066bdb Merge pull request #1256 from weaveworks/1245-dns-loadbalancing
Add note to explain DNS shuffle effects.

Fixes #1245.
2015-08-04 12:22:23 +01:00
Tom Wilkie f241e15ec1 Review feedback 2015-08-04 11:00:32 +00:00
Tom Wilkie 881ece3553 Add note to explain dns shuffle effects. 2015-08-04 10:47:36 +00:00
Michael Bridgen 281bf02871 Merge branch 'pr1254' 2015-08-03 15:26:08 +01:00
Michael Bridgen 778038fdd3 Merge branch 'fix-dotted-imports-for-log' of https://github.com/dpw/weave into pr1254 2015-08-03 14:29:53 +01:00
David Wragg e7ee72836d Log -> log 2015-08-03 14:13:24 +01:00
David Wragg 31c0506b85 Eliminate dotted imports of common for the sake of Log 2015-08-03 14:07:16 +01:00
David Wragg 7d6f85424c Move OnOff into router.go 2015-08-03 14:06:23 +01:00
Tom Wilkie ca89cfee3d Merge pull request #1250 from paulbellamy/testrunner-summarize-fails
Some usability tweaks to the test runner
2015-07-31 12:36:50 +01:00
Paul Bellamy 5a37f652c2 add -v to testrunner, and less output in happy path 2015-07-31 12:25:50 +01:00
Paul Bellamy cc7b781bb3 have testrunner summarize failed tests so they are easier to find 2015-07-31 12:12:33 +01:00
Paul Bellamy 55051f0194 Merge remote-tracking branch 'upstream/1.0' 2015-07-31 11:01:19 +01:00
Paul Bellamy 78e0e79b26 Merge pull request #1238 from weaveworks/1232-weavewait-image
[proxy] only mount /w into weavewaited containers
2015-07-31 10:57:26 +01:00
Paul Bellamy b7e8938ab4 scope the test runner call so scope works 2015-07-31 10:49:21 +01:00
Matthias Radestock f8327c3c6c expand test coverage to unicast relaying
by way of an ipam space request from host3 to host1, via host2.
2015-07-30 20:38:00 +01:00
Paul Bellamy e3851e6e55 Merge pull request #1246 from weaveworks/gce-parameterize
parameterize test/gce.sh so scope can override TEMPLATE_NAME and NUM_HOSTS
2015-07-30 16:18:59 +01:00
Matthias Radestock 6a136eebb2 make parallel test running work locally
@tomwilkie assures me this change won't break CircleCI. We shall see.

This now works for me:

make clean
make COVERAGE=true
COVERDIR=test/coverage SLOW=true ./test/units.sh
cd test
./setup.sh
COVERAGE=true PARALLEL=true ./run_all.sh
./gen_coverage_reports.sh
2015-07-30 15:57:49 +01:00
Paul Bellamy 9396c046cd parameterize test/gce.sh so scope can override TEMPLATE_NAME and NUM_HOSTS 2015-07-30 15:48:22 +01:00
Paul Bellamy 4958b8d37a [proxy] Mount /w from the host for weavewaited containers
We set it at container create. Had tried also setting it at start, but
it seems to cause weird behaviour, and there is no way to do it from the
CLI.
2015-07-30 15:11:03 +01:00
Paul Bellamy e2389a4061 [proxy] Don't try to attach if container failed to start 2015-07-30 13:31:47 +01:00
Paul Bellamy dccd199369 Merge pull request #1242 from weaveworks/1239-600-docker-py
Shard 600_proxy_docker_py into 4.
2015-07-30 13:14:54 +01:00
Tom Wilkie a87be89095 Typos. Honestly 2015-07-30 11:07:17 +00:00
Tom Wilkie 5c9a13d343 Shard 600_proxy_docker_py into 4. 2015-07-30 10:38:02 +00:00
Tom Wilkie bfe07fc71a Give each shard 5 VMs 2015-07-30 10:32:16 +00:00
Tom Wilkie fa95b67c92 Add summary to bottom of test runner output.
Also, don't sort tests by #hosts when run sequentially, and fix typo in run_all.sh.

Fixes #1240
2015-07-30 10:29:05 +00:00
Adam Harrison 728203912e .gitignore Vim recovery files 2015-07-30 10:53:59 +01:00
Paul Bellamy 27289e7b7b Merge pull request #1236 from weaveworks/1169-frugal-frugal-frugal
Run integration tests in parallel when possible.
2015-07-30 10:16:39 +01:00
Tom Wilkie 669a0db528 Run integration tests in parallel when possible. 2015-07-29 17:28:58 +00:00
Paul Bellamy 4da999ba86 Merge pull request #1235 from weaveworks/gce
Improve CI run time
2015-07-29 17:38:30 +01:00
Paul Bellamy 5e9bd5424a Removed all the imports from "code.google.com" 2015-07-29 15:47:02 +01:00
Tom Wilkie 3bffd871b8 Merge pull request #1230 from weaveworks/1154-proxy-coverage
Add coverage to proxy for integration tests.
2015-07-29 13:24:21 +01:00
Adam Harrison 2d450ac39d Merge pull request #1225 from weaveworks/21-dns-listen-addr
Allow users to set dns listen address
2015-07-29 13:18:10 +01:00
Tom Wilkie 6fe69590c4 Add coverage to proxy for integration tests. 2015-07-29 12:06:29 +00:00
Tom Wilkie 4df3d7f150 Reduce the amount of parallelism in the ipam tests 2015-07-29 10:13:02 +00:00
Tom Wilkie 51128a6705 Parallelise the copying of /etc/hosts. 2015-07-29 09:58:51 +00:00
Tom Wilkie e7676979ee Parallelise the copying of imaages etc 2015-07-29 09:58:05 +00:00
Tom Wilkie da36c78942 Reduce the number of times gcs.sh ssh's into the VMs 2015-07-29 09:41:57 +00:00
Matthias Radestock 77358140d9 Merge pull request #1219 from squaremo/driveby
Remove misleading comment and lowercase deniedBy
2015-07-28 18:09:01 +01:00
Adam Harrison 1701bc3e92 Merge branch '1.0'
Conflicts:
	weave
2015-07-28 18:06:44 +01:00
Matthias Radestock ba0ffd225e Merge pull request #1231 from weaveworks/issues/1229-explicitly-set-docker-bridge-mac
Enforce docker bridge address assignment type on launch

Fixes #1229.
2015-07-28 17:59:46 +01:00
Adam Harrison a14d4d9f8e Enforce docker bridge address assignment type on launch 2015-07-28 17:51:48 +01:00
Tom Wilkie db6ee9954c Allow users to set dns listen address so we can run the weave router in the host net namespace. 2015-07-28 14:49:09 +00:00
Paul Bellamy 792c4c8de4 Merge pull request #1227 from weaveworks/gce-gc
Extend scheduler to periodically garbage collect stranded VMs
2015-07-28 15:35:28 +01:00
Matthias Radestock 820307dd4e Merge pull request #1228 from weaveworks/1030-150-connect-forget
Don't init the ring if the address is not in range.

Fixes #1030.
2015-07-28 15:29:16 +01:00
Tom Wilkie 88144ac7f8 Review feedback 2015-07-28 14:16:38 +00:00
Tom Wilkie da7ac78694 Don't try and init the ring if the IP address is not in our range. 2015-07-28 14:12:42 +00:00
Tom Wilkie 10dbd9ad4c Merge pull request #1224 from weaveworks/1203_proper_mock_gossip
proper mock periodic gossip
2015-07-28 13:29:20 +01:00
Tom Wilkie 9779e06f66 Extend scheduler to periodically garbage collect stranded VMs 2015-07-28 13:19:38 +01:00
Matthias Radestock f861d22593 do proper mock periodic gossip
instead of abusing broadcast gossip

Fixes #1203.
2015-07-28 10:37:18 +01:00
Paul Bellamy e3f0565517 Merge pull request #1221 from weaveworks/1220_include_test_dir_coverage
include directory of test code in coverage
2015-07-28 10:05:16 +01:00
Matthias Radestock 9a91b3ce9c include directory of test code in coverage
Fixes #1220.
2015-07-27 17:08:31 +01:00
Michael Bridgen c88361473c Remove misleading comment and lowercase deniedBy
* the comment "don't make the caller wait" applies to both branches
   of that if clause, and having it on one branch implies the other
   does make the caller wait
 * there's no reason for DeniedBy to start with a capital: it's a
   method on a private struct and it's not part of an interface.
2015-07-27 16:22:32 +01:00
Michael Bridgen a2e1a2d375 Merge branch 'pr1200' 2015-07-27 15:46:29 +01:00
Matthias Radestock 536ce992fc re-enable test
our switch on CircleCI from Docker 1.7.0 to 1.7.1 should make this
pass now.
2015-07-27 14:47:55 +01:00
Matthias Radestock 8d57b85a3a Merge branch 'master' into weave_1.1_readme_updates
Conflicts:
	README.md
2015-07-27 14:33:05 +01:00
Matthias Radestock ce37b622eb Merge branch '1.0' 2015-07-27 14:25:06 +01:00
Matthias Radestock d5e510f778 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-27 14:24:33 +01:00
Matthias Radestock be8e414d5a Merge pull request #1217 from weaveworks/1186_document_root_docker
document how to run weave when docker access is root-only

Closes #1186.
2015-07-27 14:23:50 +01:00
Matthias Radestock 65e94f624b document how to run weave when docker access is root-only
Closes #1186.
2015-07-27 14:13:50 +01:00
Paul Bellamy ed4fb14f52 Merge pull request #1214 from weaveworks/rebuild-gce-templates
[circle] use new gce templates for docker 1.7.1
2015-07-27 13:38:44 +01:00
Matthias Radestock 32cce0c636 Merge branch 'master' into weave_1.1_readme_updates 2015-07-27 13:31:48 +01:00
Paul Bellamy 34bb7ae84a [circle] use new gce templates for docker 1.7.1 2015-07-27 12:51:12 +01:00
Michael Bridgen 5389e31190 Merge branch '687-detect-ipam-clash' of github.com:weaveworks/weave into pr1200 2015-07-27 11:54:31 +01:00
Bryan Boreham f0915221d1 Rename 'reclaim' to 'noErrorUnknown' which describes the behaviour better 2015-07-23 20:16:30 +01:00
Matthias Radestock aa4efd63ef cosmetic: uncomment test the way ordained by emacs 2015-07-22 16:55:43 +01:00
Tom Wilkie a12d63bb12 Make ipam test less stressful, so it doesn't timeout. 2015-07-22 12:53:27 +00:00
Tom Wilkie 062a25a032 Make unit test timeout 8mins. 2015-07-22 12:19:12 +00:00
Tom Wilkie 9e6d08c606 Put 2m timeout on all unit tests. 2015-07-22 11:56:39 +00:00
Alvaro 976641c3b6 Reverted: Fixed typo 2015-07-22 12:17:29 +02:00
Alvaro 2f80f12001 Fixed typo 2015-07-22 12:14:38 +02:00
Bryan Boreham 647b755b64 Check manually-assigned addresses with IPAM to see if they clash 2015-07-21 17:02:52 +01:00
David Wragg 26dc83dbc2 Merge weaveworks/519_remove_outermost_gob (PR #1189) 2015-07-21 12:01:40 +01:00
Matthias Radestock 3c107d675a Merge branch '1.0' 2015-07-21 11:42:49 +01:00
Matthias Radestock a20ca49344 Merge pull request #1206 from weaveworks/1201-weavewait-ro
[proxy] Mount weavewait readonly so it can't be tampered with

Fixes #1201.
2015-07-21 11:41:48 +01:00
Paul Bellamy aa8466f688 [proxy] Mount weavewait readonly so it can't be tampered with 2015-07-21 11:30:56 +01:00
Tom Wilkie 2980586e76 Put timeout on nameserver test to try and expose #1203 2015-07-21 09:25:04 +00:00
Paul Bellamy dba116bae1 Merge remote-tracking branch 'upstream/1.0' 2015-07-21 10:13:24 +01:00
Matthias Radestock 0b7d462adf enforce a message size limit
so we do not allocate loads of memory when receiving (accidental or
deliberate) garbage
2015-07-20 23:51:04 +01:00
Matthias Radestock 6f8622a1a0 replace outermost framing on tcp connection
switch from gob to length-prefix encoding
2015-07-20 23:51:04 +01:00
Matthias Radestock af049efb40 refactor: s/SimpleTCP{Sender,Receiver}/GobTCP{Sender,Receiver} 2015-07-20 23:51:02 +01:00
Matthias Radestock ad4e4ce6b8 refactor: make 'inner' encoder/decoder explicit 2015-07-20 23:50:10 +01:00
Tom Wilkie 4c9b0be117 Merge pull request #1198 from weaveworks/1146-coverage
When running unit tests, output coverage for imported modules.
2015-07-20 20:34:12 +01:00
Tom Wilkie a9dae46110 When running unit tests, output coverage for imported modules. 2015-07-20 15:47:07 +00:00
Paul Bellamy 53628fdeff Merge pull request #1187 from weaveworks/1182-proxy-tls-close
[proxy] Fully close TLS sockets, as they have no CloseWrite
2015-07-20 16:46:21 +01:00
Bryan Boreham e34093c328 Merge pull request #1197 from weaveworks/1158-flaky
LGTM
2015-07-20 16:02:52 +01:00
Tom Wilkie 9131b46263 Flush gossip messages after each turn, to ensure there isn't a build up of pending messages. 2015-07-20 14:36:40 +00:00
Michael Bridgen 2a9c3fc64a Merge branch 'pr1112' 2015-07-20 15:31:42 +01:00
Michael Bridgen c44c61dc83 Merge branch '1103-proxy-chunking' of github.com:weaveworks/weave into pr1112 2015-07-20 15:09:50 +01:00
Paul Bellamy 11663dd29f [proxy] rewrote chunked response handler
1) We cannot send "Connection: close", because the fsouza docker client
   expects the tcp socket to stay open between requests.

2) Because we cannot force-close the connection, we can't hijack the
   connection (because go's net/http doesn't let use un-hijack it).

3) Because we need to maintain the individual chunking of messages (for
   docker-py), we can't just copy the response body, as Go will remove and
   re-add the chunking willy-nilly.

Therefore, we have to read each chunk one-by-one, and flush the
ResponseWriter after each one.
2015-07-20 14:43:16 +01:00
Bryan Boreham 90b7c3625d Merge pull request #1176 from weaveworks/1156-gossip-timestamp
LGTM
2015-07-20 14:28:01 +01:00
Tom Wilkie 4e29dba5cd Make Gossip DNS reject gossip messages if clockskew > tombstoneTimeout / 2 2015-07-20 13:12:07 +00:00
Matthias Radestock f1b5a00cb3 Merge pull request #1195 from weaveworks/1177-dns-disappear
Don't periodically delete all non-tombstone entries.

Fixes #1177.
2015-07-20 13:07:42 +01:00
Tom Wilkie 1a4b38a10c Don't delete all the non-tombstone entries every 10mins! 2015-07-20 12:03:46 +00:00
Tom Wilkie 9ab2da8deb Add GET /name handler to return all dns entries (including tombstones) for debugging.
Also, make Address marshall into json as an IP string, not a number.
2015-07-20 12:03:33 +00:00
Matthias Radestock 66473e6021 refactor: return slice instead of pointer to slice from tombstone() 2015-07-20 12:37:54 +01:00
Paul Bellamy a9229b9197 weave env should still work with '--log-level=debug' 2015-07-20 11:57:20 +01:00
Paul Bellamy 7b9e59833e test upload_executable helper should mkdir before uploading 2015-07-20 10:58:39 +01:00
Tom Wilkie 5baddb83cb Comment out failing test until we figure out what to do. 2015-07-20 09:45:02 +00:00
Tom Wilkie 4e56247ed9 Merge pull request #1193 from weaveworks/disable_dns_in_multiweave
Disable dns in multiweave
2015-07-20 10:41:56 +01:00
Matthias Radestock ae2348875b disable dns in multiweave
Thus unbreaking it post #1065.
2015-07-19 22:52:42 +01:00
Matthias Radestock fafaeef07d introduce --no-dns option
undocumented, since it is mainly meant for testing
2015-07-19 22:51:40 +01:00
Matthias Radestock 5b62b8c1e3 refactor: inline populate_dns
and ditch the wait_for_status, since we've only just called that
2015-07-19 22:32:33 +01:00
Matthias Radestock 7c17c8aec3 refactor: simplify router arg parsing
using the same "always shift one" approach as in proxy_args
2015-07-19 21:56:04 +01:00
Matthias Radestock 64408b126e weave launch-router wasn't returning the correct container id
since $CONTAINER gets stomped on by various functions, in particular
populate_dns.

Broken by #1065.
2015-07-19 21:50:45 +01:00
Bryan Boreham 2a1f090a88 Merge pull request #1183 from weaveworks/1181-data-race
Correctly stop the test gossip router to prevent complaints of data races in subsequent tests.
2015-07-17 17:14:46 +01:00
Matthias Radestock e2a2a8f18f Merge branch '1.0' 2015-07-17 15:07:45 +01:00
Matthias Radestock dafa30725e Merge branch 'latest_release_doc_updates' into 1.0 2015-07-17 15:07:19 +01:00
Matthias Radestock 24b9a56e0a Merge pull request #1172 from weaveworks/issues/1061-improve-blockquote
Use Boostrap styles for warnings in docs

Fixes #1061.
2015-07-17 15:06:40 +01:00
Tom Wilkie a3d32068d2 Correctly stop the test gossip router to prevent complaints of data races in subsequent tests. 2015-07-17 13:48:39 +00:00
David Kaltschmidt e7f6682593 Use bootstrap alert styles for blockquote 2015-07-17 15:14:29 +02:00
Paul Bellamy 3f4b385b0f [proxy] If we can't CloseWrite a connection (tls), just Close it so clients don't hang 2015-07-17 14:09:27 +01:00
Paul Bellamy 5fc16a8267 [proxy] use a waitgroup as it's more semantically accurate 2015-07-17 14:08:51 +01:00
Bryan Boreham 68afbe31b0 Shrink image file size 2015-07-17 14:07:23 +01:00
Tom Wilkie ba3451e9ca Merge pull request #1180 from weaveworks/1171-210-failures
Don't swallow errors in the docker client.
2015-07-17 13:38:38 +01:00
Tom Wilkie 25c9180fdf Don't swallow errors in the docker client. 2015-07-17 12:35:12 +00:00
Paul Bellamy e03a4bb176 updating boot2docker docs from 1.0 to master 2015-07-17 12:55:39 +01:00
Paul Bellamy 4d594458d2 Merge branch '1.0' 2015-07-17 12:47:23 +01:00
Paul Bellamy 38176dcbb6 Merge remote-tracking branch 'upstream/latest_release_doc_updates' into 1.0 2015-07-17 12:46:48 +01:00
Paul Bellamy 854d83f294 updating boot2docker docs for proxy 2015-07-17 12:41:04 +01:00
Matthias Radestock 358ae3a936 Merge pull request #1174 from weaveworks/1128-iprange-error
More helpful error message when --ip-alloc-range mismatched

Closes #1128.
2015-07-17 12:35:20 +01:00
Paul Bellamy f3131fab57 Merge pull request #1175 from paulbellamy/975-boot2docker-documentation-update
updating boot2docker docs for proxy
2015-07-17 12:32:54 +01:00
Paul Bellamy 397f1398ee updating boot2docker docs for proxy 2015-07-17 12:30:14 +01:00
Bryan Boreham 2dbf83889b Remove unused error messages 2015-07-17 12:19:54 +01:00
Bryan Boreham 9b2c5b8466 Improve description of merge error 2015-07-17 12:19:33 +01:00
Bryan Boreham 1f4b943454 More helpful error message when --ip-alloc-range mismatched 2015-07-17 11:42:30 +01:00
Matthias Radestock 2ca0fb93c9 Merge pull request #1173 from weaveworks/1168-checkandpanic
Make nameserver.checkAndPanic look for dups, call it more often.

Fixes #1168.
2015-07-17 11:37:34 +01:00
Matthias Radestock 47273d424f Merge pull request #1170 from weaveworks/exec-dockerfile
Re-arrange weaveexec Dockerfile to improve download times
2015-07-17 11:36:15 +01:00
Bryan Boreham f4d6e028d4 Simplify 2015-07-17 11:33:29 +01:00
Tom Wilkie f10e0e4add Merge pull request #1159 from weaveworks/1150-claim-from-peer
Implement claiming addresses from other peers
2015-07-17 11:21:48 +01:00
Tom Wilkie 66e58937ca Make nameserver.checkAndPanic look for dups, call it more often. 2015-07-17 10:19:25 +00:00
Matthias Radestock 62c1cad676 Merge remote-tracking branch 'upstream/master' 2015-07-17 10:58:34 +01:00
Matthias Radestock ca523c716c cosmetic 2015-07-17 10:58:01 +01:00
Tom Wilkie e2deff09a6 Nameserver: log when peer goes away. 2015-07-17 09:36:44 +00:00
Ilya Dmitrichenko 19ddb65036 New screencast URL and image 2015-07-16 18:13:34 +01:00
Bryan Boreham 61c7c034e7 Re-arrange weaveexec Dockerfile to improve download times 2015-07-16 17:02:00 +01:00
Bryan Boreham 4c5920a50a Add fuzz-test for Claim 2015-07-16 16:12:23 +01:00
Bryan Boreham c3c40b15f1 Avoid hanging the caller when we try to claim from a dead peer 2015-07-16 16:12:23 +01:00
Bryan Boreham 2fa65f0a22 Smoke-test for claim operation 2015-07-16 16:12:23 +01:00
Bryan Boreham af7ca99dc4 Extend unit-tests for claim operation 2015-07-16 16:12:23 +01:00
Bryan Boreham 2d224d423d Add SpaceRequestDenied message 2015-07-16 16:12:23 +01:00
Bryan Boreham e7088e5daf Extract decodeRange function 2015-07-16 16:12:23 +01:00
Bryan Boreham d65409e97e Improve comment & log for deferred claim 2015-07-16 16:12:23 +01:00
Matthias Radestock 70110e483c Merge pull request #1166 from weaveworks/dns-tests
Make 210_dns_cross_hosts_test.sh excercise gossip dns tombstones.
2015-07-16 16:11:58 +01:00
Paul Bellamy a0876becbc Merge remote-tracking branch 'upstream/1.0'
Conflicts:
	proxy/create_container_interceptor.go
	proxy/create_exec_interceptor.go
	proxy/proxy.go
	proxy/start_container_interceptor.go
2015-07-16 15:29:29 +01:00
Paul Bellamy 1afdac4d2c Merge pull request #1167 from weaveworks/1157-proxy-net-host
[proxy] do not weave attach containers in '--net=host|container:<name|id>'
2015-07-16 15:24:37 +01:00
Paul Bellamy c6fa9cb17e refactor weaveCIDRsFromConfig to return an error message 2015-07-16 15:15:32 +01:00
Matthias Radestock aa3f35e38c remove stale reference to weave launch-dns 2015-07-16 14:41:57 +01:00
Tom Wilkie db77570779 Test is too long 2015-07-16 13:40:39 +00:00
Paul Bellamy 9619a27f8c [proxy] adding log message for ignored containers 2015-07-16 14:01:22 +01:00
Paul Bellamy c13154eea9 updating comment as per golint 2015-07-16 13:58:30 +01:00
Paul Bellamy 1132d26d47 [proxy] do not weave attach containers in '--net=host|container:<name|id>' 2015-07-16 13:58:27 +01:00
Tom Wilkie 6e5995964d Make 210_dns_cross_hosts_test.sh excercise gossip dns tombstones.
Also, make gce.sh less verbose, and do the env dance correctly.
2015-07-16 12:48:00 +00:00
Adam Harrison da13238368 Merge branch '1.0' 2015-07-16 13:45:36 +01:00
Paul Bellamy 0865f4c207 Merge pull request #1099 from weaveworks/1055-proxy-autoconfig
Proxy autoconfig
2015-07-16 13:33:21 +01:00
Adam Harrison 77bc56751b Merge pull request #1164 from weaveworks/1162_detect_host_netns_in_container
fix detection of host netns when weave script runs inside container
2015-07-16 13:33:19 +01:00
Matthias Radestock b32c017f33 fix detection of host netns when weave script runs inside container
$$ refers to the pid in the container's process namespace, so using it
as a reference into /hostproc is entirely wrong.

Fixes #1162.
2015-07-16 13:19:56 +01:00
Paul Bellamy a4a31e632b [proxy] Choose where to listen based on how launching client connected 2015-07-16 12:44:39 +01:00
Matthias Radestock 23ad547db4 Merge pull request #1155 from weaveworks/dns-gossip
Make DNS gossip converge correctly

Fixes #1151
2015-07-15 20:37:43 +01:00
Matthias Radestock 4d887c8a55 Merge branch '1.0'
Conflicts:
	proxy/create_exec_interceptor.go
	test/610_proxy_wait_for_weave_test.sh
2015-07-15 18:07:11 +01:00
Matthias Radestock a982146cbe Merge pull request #1153 from weaveworks/1143-non-weave-exec
[proxy] should not attempt weavewait in on weave container's execs

Fixes #1143.
2015-07-15 17:40:13 +01:00
Tom Wilkie 73210b6a70 Make sure DNS Gossip converges correctly.
- Abide by gossip interface (return nil, not empty gossip) so gossip converges!
- Make sure we don't say an old entry version is new to us; add some more tests.
- Add dns test for 3 (or N) hosts
- Extend mock gossip router to ensure reconsumption off diffs yield nil
- Don't increment version when re-adding existing entry.
2015-07-15 15:54:52 +00:00
Paul Bellamy e4422205e8 [proxy] should not attempt weavewait in on weave container's execs 2015-07-15 16:14:14 +01:00
Tom Wilkie 9df7358ded Add pprof handler to weaver. 2015-07-15 15:10:22 +00:00
Matthias Radestock 9507ea93dd rename test since we have two 250_* 2015-07-15 14:46:51 +01:00
Matthias Radestock 52d3bcfe8b Merge pull request #1149 from weaveworks/1118-respond-late-paxos
Respond to paxos messages when we already have a ring

Fixes #1118.
2015-07-15 13:24:40 +01:00
Bryan Boreham b3979c9505 Respond to paxos message if we already have a ring 2015-07-15 13:05:25 +01:00
Bryan Boreham 273a0fba47 Add sender to mock broadcast messages 2015-07-15 13:05:25 +01:00
Alvaro 7e34ec61f6 Merge pull request #1142 from weaveworks/1113-recursive-dns
Closes #1113
2015-07-15 13:42:59 +02:00
Bryan Boreham acf13dc157 Add sender to OnGossipBroadcast() 2015-07-15 12:07:56 +01:00
Tom Wilkie 91395d6728 Use Msg.Copy! 2015-07-15 11:05:36 +00:00
Paul Bellamy ef4a227ae9 Merge pull request #1144 from weaveworks/restart-docker-after-vagrant-tweaks
Restart docker after vagrant tweaking and refactor tweak-code
2015-07-15 11:34:59 +01:00
Alfonso Acosta 25589562cd Restart docker after vagrant tweaking and refactor tweak-code
Docker needs to be restarted and not started, since it already starts running after installation
2015-07-15 09:31:47 +00:00
Matthias Radestock 7063ca51aa remove dead code 2015-07-15 05:35:05 +01:00
Matthias Radestock 97498d26f7 remove dead code 2015-07-15 05:32:35 +01:00
Matthias Radestock 36292216fd rename tests so they actually run
These tests were introduced in #1065 and #1126.
2015-07-14 19:47:15 +01:00
Matthias Radestock 86448a1025 fix breakage
This wasn't spotted because #1065, which removed launch-dns, got
merged just before #1126, which introduced this test.
2015-07-14 19:42:59 +01:00
Ilya Dmitrichenko b4f53edd91 Merge pull request #1138 from weaveworks/vagrantfile-update
update default vagrant box to ubuntu 15
2015-07-14 18:21:02 +01:00
Matthias Radestock 3a22d2e6a1 Merge pull request #1135 from weaveworks/issues/1028-weave-dns-lookup
Implement `weave dns-lookup`

Closes #1028.
2015-07-14 18:19:26 +01:00
Matthias Radestock 9a4bbb55da Merge branch '1.0'
Conflicts:
	proxy/common.go
	weave
2015-07-14 18:09:25 +01:00
Matthias Radestock b476bd2afe Merge pull request #1137 from weaveworks/1109-docker-bridge-ip
[proxy] respect custom DOCKER_BRIDGE

Fixes #1109.
2015-07-14 17:52:08 +01:00
Tom Wilkie fa73240812 Copy dns requests and give them a fresh id when doing recursive queries. 2015-07-14 16:44:21 +00:00
Adam Harrison a3dc2d0482 Smoketest dns-lookup 2015-07-14 17:36:30 +01:00
Adam Harrison 41834478d7 Rework documentation to use weave dns-lookup 2015-07-14 17:36:30 +01:00
Adam Harrison 6832ae20b0 Implement weave dns-lookup 2015-07-14 17:36:30 +01:00
Matthias Radestock 7ae06ef00d Merge pull request #1126 from weaveworks/issues/1018-more-flexible-hostname-derivation
[proxy] More flexible container name -> hostname derivation

Closes #1018.
2015-07-14 17:31:53 +01:00
Alvaro a1ac0313e5 Merge pull request #1065 from weaveworks/gossipdns
Gossip-based DNS embedded in the router.
2015-07-14 18:30:16 +02:00
Paul Bellamy d9c5d2f940 update default vagrant box to ubuntu 15 2015-07-14 17:08:26 +01:00
Tom Wilkie 361ed1b4a6 Resolve unqualified domains in the weave.local domain. 2015-07-14 16:05:41 +00:00
Alfonso Acosta dfcc9678f3 Make weave usage fit into 80 columns 2015-07-14 16:02:19 +00:00
Tom Wilkie 8b061fd555 Gossip-based DNS embedded in the router.
- Nameserver holds a sorted list of (hostname, peer, container id, ip) tuples.
- Entries are gossiped using topology gossip / broadcast - only new/updated entries
  are propogated as expected.
- Entries for a given peer are removed when the connection to the peer is lost.
- Entries are tombstoned when containers die.  Tombstones are kept for 10mins,
  as they do not need to survive partition, only gossip propagation delay.
2015-07-14 16:00:38 +00:00
Tom Wilkie 01f7201a9e Remove legacy WeaveDNS code. 2015-07-14 16:00:28 +00:00
Paul Bellamy acd8bdec21 [proxy] respect custom DOCKER_BRIDGE 2015-07-14 16:33:35 +01:00
Alfonso Acosta ded3d6b40b Address PR comments 2015-07-14 15:31:44 +00:00
Tom Wilkie f7739ef04c Don't fail if docker rmi fails 2015-07-14 14:50:39 +00:00
Alfonso Acosta 4f82dc97fd [proxy] More flexible container name -> hostname derivation
Provides to new two new flags: `--hostname-match <regexp>`
and `--hostname-replacement <replacement>`. When launching a container, its name
matched against regular expression `<regexp>`. Then, based on that match,
`<replacement>` will be used to generate a hostname, which will ultimately be
handed over to weaveDNS for registration.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide `--hostname-match '^aws-[0-9]+-(.*)$'` and
`--hostname-replacement 'my-app-$1'`, running a container named
`aws-12798186823-foo` through WeaveProxy will lead to WeaveDNS registering
`my-app-foo`.

Closes #1018
2015-07-14 14:41:44 +00:00
Matthias Radestock 16471d0a28 Merge branch '1.0'
Conflicts:
	site/features.md
	test/110_encryption_test.sh
2015-07-14 15:41:10 +01:00
Matthias Radestock 6386c1bd18 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-14 15:36:55 +01:00
Matthias Radestock 2e93a4c18e Merge pull request #1132 from weaveworks/issues/945-secure-router-config
Improvements to password handling recommendations

Closes #945.
2015-07-14 15:31:20 +01:00
Matthias Radestock 0abd134a0d Merge pull request #1133 from weaveworks/revert-1050-issues/987
Revert "Resolve unqualified names in the local WeaveDNS domain"
2015-07-14 15:06:19 +01:00
Matthias Radestock 18032015b9 Revert "Resolve unqualified names in the local WeaveDNS domain" 2015-07-14 16:06:05 +01:00
Adam Harrison e26e7e29f2 Improvements to password handling recommendations 2015-07-14 14:48:58 +01:00
Matthias Radestock 39a1f2163f Merge pull request #1050 from weaveworks/issues/987
Resolve unqualified names in the local WeaveDNS domain

Closes #987.
2015-07-14 14:43:29 +01:00
Alvaro Saurin 4c519fc761 Smoke tests 2015-07-14 15:12:40 +02:00
Matthias Radestock bbacaa42b8 cosmetic 2015-07-14 13:23:28 +01:00
Matthias Radestock 2f35ad1d42 Merge pull request #1098 from dpw/encrypt-features
New connection protocol version with encrypted features map

Closes #1029. Closes #912.
2015-07-14 13:20:18 +01:00
Bryan Boreham 6d17fe5df5 Need to restart docker after systemd reconfigure 2015-07-14 12:12:35 +01:00
Bryan Boreham 907de67a40 Merge pull request #1125 from weaveworks/smoke-overlay
Upgrade smoke-tests to use 'overlay' storage and Ubuntu 15.04
2015-07-14 11:51:53 +01:00
Tom Wilkie 499d65e715 Build cover tool by default, and do go get -t for tests, irregardless of $SLOW 2015-07-14 10:50:34 +00:00
Alvaro Saurin efb0ead9ad Resolve unqualified names in the local WeaveDNS domain
Unit tests
2015-07-14 10:46:41 +02:00
Matthias Radestock 85b4a05c9a Merge branch '1.0' 2015-07-13 19:07:47 +01:00
Matthias Radestock 1f3d054b09 Merge pull request #1124 from weaveworks/issues/1037-mitigate-entropy-depletion
Mitigate entropy depletion

Closes #1037.
2015-07-13 19:06:54 +01:00
Bryan Boreham 4853a1da05 Tell Docker to use 'overlay' storage driver 2015-07-13 18:28:29 +01:00
Bryan Boreham db8016112e Upgrade to Ubuntu 15.04 2015-07-13 18:28:11 +01:00
Tom Wilkie 4eb6d147b5 Merge pull request #1121 from weaveworks/test_large_packets
test that large packets can be transmitted over weave
2015-07-13 17:06:28 +01:00
Adam Harrison e2f8b6f9fd Document /dev/random blocking issue 2015-07-13 15:02:31 +01:00
Adam Harrison f3c4a9fc6d Limit router accept rate with token bucket 2015-07-13 15:02:31 +01:00
Adam Harrison 9634526a67 Add token bucket implementation 2015-07-13 15:01:04 +01:00
Adam Harrison b67c102fe5 Remove simple sleep from router accept 2015-07-13 15:01:04 +01:00
Tom Wilkie 1e39b2bdcf Merge pull request #1123 from weaveworks/remove-danglies
Remove Docker dangling images in smoke-tests
2015-07-13 14:38:04 +01:00
Adam Harrison d6443809bd Merge pull request #1120 from weaveworks/998-race
Various improvements to unit test running
2015-07-13 14:09:45 +01:00
Bryan Boreham 80e56d67db Remove Docker dangling images after copying new ones 2015-07-13 14:03:47 +01:00
Tom Wilkie 24a4d6501e Merge pull request #1117 from weaveworks/multi_hop_tests
Multi hop tests
2015-07-13 11:39:06 +01:00
Bryan Boreham 5e43f0fd4c Merge pull request #1079 from weaveworks/68-rewrite-etc-hosts
LGTM.  Closes #68, with remainder to #1122
2015-07-13 11:03:20 +01:00
Tom Wilkie 13f1239a3e Various improvements to unit test running
- units.sh should exit on error.
- Add race detector to unit test runner.
- Use local testing/cover/cover tool in gen_coverage_report.sh and units.sh
- Use the scheduler to parallelise the unit tests.
- Make test run id a string and differentiate between unit runs and integration runs in the scheduler.
- Pipe circle env vars through to build container so we can detect when to use the scheduler
- Add python requests to the weave build container.
- Quote test names in urls, make flask handle url segments with slashes in.
2015-07-13 09:33:52 +00:00
Matthias Radestock 9463ceb873 test that large packets can be transmitted over weave 2015-07-13 10:31:20 +01:00
Matthias Radestock 7aab5cc5b4 refactor: simplify NewPeers 2015-07-11 17:46:57 +01:00
Matthias Radestock 2b61bc91df cosmetic: remove blank log lines 2015-07-11 16:43:33 +01:00
Matthias Radestock 57a4371e9f attempt to cure spurious test failures 2015-07-11 16:31:16 +01:00
Matthias Radestock 1d2e6b4c56 test gossip forwarding 2015-07-11 16:17:36 +01:00
Matthias Radestock 2a0bc91f86 add test for peer discovery and multi-hop routing 2015-07-11 14:57:24 +01:00
Matthias Radestock 210b926064 increase number of test VMs from 2 to 3 2015-07-11 14:57:24 +01:00
Matthias Radestock 9a089a111f don't invoke weave stop-router at end of tests
since that removes the container, rather than just stopping it.
2015-07-11 14:56:11 +01:00
Matthias Radestock 710eabeff3 reduce test vm memory 2015-07-11 12:15:46 +01:00
Matthias Radestock 603f34e944 oops, forgot to commit this 2015-07-11 12:14:43 +01:00
Matthias Radestock a3dff7e1e9 cope with more than two test hosts 2015-07-11 11:59:34 +01:00
Matthias Radestock 25486f7b4d cosmetic: s/weave_stop_router/stop_router_on
Also run `weave stop-router` as part of this, so conntrack cleanup
happens.
2015-07-11 11:58:29 +01:00
Matthias Radestock c22d824db8 .gitignore and clean up coverage reports 2015-07-11 11:57:01 +01:00
Matthias Radestock a44a3a4158 cure "./gen_coverage_reports.sh: line 5: CIRCLECI: unbound variable" 2015-07-11 11:46:49 +01:00
Matthias Radestock 982c9d7650 remove dead code 2015-07-11 11:17:44 +01:00
Matthias Radestock 7042c1506a cosmetic: consistency with other tests 2015-07-11 03:36:21 +01:00
Matthias Radestock 76943f0b17 cosmetic 2015-07-11 02:52:30 +01:00
Matthias Radestock c4f516655d refactor: simplify ipam claim try 2015-07-11 02:28:14 +01:00
Matthias Radestock aaba681db1 remove dead code 2015-07-11 01:54:37 +01:00
Tom Wilkie 56a169b50f Merge pull request #1115 from weaveworks/unit-coverage
Run unit tests in circle and include their coverage in the report.
2015-07-10 19:34:48 +01:00
Tom Wilkie 32b2ec4038 Run unit tests in circle and include their coverage in the report. Report coveralls.io from Circle. 2015-07-10 18:19:50 +00:00
Matthias Radestock ce5052305d fix CircleCI breakage 2015-07-10 18:44:30 +01:00
Matthias Radestock 0e94e3e07b complain even less about absent weave container in coverage collection 2015-07-10 18:30:13 +01:00
Matthias Radestock 3d72670105 don't complain in coverage collection when weave container is absent 2015-07-10 18:24:19 +01:00
Tom Wilkie f8718dcc5d Remove duplication of coverage stanza in weave script. 2015-07-10 16:35:46 +00:00
Paul Bellamy fa6777004f Review feedback 2015-07-10 17:34:06 +01:00
Paul Bellamy e3212d462d Merge pull request #1105 from weaveworks/673-smoke-test-coverage
Code coverage for smoke tests.
2015-07-10 16:53:59 +01:00
Tom Wilkie f5186e74c0 Review feedback 2015-07-10 15:33:00 +00:00
Tom Wilkie bf814739ba Reduce repetition in Makefile. 2015-07-10 15:03:54 +00:00
Tom Wilkie 00a7490a1d Code coverage for smoke tests.
Allow non-circle people to build coverage reports.
2015-07-10 14:45:14 +00:00
Adam Harrison da41604229 Fix IPAM test compilation 2015-07-10 15:43:28 +01:00
Adam Harrison d5a4326b9e Merge branch '1.0'
Conflicts:
	ipam/allocator_test.go
	ipam/claim.go
2015-07-10 14:35:41 +01:00
Adam Harrison 835d99e6fe Merge pull request #1104 from weaveworks/1083-async-claim
Don't wait to claim addresses from IPAM
2015-07-10 14:03:05 +01:00
Paul Bellamy e4458372e8 [proxy] weavewait rewrites /etc/hosts so weave ip is returned first from 'hostname -i'
Adds a --no-rewrite-hosts flag to the proxy, and be default, removes the
docker IP from hosts. We only discard the docker host when it exists, so
--net=none works.
2015-07-10 13:57:20 +01:00
Matthias Radestock a05c65c73b simplify feature extraction 2015-07-09 14:38:08 +01:00
David Wragg 14d346db8b Add a --protocol-min-version option to router
To allow users to forgo compatibility with Weave Net 1.0 in order to
avoid #912, by setting --protocol-min-version=2.
Defaults to --protocol-min-version=1, i.e. compatible but vulnerable.
2015-07-09 14:38:06 +01:00
David Wragg 882f14d50c Version 2 protocol, which encrypts the features map
With V1 compatibility
2015-07-09 14:37:42 +01:00
Bryan Boreham 75646d4786 Merge remote-tracking branch 'origin/1.0'
Conflicts:
	router/connection.go
2015-07-09 12:56:37 +01:00
Bryan Boreham b93070f91a Fix log message on peer move 2015-07-09 12:51:52 +01:00
Bryan Boreham cbcd5da680 Fix log message on peer move 2015-07-09 12:33:39 +01:00
Bryan Boreham cf4ce0a07d Don't cancel address claim when caller closes socket 2015-07-09 10:47:34 +01:00
Bryan Boreham 78c4b06492 Don't wait for certainty before responding to Claim
Conflicts:
	ipam/claim.go
2015-07-09 10:47:27 +01:00
David Wragg 501f40d9c1 Consolidate remote peer checks 2015-07-08 17:21:32 +01:00
Matthias Radestock 08463ea403 Merge branch '1.0' 2015-07-08 16:54:24 +01:00
Matthias Radestock 2ced8b9469 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-08 16:53:13 +01:00
Matthias Radestock 26c1bcf866 clarify role of IP allocator range
Part of #1035.
2015-07-08 16:51:25 +01:00
Tom Wilkie 89ad7e1ba2 Move test gossip router out of ipam code for use in gossip dns code. 2015-07-08 15:03:13 +00:00
Matthias Radestock e6828e1aa5 Merge pull request #1101 from weaveworks/misc-changes
Extend router/peers.go to allow multiple OnGC callbacks
2015-07-08 16:00:22 +01:00
Tom Wilkie c8718d85dc Extend router/peers.go to allow multiple OnGC callbacks, and call the callbacks outside of the peers lock. 2015-07-08 14:47:02 +00:00
Tom Wilkie 56863c3d0e Ensure bin/lint doesn't complain about removed files when used as a git precommit script. 2015-07-08 14:43:21 +00:00
David Wragg e50b1f1fe7 Remove the "found" return value from Peers Fetch method
Callers can simply check whether the returned *Peer is nil.
2015-07-08 09:06:33 +01:00
David Wragg 5e10b901a3 Drop the check for duplicate connections in the handshake
Duplicate connections are also detected and handled in AddConnection,
I have not been able to reproduce #182 without the check, so although
it may once have been necessary, it doesn't seem to be needed now.
2015-07-08 09:03:51 +01:00
David Wragg a6a74001bd Make TCPReceiver more closely mirror TCPSender 2015-07-08 08:53:53 +01:00
Bryan Boreham 0b032386c1 Merge pull request #1092 from weaveworks/1082_usage_to_stderr
Note I have rebased this and merged changes.  Closes #1082.
2015-07-07 15:43:23 +01:00
Matthias Radestock 8eb092c754 display usage on stderr
so that the likes of $(weave proxy-typo-env) don't do weird things

Closes #1082.
2015-07-07 15:39:47 +01:00
Alvaro 33921c2cfe Merge pull request #1073 from weaveworks/971_check_container_alive_in_api
make container aliveness check part of the ipam & dns API
2015-07-07 16:08:40 +02:00
Matthias Radestock 6cc566fd3e Merge pull request #1090 from weaveworks/1076-ignore-iface
Don't complain about weave bridge routes clashing

Fixes #1076.
2015-07-07 13:12:41 +01:00
Matthias Radestock 491a4369d7 Merge pull request #1096 from squaremo/issue1087_password_equals
Handle --option=value as well as --option value

Closes #1087.
2015-07-07 12:57:01 +01:00
Bryan Boreham 6666fd14ac Allow multiple --ignore-iface arguments 2015-07-07 12:52:29 +01:00
Bryan Boreham e621aca77e Added --ignore-iface option to netcheck and use it to ignore weave bridge route 2015-07-07 12:52:29 +01:00
Adam Harrison 3e7c20b4ee Merge branch '1.0' 2015-07-07 12:46:00 +01:00
Michael Bridgen 22446ffc19 Handle --option=value as well as --option value
In any place we munge options, treat the form with an equals the same
as the form without.

The exes ultimately invoked by the script handle both forms, so unless
we need to do something with the option in the script, we can just let
options fall through.
2015-07-07 12:44:37 +01:00
Matthias Radestock f39791616d Merge pull request #1095 from weaveworks/move-ipam-address
Move ipam/address to net/address

Closes #1065.
2015-07-07 11:43:47 +01:00
Paul Bellamy d39aaa86ee Merge pull request #1084 from squaremo/issue602_moar_hyphens
Consistent option naming
2015-07-07 11:37:21 +01:00
Tom Wilkie 4fdb14293b Move ipam/address to net/address 2015-07-07 10:33:20 +00:00
Michael Bridgen 4ede33468e Update docs and smoke-tests with new option names 2015-07-07 11:26:09 +01:00
Michael Bridgen ebbb5d379d Usage and deprecation warnings in script
The usage is rearranged slightly to avoid wrapping at 80 characters.

This will tend to overestimate warnings, since it doesn't try very
hard to ignore values that are not intended to be options; in
particular, arguments that are intended for `docker run`. (Using `--`
to delimit these arguments would make this easier!)

It does ignore values that follow known options though, for instance
in

        weave -nickname "-password"

(-nickname results in a deprecation warning, -password does not)

and

        weave --password "-iprange"

(no deprecation warning, since -iprange is ignored)
2015-07-07 11:26:09 +01:00
Michael Bridgen 379b8c4e6b Standardise on options --like-this
Hyphenate words, and always expect double dashes for long options. A
small number of options have entirely new names.

In general I have added aliases for the unhyphenated and single-dashed
varieties, and used mflag's deprecation syntax to make it print a
warning when it sees them. I left some abbreviated options
unhyphenated (e.g., `bufsz`), and the TLS options as-is since they
correspond with Docker options.

NB the deprecation wanrings will mostly get printed to container logs,
since mostly the executables are run in containers. The next step is
to emit warnings from the script for the options mentioned in the
script usage message.
2015-07-07 11:13:30 +01:00
Adam Harrison bde445df9b Merge pull request #1089 from weaveworks/1086_dns_search_without_equals
detect `--dns-search <arg>`
2015-07-07 10:16:21 +01:00
Matthias Radestock 41b0c2a03f Merge pull request #1070 from weaveworks/1036-change-iprange
Change default IP allocation range from 10.128/10 to 10.32/12

Closes #1036.
2015-07-07 02:24:13 +01:00
Matthias Radestock 02715f88d5 cosmetic: re-order option parsing
to match the order in which we susequently process them.
2015-07-06 17:26:04 +01:00
Matthias Radestock 706f9ee352 detect --dns-search <arg>
...and not just `--dns-search=<arg>`

Fixes #1086.
2015-07-06 17:22:42 +01:00
Bryan Boreham 646cf84b4a Merge pull request #1072 from weaveworks/1043_common_launch_args
LGTM
2015-07-06 17:15:51 +01:00
Bryan Boreham f593c2fbf2 Change default IP allocation range from 10.128/10 to 10.32/12 2015-07-06 17:09:05 +01:00
Bryan Boreham bd24307c2b Merge pull request #1069 from 2opremio/fons/fix-tests-OSX
LGTM
2015-07-06 16:43:26 +01:00
Michael Bridgen e0c7054f9b Merge pull request #1075 from weaveworks/fons/test-vagrant-creation
Explain how to create the test VMs from vagrant
2015-07-06 16:31:22 +01:00
Michael Bridgen 59550e0fcb Merge branch 'pr1077' 2015-07-06 16:27:45 +01:00
Michael Bridgen af64c8e2af Merge branch '1063_status_json_accept_header' of github.com:weaveworks/weave into pr1077 2015-07-06 16:25:58 +01:00
Matthias Radestock 03ac7a86c6 make bin/multiweave work again in 'launch launches everything' world 2015-07-06 15:13:21 +01:00
Matthias Radestock 80a232f44c copy latest random_mac() from weave script to bin/multiweave 2015-07-06 15:09:23 +01:00
Matthias Radestock d1041c17d3 Merge pull request #1081 from weaveworks/weave_1.1_readme_updates_proxy_env
Remove weave proxy-(env|config) for just (env|config). Readme changes
2015-07-06 15:05:05 +01:00
Matthias Radestock cf7fff3da2 Merge pull request #1080 from weaveworks/1014-weave-env
rename proxy-(env|config) to (env|config)

Closes #1014.
2015-07-06 15:04:40 +01:00
Alfonso Acosta 373d663b5e Fix integration tests for OSX 2015-07-06 14:48:53 +01:00
Alfonso Acosta e86d255a47 Add comment about running integration tests from the Vagrant build VM 2015-07-06 14:07:16 +01:00
Paul Bellamy 5c44f74475 rename proxy-(env|config) to (env|config)
Keep error message to stderr, as the proxy should be launched with
'weave launch'. 'proxy-(env|config)' are kept with a deprecation
warning, for a while.
2015-07-06 13:41:23 +01:00
Paul Bellamy d649bdddc7 Remove weave proxy-(env|config) for just (env|config). Readme changes 2015-07-06 12:59:07 +01:00
Matthias Radestock 5c7763b075 Merge branch '1.0' 2015-07-06 11:00:15 +01:00
Matthias Radestock e3ab396428 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-06 10:59:34 +01:00
Matthias Radestock df31454c30 Merge commit 'c8032b6' into latest_release_doc_updates 2015-07-06 10:58:18 +01:00
Matthias Radestock c8bd47e948 set correct content-type header when returning json status 2015-07-05 19:25:28 +01:00
Matthias Radestock 098fc81825 output json status based on 'Accept' header
...instead if having a separate URL.

Closes #1063.
2015-07-05 19:19:02 +01:00
Alfonso Acosta cab4a7e1ee Explain how to create the test VMs from vagrant 2015-07-05 18:59:53 +01:00
Matthias Radestock 6596c8b1a7 make container aliveness check part of the ipam & dns API
...rather than conducting it implicitly when an ID "looks like" a
container ID.

Closes #971
2015-07-04 19:13:13 +01:00
Matthias Radestock 5559f1df2e cosmetic: remove some unnecessary quoting
for consistency, since we don't quote the same term anywhere else
2015-07-04 18:14:13 +01:00
Matthias Radestock 156597a965 small simplifying refactor: use shortcircuit boolean expressions 2015-07-04 18:04:25 +01:00
Matthias Radestock d0641062c0 pass common launch args to all three components
ATM that's just --loglevel=...

Closes #1043.
2015-07-04 04:38:18 +01:00
Matthias Radestock cf4fffa394 Merge pull request #1057 from weaveworks/329-log-level-choice
Give the user more choice of log levels

Closes #329
2015-07-04 03:46:59 +01:00
Matthias Radestock b30de63f18 Merge pull request #1067 from paulbellamy/proxy-stderr
print all stderr output from callWeave to the proxy logs, even if successful

Closes #1056
2015-07-04 03:44:50 +01:00
Bryan Boreham ff2d7451e2 Remove -debug option, superceded by --log-level 2015-07-04 03:27:07 +01:00
Matthias Radestock 910b57731d remove stray -debug in tests 2015-07-04 03:19:27 +01:00
Matthias Radestock b8aa1d473b remove dead code 2015-07-04 02:53:36 +01:00
Matthias Radestock ce26f88ee2 Merge branch '1.0'
Conflicts:
	router/crypto.go
	router/ethernet_decoder.go
	router/handshake_test.go
	router/mocks_test.go
	router/peers_test.go
	router/router.go
	router/udp_sender.go
2015-07-03 20:47:29 +01:00
Matthias Radestock bf73029d15 cosmetic: goimports -w . 2015-07-03 20:41:35 +01:00
Matthias Radestock 4dbd657a26 import gopacket from github instaead of google code
The latter redirects to the former, which breaks `go get`.

Closes #1071.
2015-07-03 20:32:27 +01:00
Matthias Radestock 1524796408 Merge pull request #1068 from weaveworks/1004-seed-random
Seed random-number generator from the host time

Fixes #1004.
2015-07-03 16:01:16 +01:00
Paul Bellamy 7821412bf7 [proxy] print all stderr from callWeave to the proxy logs, even if successful 2015-07-03 15:45:09 +01:00
Matthias Radestock b72b7a9ed5 Merge branch '1.0' 2015-07-03 14:28:42 +01:00
Matthias Radestock a3a7a19870 simplifying refactor 2015-07-03 14:28:18 +01:00
Matthias Radestock 8b0089565f Merge branch '1.0' 2015-07-03 14:18:46 +01:00
Matthias Radestock 251c68e85a Merge pull request #1064 from weaveworks/issues/1023-await-ipam-forever
Wait forever for IPAM

Fixes #1023.
2015-07-03 14:17:52 +01:00
Adam Harrison 227cb11f25 Router, DNS and proxy wait forever by default 2015-07-03 14:01:34 +01:00
Adam Harrison 6097dc8aaa Add wait forever capability to EnsureInterface 2015-07-03 14:01:34 +01:00
Bryan Boreham 8c6c692926 Seed the math/rand generator from the time 2015-07-03 13:39:47 +01:00
Matthias Radestock 7554bd3913 Merge branch 'master' into weave_1.1_readme_updates
Conflicts:
	README.md
2015-07-03 11:55:32 +01:00
Matthias Radestock b81fce32f6 one more s/proxy/Weave Docker API proxy 2015-07-03 11:51:12 +01:00
Matthias Radestock 3ea1448c52 cosmetic 2015-07-03 11:49:20 +01:00
Matthias Radestock f31a3c1261 Merge branch '1.0' 2015-07-03 11:48:07 +01:00
Matthias Radestock 9e32605183 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-03 11:45:37 +01:00
Matthias Radestock 9009e0eb7f one more s/proxy/Weave Docker API proxy 2015-07-03 11:45:05 +01:00
Matthias Radestock 243d445d1b Merge branch 'latest_release_doc_updates' into 1.0 2015-07-03 10:59:10 +01:00
Matthias Radestock 65cd2b0e04 missed one 2015-07-03 10:58:22 +01:00
Matthias Radestock 33b230c114 Merge branch 'latest_release_doc_updates' into 1.0 2015-07-03 10:56:00 +01:00
Matthias Radestock 6389af6ea2 Merge pull request #1066 from weaveworks/1019_rename_proxy_in_docs
introduce 'Proxy' as 'Docker API Proxy'

Closes #1066.
2015-07-03 10:55:17 +01:00
Matthias Radestock fcea6fcbf8 Merge branch '1.0' 2015-07-03 10:03:43 +01:00
Matthias Radestock 8b35f5e8fe fix typo in comment 2015-07-03 10:03:07 +01:00
Matthias Radestock 7d5dcfafc9 introduce 'Proxy' as 'Docker API Proxy'
in order to reduce potential confusion about its role.

Closes #1019.
2015-07-03 03:33:23 +01:00
Matthias Radestock 07ee2df822 cosmetic(ish): use dotted import. like everywhere else 2015-07-02 21:07:51 +01:00
Paul Bellamy 5b79e274e8 fixup logging changes, so it compiles 2015-07-02 17:04:21 +01:00
Matthias Radestock e25d1b8365 Merge branch '1.0' 2015-07-02 16:35:40 +01:00
Matthias Radestock af40ebcab4 Merge pull request #1062 from weaveworks/issues/1006-fix-hostname-derivation
Disable hostname derivation when container name is too long

Fixes #1006.
2015-07-02 16:34:40 +01:00
Paul Bellamy 3fd146557a Merge pull request #1060 from weaveworks/issues/1059-remove-google-code-refs
Remove all the imports from "code.google.com"
2015-07-02 15:59:57 +01:00
Adam Harrison d427c99161 Add smoke test 2015-07-02 14:29:38 +01:00
Adam Harrison d1a887857d Enforce maximum length on weave run hostname derivation 2015-07-02 14:29:38 +01:00
Adam Harrison 3914c4c018 Enforce maximum length on proxy hostname derivation 2015-07-02 14:29:34 +01:00
Alvaro Saurin f6ffd604dd Removed all the imports from "code.google.com" 2015-07-02 13:32:52 +02:00
Matthias Radestock 18a4c14670 clarify network/address route overlap error/warning message
Closes #1034.
2015-07-02 11:51:22 +01:00
Matthias Radestock 0f67dbd8bd Merge branch '1.0' 2015-07-02 11:48:22 +01:00
Matthias Radestock 3bd5ae56f0 fix make update
Trying to build the thing for which we want to fetch the dependencies
is rather silly.
2015-07-02 11:46:48 +01:00
Matthias Radestock ecfc5d091d Merge pull request #1053 from weaveworks/437-check-address
Check addresses supplied by users for conflict with existing routes.

Fixes #437. Fixes #480.
2015-07-01 15:03:28 +01:00
Bryan Boreham 84238a0262 Amend error message to reflect usage situation 2015-07-01 14:58:42 +01:00
Matthias Radestock edf3ec9f09 Merge pull request #1044 from weaveworks/664-use-logrus
Use off-the-shelf logger logrus

Closes #664.
2015-07-01 14:47:52 +01:00
Matthias Radestock 2fee0f0184 Merge branch '1.0' 2015-07-01 14:02:57 +01:00
Bryan Boreham a5ddb63fca Remove Info.Print in favour of Log.Info 2015-07-01 14:01:45 +01:00
Matthias Radestock a05a3c4b26 Merge pull request #1054 from weaveworks/1042-reset-first-10
Call `weave reset` earlier in smoke-test set-up, to improve reliability

Fixes #1042.
2015-07-01 14:01:29 +01:00
Bryan Boreham a938608cc8 Call weave reset before deleting containers, to improve clean-down 2015-07-01 13:19:43 +01:00
Bryan Boreham 013380c7e7 Update router code to use common logger 2015-07-01 12:26:23 +01:00
Bryan Boreham 13c0b62f96 When looking at proxy logs, use both stderr and stdout 2015-07-01 12:26:23 +01:00
Bryan Boreham 7276fc1d4b Wire up selection of logging levels to match old behaviour
- note that all output is now going to stderr.
2015-07-01 12:26:23 +01:00
Bryan Boreham 67a6961b4b Adjust logrus feature of padding all lines less than 44 chars with spaces at the end 2015-07-01 12:26:23 +01:00
Bryan Boreham d82578d895 Replace logging calls with new style 2015-07-01 12:26:23 +01:00
Bryan Boreham c786e7eb5a Switch from basic logger to logrus 2015-07-01 12:26:23 +01:00
Bryan Boreham 91099694c9 Send error message to stderr 2015-07-01 12:17:02 +01:00
Bryan Boreham c9a20ae10c Warn user if they are trying to use a specific address that clashes with an existing route 2015-07-01 12:17:02 +01:00
Bryan Boreham f05225da22 Check specific addresses differently to networks
For a network, as used by IPAM, we care if *any* address in the range
could possibly conflict with an existing address routed by the host.
When given a single address, we only care if *that specific address*
conflicts with an existing route.
2015-07-01 12:15:04 +01:00
Matthias Radestock badfdee5e4 Merge branch '1.0' 2015-07-01 11:34:50 +01:00
Matthias Radestock ba1e75405f Merge branch 'latest_release_doc_updates' into 1.0 2015-07-01 11:34:24 +01:00
Matthias Radestock 0f5f671054 Merge pull request #1051 from weaveworks/issues/1046-clarify-weavedns-docs
Draw attention to --hostname precedence

Fixes #1046.
2015-07-01 11:33:24 +01:00
Adam Harrison 5b9d350002 Draw attention to --hostname precedence 2015-07-01 11:15:08 +01:00
Bryan Boreham 6403e7a11c Add missing rule to rebuild netcheck when its source changes 2015-07-01 11:13:40 +01:00
Matthias Radestock 312122e1be fix typo 2015-07-01 10:30:12 +01:00
Matthias Radestock bb1da63bfc Merge pull request #1048 from squaremo/issue1040_eliminate_ipam_mentions
Remove references to 'IPAM' in docs and UI

Closes #1040.
2015-06-29 23:15:58 +01:00
Matthias Radestock d1b2e74985 Merge pull request #1045 from squaremo/issue1041_usage_for_initpeercount
Add -initpeercount to usage

Closes #1041.
2015-06-29 19:48:52 +01:00
Michael Bridgen c0b2fe3e3b Remove references to 'IPAM' in docs and UI
The option `--no-default-ipam` is replaced with
`--no-default-ipalloc`; the former will still work (in a 'last one
wins' way), but its usage message says it's deprecated.
2015-06-29 19:20:26 +01:00
Michael Bridgen 864461918f Add -initpeercount to usage 2015-06-29 17:06:14 +01:00
Matthias Radestock 9127eb8acf cosmetic: make weave run usage fit in 80 columns 2015-06-29 16:56:57 +01:00
Paul Bellamy 8e629d9471 Merge pull request #999 from paulbellamy/scope-tests
Let Scope use these integration test helpers
2015-06-29 13:51:26 +01:00
Matthias Radestock ab943d938a refactor: don't return encoder from handshake()
We did this for symmetry/completeness, but the encoder is actually
"consumed" by handshake() in the creation of the tcp senders, hence it
is in fact dangerous to return it.
2015-06-29 12:38:21 +01:00
David Wragg d6fedc1e6e Remove error return value from DecodeLayers
It is never checked, so add a comment explaining why.
2015-06-29 10:47:56 +01:00
David Wragg 3222478449 Remove the LogFrame when fragmenting
Subsequent commits make this LogFrame call a little tricky to retain,
and it's not clear that it is really needed.
2015-06-29 10:47:26 +01:00
Paul Bellamy 26cb65c357 making test helpers more robust so scope can use them 2015-06-29 10:22:10 +01:00
Paul Bellamy 1ef3bd3a8b add docker version and weave version to test sanity checks 2015-06-29 10:20:55 +01:00
Matthias Radestock 51ecf05091 cosmetic: fix typo in comment 2015-06-27 09:35:14 +01:00
Bryan Boreham 565454d3cb fixed Logf format specifier 2015-06-26 17:22:35 +01:00
Matthias Radestock 906ff210fe Merge pull request #1026 from weaveworks/1003-proxy-unix-socket
Make proxy listen on unix:///var/run/weave.sock

Closes #1003
2015-06-26 16:44:41 +01:00
Tom Wilkie c4565f6ed3 Make proxy listen on /var/run/weave.sock 2015-06-26 15:08:21 +00:00
Matthias Radestock 8dd9020803 Merge branch '1.0'
Conflicts:
	ipam/allocator_test.go
2015-06-26 14:08:09 +01:00
Matthias Radestock ec62029db5 Merge pull request #1024 from weaveworks/982-fix-mock-gossip3
Flush messages from mock gossip in IPAM test

Fixes #982.
2015-06-26 13:44:57 +01:00
Matthias Radestock 55fbffef75 Merge pull request #1009 from awh/weave_launch_all_the_things
Weave launch all the things

Closes #962.
2015-06-26 13:21:44 +01:00
Bryan Boreham c84c5dbcdf Make TestGossipRouter goroutine easier to follow 2015-06-26 11:53:14 +01:00
Bryan Boreham 6725c8355f Check the result of Allocate in TestFakeRouterSimple() 2015-06-26 11:53:03 +01:00
Bryan Boreham c659e3448a Add a flush() function to the mock gossip router, and call it where required 2015-06-26 11:40:58 +01:00
Bryan Boreham 959e5f0082 Use different object types for mock gossip messages 2015-06-26 11:38:25 +01:00
Bryan Boreham 6488b0d11c More idiomatic exitChan 2015-06-26 11:38:07 +01:00
Matthias Radestock 039a2030db refactor: make DF flag passing logic more obvious
...and provide a better abstraction for sending special frames.
2015-06-26 11:11:17 +01:00
Matthias Radestock 33d85aaee5 Merge pull request #1016 from dpw/defer-df
Don't inspect the DF flag earlier than we need to
2015-06-26 11:10:42 +01:00
Adam Harrison d4c1766532 Fix smoke tests 2015-06-26 11:10:08 +01:00
Matthias Radestock 39a6d1c87e refactor: simplify a test 2015-06-25 20:13:03 +01:00
Matthias Radestock ee2a66323e Merge branch '1.0'
Conflicts:
	ipam/ring/ring_test.go
2015-06-25 19:57:09 +01:00
Matthias Radestock 635a3e5b26 cosmetic: remove attempt at pretty shell fragment
there is just no way to format this so it looks good everywhere, due
to different tab widths.
2015-06-25 19:51:39 +01:00
Matthias Radestock 82da45a638 go get test dependencies
The previous 'fix' wasn't working since it `go get -t`'ed the dirs
where our executables live. Which don't contain any tests.
2015-06-25 19:31:38 +01:00
David Wragg 64ac7745fe Don't inspect the DF flag earlier than we need to 2015-06-25 17:11:52 +01:00
David Wragg 5690902173 Move DF indication into LogFrame 2015-06-25 17:11:20 +01:00
David Wragg 4162dcafd3 Make the full EthernetDecoder available to LogFrame
So that LogFrame can include information about the decoded frame beyond
the ethernet layer.
2015-06-25 17:11:20 +01:00
Matthias Radestock 9253d45968 Merge pull request #1010 from bboreham/896-check-gossip
Try other peers for space if we get errors

Fixes #896
2015-06-25 17:05:40 +01:00
Matthias Radestock ea59c6c065 Merge pull request #1015 from weaveworks/go-get-tests
Extend 'go get' to tests
2015-06-25 17:01:26 +01:00
Bryan Boreham 7c741d6f7e Extend 'go get' to tests
The `-t` flag asks Go to fetch anything required for tests, which is more necessary now we have added testify.
2015-06-25 16:42:53 +01:00
Adam Harrison 99dc70ea7a Eliminate references to proxy and weaveDNS 2015-06-25 15:42:06 +01:00
Bryan Boreham 8a4b0d536e Updated after review feedback 2015-06-25 15:41:06 +01:00
Adam Harrison b78d4f05d0 Use new weave launch command introduced by #962 2015-06-25 14:59:43 +01:00
Bryan Boreham c76f640e2e Simpler implementation of weighted-random order 2015-06-25 14:54:44 +01:00
Adam Harrison a9e3320e7c Update documentation 2015-06-25 14:43:29 +01:00
Bryan Boreham b472da18f0 Improve logging of unicast gossip errors 2015-06-25 14:04:37 +01:00
Bryan Boreham c58cc449c0 More complex ChoosePeersToAskForSpace, with better complexity 2015-06-25 13:19:49 +01:00
Bryan Boreham af9668f130 Keep trying peers to ask for space until we find one that doesn't error 2015-06-25 12:47:38 +01:00
Adam Harrison 08f3d5b8e8 Implement new weave stop behaviour 2015-06-25 12:47:18 +01:00
Adam Harrison 0d5aad3e90 Rename stop to stop-router 2015-06-25 12:47:18 +01:00
Adam Harrison fcd79a78af Implement new weave launch behaviour 2015-06-25 12:47:14 +01:00
Bryan Boreham 9f784b3c31 Report errors in unicasting gossip 2015-06-25 12:22:53 +01:00
Matthias Radestock 657bbbffbc tiny refactor: raise abstraction level 2015-06-24 18:17:15 +01:00
Tom Wilkie 7780ac1078 Fix gce.sh destory timeouts. 2015-06-24 17:13:37 +00:00
Matthias Radestock 76a12edf57 Merge pull request #997 from dpw/eliminate-starts
Eliminate most Start methods in router package
2015-06-24 18:04:57 +01:00
David Wragg 7387caa2eb Eliminate forwarder Start methods 2015-06-24 17:37:07 +01:00
David Wragg 576dd69b0b Add a comment to Router's Start method 2015-06-24 17:37:02 +01:00
David Wragg 5e6b107d01 Eliminate the GossipSender Start method 2015-06-24 17:35:26 +01:00
David Wragg f444ae9224 Eliminate ConnectionMaker Start method 2015-06-24 17:35:26 +01:00
David Wragg 8f5d1eec11 Eliminate the Routes Start method 2015-06-24 17:35:17 +01:00
Matthias Radestock 9a6afcd236 Merge branch '1.0' 2015-06-24 17:26:19 +01:00
Matthias Radestock 5f95de19ce Merge branch 'latest_release_doc_updates' into 1.0 2015-06-24 17:25:51 +01:00
Fintan Ryan 8fb00ff206 Merge pull request #1002 from weaveworks/include-css
Include stylesheet in repo, update footer
2015-06-24 17:09:53 +01:00
Matthias Radestock 94a8338be5 fix typo in comment 2015-06-24 17:02:35 +01:00
David Kaltschmidt 00744fb9b4 use relative paths for stylesheet in docs 2015-06-24 17:54:50 +02:00
David Kaltschmidt 8250e05618 include stylesheet in repo, update footer
need because website's custom.css is fingerprinted
2015-06-24 17:18:54 +02:00
David Wragg 12c17d39cc Merge weaveworks/separate_image_build_and_export (PR #994)
separate the image build and export phases
2015-06-24 15:26:11 +01:00
Adam Harrison 409961fff3 Rename launch to launch-router 2015-06-24 14:30:35 +01:00
David Wragg 159d47a934 Merge rade/992_fractional_sleep (PR #993)
Sleep for 0.1s instead of 1s in the wait_for_status loop.

Closes #992.
2015-06-24 12:44:52 +01:00
Matthias Radestock 4b11874390 sleep for 0.1s instead of 1s in the wait_for_status loop
This reduces `weave launch|launch-dns` execution time.

Closes #992.
2015-06-24 12:16:52 +01:00
Matthias Radestock 3c7cff1c9c Merge pull request #996 from weaveworks/rm_dockercon_pointer
Remove Link to Dockercon from README
2015-06-24 10:47:00 +01:00
Fintan Ryan e3574f243f Remove Link to Dockercon from README 2015-06-24 10:35:12 +01:00
Matthias Radestock bdda9d03ae bump docker version in weave-build docker image
to 1.3.1, the same version we use everywhere else, e.g. in weavexec.
2015-06-24 03:24:58 +01:00
Matthias Radestock ae1805de76 separate the image build and export phases
That way the export can be just a single tar, which is more
convenient. And without introducing unnecessary image builds.
2015-06-24 02:54:45 +01:00
Matthias Radestock 0ce123e63a Merge branch '1.0' 2015-06-24 02:53:06 +01:00
Matthias Radestock 9ae45f6674 Merge branch 'latest_release_doc_updates' into 1.0 2015-06-24 02:52:37 +01:00
Matthias Radestock 6c3aa99595 bump min required docker version for build
to the same version we use everywhere else, e.g. in weaveexec
2015-06-24 02:51:24 +01:00
Matthias Radestock 215d96fdc3 Merge branch '1.0' 2015-06-23 23:18:09 +01:00
Matthias Radestock 2c73fd6dde Merge branch 'latest_release_doc_updates' into 1.0 2015-06-23 23:17:38 +01:00
Matthias Radestock 3b27413887 fix broken link 2015-06-23 23:17:05 +01:00
Matthias Radestock eb9e450cf1 cosmetic 2015-06-23 19:10:10 +01:00
David Wragg 72039bbe5a Eliminate the LocalPeer Start method 2015-06-23 16:08:43 +01:00
David Wragg d6bceb139e Eliminate MacCache Start method 2015-06-23 16:08:43 +01:00
David Wragg a311623bb9 Eliminate the Start method on LocalConnection 2015-06-23 16:08:43 +01:00
Paul Bellamy 95d72a57e8 Merge pull request #989 from rade/prefetch_test_images
prefetch test images
2015-06-23 15:14:59 +01:00
Adam Harrison aa8d9eab53 Merge branch '1.0' 2015-06-23 15:05:32 +01:00
Adam Harrison 17ee829299 Merge branch 'latest_release_doc_updates' into 1.0 2015-06-23 15:05:02 +01:00
Adam Harrison 5db39466e8 Fix broken IPAM link 2015-06-23 15:04:37 +01:00
Matthias Radestock 43b8840dd2 Merge branch '1.0' 2015-06-23 14:58:55 +01:00
Matthias Radestock cc4ab80f62 Merge branch 'latest_release_doc_updates' into 1.0 2015-06-23 14:57:51 +01:00
Matthias Radestock 0e47cee661 remove references to dns, ipam and proxy docs from ToCs
Since they are now explained and referenced prominently from the main
Features documentation.
2015-06-23 14:53:49 +01:00
Adam Harrison 59e667801d Merge GCE fix from branch '1.0' 2015-06-23 14:50:58 +01:00
Adam Harrison d6dca80dd7 Merge branch 'latest_release_doc_updates' into 1.0
Pull in GCE fix
2015-06-23 14:49:36 +01:00
Tom Wilkie 74c391f19c Update gce.sh make_template command, and build a fresh template. 2015-06-23 14:48:48 +01:00
Matthias Radestock ae8172ec97 simplify docker image removal 2015-06-23 14:39:29 +01:00
Adam Harrison d6ab78ff03 Merge documentation from branch '1.0' 2015-06-23 14:36:04 +01:00
Adam Harrison 7e36dc01e8 Merge documentation from branch 'latest_release_doc_updates' into 1.0 2015-06-23 14:35:30 +01:00
Adam Harrison 9020c84f81 Merge pull request #990 from awh/feature_docs_proxy_section
Add docker integration section to feature docs
2015-06-23 14:34:25 +01:00
Adam Harrison d0a1514ab6 Removed redundant further reading section from feature docs 2015-06-23 14:33:33 +01:00
Adam Harrison 06c3a0cf2a Add docker integration section to feature docs 2015-06-23 14:33:29 +01:00
Adam Harrison dde5782625 Merge documentation from branch '1.0' 2015-06-23 14:21:05 +01:00
Adam Harrison a1913130e7 Merge documentation from branch 'latest_release_doc_updates' into 1.0 2015-06-23 14:18:42 +01:00
Matthias Radestock 369bd0f4dc prefetch test images
This gives more consistent test execution times, and also make image
fetch failures more apparent and decoupled from the tests.

We could *always* just run pull, but it's an expensive operation, so
we check for the presence of the image first. The downside is that we
could be running old images. That is not a problem on our CI
infrastructure though since it spins up fresh VMs per for every tun.
2015-06-23 14:16:52 +01:00
Tom Wilkie 3b4a47a961 Update gce.sh make_template command, and build a fresh template. 2015-06-23 13:07:09 +00:00
Matthias Radestock f29ee3ad05 Merge pull request #986 from awh/feature_docs_weavedns_section
Add service discovery section to features docs
2015-06-23 13:55:50 +01:00
Adam Harrison 19a3fc6b9e Add naming and discovery section to features docs 2015-06-23 13:50:37 +01:00
Paul Bellamy 0a287217b6 Merge pull request #955 from paulbellamy/testing
Replacing custom testing helpers with testify, where possible
2015-06-23 12:21:24 +01:00
Adam Harrison 043d15355c Restore commit lost to force push 2015-06-23 11:53:22 +01:00
Matthias Radestock 2c4cebe9d9 Merge branch '1.0' 2015-06-23 10:31:40 +01:00
Matthias Radestock 9ec1ce3225 Merge pull request #981 from weaveworks/970_show_docker_py_test_failures
show docker-py test failures
2015-06-23 10:30:57 +01:00
Matthias Radestock cedf9bb82d Merge branch '1.0' 2015-06-23 09:54:24 +01:00
Matthias Radestock 1b4f83c067 Merge branch 'latest_release_doc_updates' into 1.0 2015-06-23 09:53:44 +01:00
Matthias Radestock c126c403e7 Merge pull request #983 from rade/improve_ipam_doc_integration
improve IPAM doc integration
2015-06-23 09:52:39 +01:00
Matthias Radestock 90b9b3c1bf 'address allocation' is the feature
covering both automatic and manual allocation
2015-06-23 09:50:39 +01:00
Matthias Radestock 1a17b41bc3 reduce test output noise 2015-06-23 09:42:46 +01:00
Matthias Radestock 2e5e0a7730 remove pointless assertion 2015-06-23 09:42:46 +01:00
Matthias Radestock b2f62cc635 show test failure output
step towards fixing #970
2015-06-23 09:42:46 +01:00
Matthias Radestock 2a9f8a3d75 Merge branch '1.0' 2015-06-22 23:00:29 +01:00
Matthias Radestock 0a553d6630 Merge branch 'latest_release_doc_updates' into 1.0 2015-06-22 22:59:16 +01:00
Matthias Radestock e51c240ea1 fix broken links 2015-06-22 22:57:48 +01:00
Paul Bellamy acd5b91eb8 Merge remote-tracking branch 'upstream/1.0' 2015-06-22 17:28:50 +01:00
Paul Bellamy f5201469a3 Merge pull request #980 from paulbellamy/only-one-entrypoint
[proxy] Only prepend weavewait if not already present
2015-06-22 17:28:20 +01:00
Paul Bellamy 34aa2e32d8 [proxy] Only prepend weavewait if not already present
This way `docker commit` will not stack up weavewaits.
2015-06-22 15:24:49 +01:00
Adam Harrison bda245bfdb Merge pull request #968 from rade/954_show_attach_expose_addresses
show IP addresses in attach/expose/detach/hide
2015-06-22 14:49:41 +01:00
Bryan Boreham d1eb2917e8 Merge documentation from branch 1.0 into master 2015-06-22 14:32:12 +01:00
Bryan Boreham 9a631d0ecd Merge documentation from branch 'latest_release_doc_updates' into 1.0 2015-06-22 14:25:56 +01:00
Bryan Boreham c8032b6b25 Merge pull request #977 from bboreham/proxy-net-syntax
Change one IPAM proxy example to use a network
2015-06-22 14:24:24 +01:00
Bryan Boreham 68ca6ebe04 Change one IPAM proxy example to use the 'net:' syntax 2015-06-22 14:15:24 +01:00
Matthias Radestock 9f0cd93859 refactor(ish): get the more fundamental setup out of the way first 2015-06-22 12:50:50 +01:00
Matthias Radestock 7cf0d59003 update docs 2015-06-22 12:34:32 +01:00
Adam Harrison 74f8c07674 Merge documentation from branch '1.0' 2015-06-22 12:05:40 +01:00
Adam Harrison 1bbec56cc7 Merge documenation from branch 'latest_release_doc_updates' into 1.0 2015-06-22 12:02:35 +01:00
Adam Harrison b86bae9c86 Fix incorrect address in service import/export examples 2015-06-22 12:00:57 +01:00
Paul Bellamy 6d89867a74 Merge pull request #978 from rade/972_remove_proxy_d_option
remove proxy -D option
2015-06-22 11:36:37 +01:00
Matthias Radestock ebf725d869 add some tests 2015-06-22 11:26:33 +01:00
Matthias Radestock 257774a093 make weave attach|expose|detach|hide show IP addresses
The output contains one IP address for each addr (i.e. [ip:]<cidr> |
net:<cidr> | net:default) supplied on the command line; or, if none
was specified, a single address from the default IPAM subnet.

We don't want `weave run` to output the addresses, since it is meant
to (only) output the container id. Hence we redirect the `attach`
output to stderr in that case.

Closes #954.
2015-06-22 11:26:33 +01:00
Matthias Radestock 6f798f723a Merge remote-tracking branch 'upstream/1.0' into 1.0 2015-06-22 11:17:40 +01:00
Matthias Radestock 5fbda6b094 Merge remote-tracking branch 'upstream/master' 2015-06-22 11:15:58 +01:00
Matthias Radestock b483be8c4b remove the -D proxy option
It doesn't do anything useful since the weave script needs to be able
to talk to docker on the standard unix socket.

Fixes #972.
2015-06-22 11:13:53 +01:00
Adam Harrison a751237164 Merge documentation from branch '1.0' 2015-06-22 11:00:25 +01:00
Matthias Radestock 0c87dcd656 cosmetic 2015-06-22 11:00:12 +01:00
Adam Harrison b1bd1d4d6a Merge pull request #964 from awh/v1.0_use_proxy_doc_updates
Update documentation to leverage proxy
2015-06-22 10:46:00 +01:00
Matthias Radestock e276f3e026 cosmetic 2015-06-22 10:38:59 +01:00
Adam Harrison 1e638be7ac Remove weave run from how it works 2015-06-22 10:36:56 +01:00
Adam Harrison acd2b9abeb Reword proxy hyperlink text in index 2015-06-22 10:36:56 +01:00
Adam Harrison 6ddecfc764 Update proxy docs 2015-06-22 10:36:56 +01:00
Adam Harrison f15ad71354 Update IPAM docs to use proxy 2015-06-22 10:36:56 +01:00
Adam Harrison 4d54af39b0 Update weaveDNS docs to use proxy 2015-06-22 10:36:56 +01:00
Adam Harrison 81d5a8f4f5 Update features docs to use proxy 2015-06-22 10:36:56 +01:00
Adam Harrison 344119f42a Update README examples to use proxy 2015-06-22 10:36:52 +01:00
Matthias Radestock 84e5659090 Merge branch '1.0' 2015-06-22 10:31:50 +01:00
Matthias Radestock 514db8efdd Merge branch 'latest_release_doc_updates' into 1.0 2015-06-22 10:31:20 +01:00
Paul Bellamy 0693ec55c6 Merge pull request #974 from rade/972_remove_proxy_d_option_from_docs
remove the `-D` proxy option from the docs
2015-06-22 10:29:16 +01:00
Matthias Radestock 56c720b078 remove the -D proxy option from the docs
It doesn't do anything useful since the weave script needs to be able
to talk to docker on the standard unix socket.

Also remove dangling reference to 'localhost', and move note about
firwalls to where it is most pertinent.

Part fix to #972.
2015-06-22 10:20:18 +01:00
Matthias Radestock bbeb7966b4 Merge remote-tracking branch 'upstream/1.0' 2015-06-21 10:42:28 +01:00
Matthias Radestock 403b9654f1 Merge remote-tracking branch 'upstream/1.0' into latest_release_doc_updates 2015-06-21 10:41:38 +01:00
Matthias Radestock 84775e414b Add release 1.0.1 2015-06-21 10:05:52 +01:00
Matthias Radestock edb4911bf6 Merge branch '1.0' 2015-06-21 09:39:45 +01:00
Matthias Radestock d913ca869c Merge branch '967_include_image_name_in_inspect_error' into 1.0 2015-06-21 09:38:42 +01:00
Michael Bridgen e3917121fa Merge remote-tracking branch 'upstream/1.0.0' 2015-06-20 16:45:34 -07:00
Michael Bridgen ede288ad38 Merge pull request #969 from rade/967_include_image_name_in_inspect_error
include image name in errors
2015-06-20 16:41:05 -07:00
Michael Bridgen 58f14551dc Merge branch 'pr969' 2015-06-20 16:28:44 -07:00
Michael Bridgen 97816d6c54 Merge branch '967_include_image_name_in_inspect_error' of https://github.com/rade/weave into pr969 2015-06-20 16:21:20 -07:00
Matthias Radestock 3732f968d0 include image name in errors
The go docker client's ErrNoSuchImage does not include the image
name. However, it is imperative that this name appears in error
messages sent to clients, since the docker client, as of version
1.7.0, only automatically pulls images when their name is present in
the error.

Fixes #967.
2015-06-20 23:36:48 +01:00
Matthias Radestock 939a095bf4 Merge pull request #966 from weaveworks/readme_website_sync
README update to point at weave.works
2015-06-19 20:38:37 +01:00
Fintan Ryan ad0d53f7fe Update proposed text 2015-06-19 19:17:43 +01:00
Fintan Ryan e748ddc20d README update to point at weave.works 2015-06-19 13:00:01 +01:00
Matthias Radestock e51ecd73b3 refactor: extract helper 2015-06-18 19:01:10 +01:00
Matthias Radestock 5479d0a54d improve test performance - only fetch status once per check 2015-06-18 18:53:06 +01:00
Matthias Radestock 6830b27317 cosmetic: correct some comments, tweak some arg parsing 2015-06-18 18:13:27 +01:00
Matthias Radestock 4399be7ad2 correct comments 2015-06-18 17:55:42 +01:00
Matthias Radestock 42d2a860eb test more things, more obviously 2015-06-18 17:48:21 +01:00
Matthias Radestock 3ec0200067 cosmetic oops 2015-06-18 16:57:54 +01:00
Matthias Radestock d1e4a8ec8a cosmetic: vertical alignment and consistency for better readability 2015-06-18 16:26:16 +01:00
Paul Bellamy 54b3061c50 Merge gofmt and goimports run 2015-06-18 14:05:51 +01:00
Bryan Boreham 19fe808dff Update links in changelog to point at latest_release 2015-06-18 11:59:44 +01:00
Bryan Boreham b7281cc08d Add release 1.0.0 2015-06-18 11:23:44 +01:00
Adam Harrison 617c3883c7 Merge pull request #948 from awh/v1.0_doc_updates
Update documentation to leverage IPAM and DNS
2015-06-18 10:38:32 +01:00
Adam Harrison 9e20a5256b Rename example containers 2015-06-18 10:32:15 +01:00
Matthias Radestock a3db33cfd9 more helpful error message when weave et al die on startup
Closes #958.
2015-06-17 22:54:11 +01:00
Adam Harrison aa8a86a0b9 Update service binding example 2015-06-17 17:34:15 +01:00
Adam Harrison 7238192150 Update service routing example 2015-06-17 17:34:15 +01:00
Adam Harrison caa0e31be2 Update service import example 2015-06-17 17:34:15 +01:00
Adam Harrison 5a6cafc3da Update service export example 2015-06-17 17:34:15 +01:00
Adam Harrison 1df52350fa Update host network integration example 2015-06-17 17:34:15 +01:00
Adam Harrison 40323202f5 Update dynamic attachment example 2015-06-17 17:34:15 +01:00
Adam Harrison 0d83f24661 Prefer -ti to -t -i in updated examples 2015-06-17 17:34:15 +01:00
Adam Harrison 8550469c9f Update subnet isolation example 2015-06-17 17:34:15 +01:00
Adam Harrison e5679a787c Update subnet isolation example 2015-06-17 17:34:15 +01:00
Adam Harrison e37a4314b3 Add manual addressing to features 2015-06-17 17:34:10 +01:00
Adam Harrison 7b5ee8fb65 Update virtual ethernet switch example 2015-06-17 17:32:40 +01:00
Adam Harrison cf5835f081 Update README examples to use IPAM and DNS 2015-06-17 17:32:40 +01:00
Paul Bellamy aea1a2b08c have travis fetch any test-only dependencies before building tests 2015-06-17 17:00:36 +01:00
Paul Bellamy cdee7a5d6f Replacing custom testing helpers with testify, where possible 2015-06-17 16:58:03 +01:00
Paul Bellamy 21e07c0db9 Running gofmt -s 2015-06-17 15:32:08 +01:00
Paul Bellamy 06101d134b Running goimports 2015-06-17 15:32:08 +01:00
Matthias Radestock 501108e3ae cosmetic: vertical alignment 2015-06-17 15:13:07 +01:00
Matthias Radestock 87fe10ab5d Merge pull request #952 from paulbellamy/950-proxy-launch-router
Add support for WEAVE_CIDR=none

Fixes #950.
2015-06-17 14:57:35 +01:00
Paul Bellamy 6c26a55b5a [proxy] refactor weaveCIDRsFromConfig slightly 2015-06-17 14:51:12 +01:00
Paul Bellamy ca681bce13 [proxy] Add support for WEAVE_CIDR=none
Tells the proxy not to do anything with this container. We set it when
running weaveexec/weave/etc containers, so that the weave script works
through the proxy.
2015-06-17 14:51:12 +01:00
Bryan Boreham ff838a14d9 Fix terminology in error message.
Also removed hint on usage, because `-iprange` is on by default.
2015-06-17 13:16:53 +01:00
Matthias Radestock c45b586a44 Merge pull request #949 from paulbellamy/939-proxy-env-bug
remove spurious output from proxy-(env|config)

Fixes #939.
2015-06-17 12:10:09 +01:00
Matthias Radestock 215312bb5f Merge pull request #946 from bboreham/758-expand-ipam-docs
Expand description of -initpeercount in docs

Closes #758.
2015-06-17 12:06:04 +01:00
Bryan Boreham 34e0e3bb24 Merge pull request #935 from bboreham/weavedns-races
All unit and smoke tests passed.
2015-06-17 12:05:43 +01:00
Paul Bellamy b1f43f0d7c [proxy] Remove spurious output from proxy-(env|config)
`docker log` outputs an error if stdout is closed before it is done, so
silence that
2015-06-17 11:53:28 +01:00
Bryan Boreham 40efc347b6 Cosmetic 2015-06-17 11:41:46 +01:00
Matthias Radestock 71f19469ab Merge pull request #947 from paulbellamy/940-proxy-default-ipam
[proxy] --with-ipam -> --no-default-ipam

Closes #940.
2015-06-17 11:37:25 +01:00
Bryan Boreham 9636675c2c Split part of DNSServer.Start() to a separate ActivateAndServe()
Specifically, move the part that blocks, and call that as necessary.
This means Start() can run on the caller's goroutine and avoid race conditions.
2015-06-17 11:35:53 +01:00
Bryan Boreham 1b57a24789 Don't re-initialise log writers unless the type changed.
This avoids race-conditions in unit tests where the initialisation
is on a different goroutine to the logging.
2015-06-17 11:35:01 +01:00
Bryan Boreham 90fb201a51 Copy the DNS entry going into the cache, to avoid races.
The shuffleAnswers() call ends up acting on the same data,
so it seems simplest to resolve ownership arguments by copying.
2015-06-17 11:35:01 +01:00
Bryan Boreham 657133db50 Move the counting of results from DNS goroutine to test goroutine to avoid race-condition 2015-06-17 11:35:01 +01:00
Bryan Boreham e68364cb3b Don't overwrite recvChan; it just creates a race condition 2015-06-17 11:35:01 +01:00
Bryan Boreham 1f92ae6ba8 Swap the order in which two goroutines are started, since one relies on the other. 2015-06-17 11:35:01 +01:00
Bryan Boreham a6bebd85ed Remove 'running' member that triggers a race warning and isn't necessary. 2015-06-17 11:35:01 +01:00
Paul Bellamy 220c80c3ed [proxy] --with-ipam -> --no-default-ipam 2015-06-17 11:31:33 +01:00
Bryan Boreham 5960ecb3d1 Expand description of -initpeercount 2015-06-17 11:12:10 +01:00
Matthias Radestock c2778d9fa3 improve -neg-ttl usage message 2015-06-17 10:29:39 +01:00
Matthias Radestock cfe14ff568 Merge pull request #943 from inercia/weave-941
make negative TTL default to same value as TTL

Fixes #941.
2015-06-17 10:23:41 +01:00
Matthias Radestock cf5d8874b6 Merge pull request #937 from inercia/weave-934
Ignore empty queries (sent when the server is being shut down)

Fixes #934.
2015-06-17 10:10:18 +01:00
Alvaro Saurin d086867c0c make negative TTL default to same value as TTL 2015-06-17 10:17:12 +02:00
Matthias Radestock d09133c010 cosmetic: less sudoing 2015-06-17 08:30:35 +01:00
Matthias Radestock 6ac2b34a6e Merge pull request #936 from weaveworks/readme_update_2
Update wget to curl
2015-06-17 08:27:46 +01:00
Matthias Radestock 9276df62c2 document weave stop-proxy 2015-06-17 07:09:47 +01:00
Matthias Radestock d4c383b4b7 cosmetic: add weaveDNS TTL customisation to ToC 2015-06-17 07:05:09 +01:00
Matthias Radestock b10a4a2976 cosmetic 2015-06-17 06:59:20 +01:00
Matthias Radestock cfda9ffb8f add load balancing and faul resilience to weaveDNS docs ToC
This was missed in #775
2015-06-17 06:48:12 +01:00
Matthias Radestock ae5c2dab86 take advantage of recent features in proxy example 2015-06-16 23:01:14 +01:00
Matthias Radestock 0452076ebc remove outdated note 2015-06-16 22:58:30 +01:00
Matthias Radestock 7831460eff rely on ipam for launch-dns in proxy example 2015-06-16 22:51:57 +01:00
Matthias Radestock 20d5790358 drop -iprange from proxy docs, since ipam is enabled by default now 2015-06-16 22:51:10 +01:00
Matthias Radestock a52702f76e fix typo 2015-06-16 22:46:41 +01:00
Matthias Radestock 351573c122 simplify proxy launch examples
No need to specify --with-dns if DNS is running.

This should have been changed as part of #898.
2015-06-16 22:38:53 +01:00
Matthias Radestock 809b048abd fix sporadic 650_*.sh test failure caused by undefined variable
This is quite hilarious...

$BASE_IMAGE is not defined in config.sh. So running this test would
actually attempt to run something like

docker -H=... run -e WEAVE_CIDR=10.2.1.4/24  grep ^1$ /sys/class/net/ethwe/carrier

i.e. it would try to run the 'grep' image.

So why does this not fail all the time?

1) 610_*.sh defines $BASE_IMAGE.
2) 620_*.sh builds a 'grep' image.

If either of these tests are included in the same test run before
650_*.sh, then the latter will succeed.

Throw in our fabulous CircleCI scheduler, which distributes tests
according to their execution time, and you end up with sporadic
failures.

Fixes #938.
2015-06-16 21:13:35 +01:00
Alvaro Saurin c697d2a8f9 Ignore empty queries (sent when the server is being shut down) 2015-06-16 20:54:51 +02:00
Adam Harrison b8afefa55f Merge pull request #931 from paulbellamy/weavedns_default_search_domain
[dns] resolve names in `weave.local` by default unless hostname or search path is specified
2015-06-16 18:13:17 +01:00
Fintan Ryan 84bf3c139c Update wget to curl 2015-06-16 17:55:48 +01:00
Paul Bellamy 1bd343f9f0 Merge pull request #932 from bboreham/921-ipam-or-die
Kill the container we just started if we fail to allocate an IP address
2015-06-16 16:18:23 +01:00
Bryan Boreham fd5ac633d3 Use weave attach --or-die in proxy instead of killing it in the proxy. 2015-06-16 16:05:41 +01:00
Paul Bellamy a3e836bbaf Merge pull request #933 from inercia/weave-930
Use read/write-locks instead of read-locks in the Domain*Lookup()
2015-06-16 15:41:44 +01:00
Bryan Boreham ee4daf02b5 Introduce ipam_cidrs_or_die, and call it where we don't want the
container to survive an ipam failure.
2015-06-16 15:27:49 +01:00
Paul Bellamy a8c1832469 updating docs for new dns-search domain behaviour 2015-06-16 15:13:19 +01:00
Paul Bellamy 2c3baa9119 use weavedns search-domain by default
iff no hostname/dns-search specified
2015-06-16 15:13:19 +01:00
Alvaro Saurin f4507e7252 Change read-locks for read/write-locks 2015-06-16 16:02:49 +02:00
Bryan Boreham 32d3909023 Make ipam_cidrs() return failure when call_weave fails 2015-06-16 14:47:47 +01:00
Alvaro Saurin 8a935e3cb2 Launch WeaveDNS with "launch_dns_on" 2015-06-16 15:29:36 +02:00
Matthias Radestock 8b5d0e3fbd Merge pull request #898 from paulbellamy/weavedns_default_resolver
Weavedns default resolver

Fixes #383.
2015-06-16 14:17:14 +01:00
Paul Bellamy af38f07d26 refactoring proxy dns test 2015-06-16 14:08:35 +01:00
Adam Harrison b33d4497fa Fix test broken by new default behaviour 2015-06-16 14:07:42 +01:00
Adam Harrison 03b83811fa Update documentation 2015-06-16 14:07:42 +01:00
Adam Harrison e5b1cc21a9 Smoke test for new weave script DNS behaviour 2015-06-16 14:07:42 +01:00
Adam Harrison fdce84d9d9 New --with-dns/--without-dns behaviour in weave script 2015-06-16 14:07:42 +01:00
Paul Bellamy 8873d69b77 [proxy] Add --without-dns flag, and change meaning of --with-dns flag 2015-06-16 14:07:40 +01:00
Alvaro Saurin a1cb5b16a6 Run the unit tests with GOMAXPROCS=4 2015-06-16 14:58:53 +02:00
Alvaro Saurin 8621aa7cbf Launch WeaveDNS with --debug when DEBUG is set 2015-06-16 14:58:53 +02:00
Bryan Boreham 9a99a51e14 Merge pull request #925 from bboreham/922-remove-dot
Remove trailing dot from hostnames. Fixes #922.
2015-06-16 13:58:12 +01:00
Paul Bellamy bd0aff6a0f Merge pull request #929 from weaveworks/923-fix-deadlock
Fix deadlock in weavedns
2015-06-16 13:31:39 +01:00
Matthias Radestock 25dd60a149 Merge pull request #928 from awh/offset_tcp_nonce
Set high bit in TCP nonce to differentiate from UDP

Fixes #927.
2015-06-16 13:21:09 +01:00
Paul Bellamy 048261c921 Hold lock while accessing mutable variable, but release before sending on chan 2015-06-16 13:06:14 +01:00
Adam Harrison 9149366919 Set high bit in TCP nonce to differentiate from UDP 2015-06-16 12:21:18 +01:00
David Wragg 47d7c22073 Merge rade/871_version_header (PR #920): protocol versioning
Closes #871.
2015-06-16 12:20:40 +01:00
Bryan Boreham 7a106aeb5f Release lock before sending on a channel 2015-06-16 11:44:25 +01:00
Matthias Radestock 3124ffede5 more forward/backward compatible protocol versioning
We now first exchange a very minimal header, consisting of just the
name of the protocol ("weave") and the min and max version (encoded as
a byte each) we support. This leaves all other details of the
protocol, including the contents of of the handshake, open.

Peers agree to communicate using the maximum mutually supported
version. We record this in the LocalConnection, though atm nothing is
making use of that information.

We set a shorter than normal deadline (10s instead of 60s) for the
header exchange, so we detect version mismatches, garbage, or
non-responsive remotes quickly.

We reset the protocol version to '1' since this is a fresh start; old
weaves will not be able to parse the header.

Closes #871.
2015-06-16 11:00:41 +01:00
Bryan Boreham 79db00a90e Strip trailing period from hostname generated from weavedns domain.
We strip at the calling point rather than in the server, because DNS
servers do see the domain as ending with a '.'  representing the root.
2015-06-16 10:26:11 +01:00
Bryan Boreham dd9adf6a65 Don't add a trailing newline to the domain 2015-06-16 10:25:54 +01:00
Matthias Radestock 0206434f62 fix 130_expose_test breakage
introduced by 8ac98f9f6b
2015-06-15 22:25:22 +01:00
Matthias Radestock 657cbaefb9 refactor: simplify dns_args 2015-06-15 21:54:51 +01:00
Matthias Radestock ee61f07d9b refactor: extract rm_containers helper
cherry-picked from #898
2015-06-15 21:41:43 +01:00
Matthias Radestock cba1827d2c Merge pull request #918 from bboreham/916-check-call-weave
Output error message if http call to weave or weavedns fails

Fixes #916.
2015-06-15 21:16:40 +01:00
Matthias Radestock 3d7c18ee70 cosmetic: remove some unnecessary quoting 2015-06-15 21:02:23 +01:00
Matthias Radestock 82c1a58e81 refactor: remove unused weave dns-domain command
and inline dns_domain() function.

Both were introduced in #890.
2015-06-15 19:23:52 +01:00
Matthias Radestock 8ac98f9f6b tiny refactor: replace some 'if's with short-circuit expressions 2015-06-15 18:33:29 +01:00
Bryan Boreham 56e0636b14 Output error message if http call to weave or weavedns fails 2015-06-15 17:58:59 +01:00
Bryan Boreham 6534cc6ae3 Merge pull request #919 from bboreham/915-not-again-again
Fixes #915
2015-06-15 17:06:30 +01:00
Bryan Boreham d25d0810af Extend the 'block' flag to block allocateAgain()
otherwise we can re-insert the entry into the map after a parallel
allocateAgain() has cleared the flag. And it /that/ happens in
parallel with a free() then the data-structure can get out of sync.
2015-06-15 16:51:27 +01:00
Alvaro Saurin ba2f6671a6 Removed a couple of Debug.Printf()s 2015-06-15 17:11:27 +02:00
Alvaro 9284366a3d Merge pull request #917 from bboreham/inercia-flush-sched-queue
Return of the Fix for the zone refresh unit test
2015-06-15 15:45:57 +02:00
Bryan Boreham 7e6a478283 Merge pull request #914 from rade/911_different_gossip_channels
LGTM. Fixes #911
2015-06-15 14:42:22 +01:00
Matthias Radestock e15ebd9118 add unit test for SurrogateGossiper 2015-06-15 14:22:25 +01:00
Bryan Boreham 0ff311356d Flush the background updater goroutines to make tests reliable 2015-06-15 13:48:54 +01:00
Bryan Boreham e49a29197b Add a Flush() routine to synchronize callers 2015-06-15 13:48:24 +01:00
Bryan Boreham 2b7fb699af Clean up a couple of compilation errors 2015-06-15 13:47:01 +01:00
Bryan Boreham f3ad8bd52f Merge branch 'weave-fix-unittest' of https://github.com/inercia/weave into inercia-weave-fix-unittest 2015-06-15 11:51:14 +01:00
Matthias Radestock 36ba838f54 remove ipam.DummyAllocator and rely on new SurrogateGossiper
As a result it is possible to mix nodes with and without IPAM. Note
that the quorum only involves the former, and hence such mixed
environments will typically require a custom `-initpeercount`.
2015-06-15 11:24:07 +01:00
Matthias Radestock dea5bd0639 introduce SurrogateGossiper for dealing with unknown gossip channels
Instead of erroring when we receive gossip for an unknown channel, we
create a GossipChannel on the fly, with a SurrogateGossiper singleton
as the gossiper.

The SurrogateGossiper ignores unicasts and relays broadcasts and
gossip.
2015-06-15 11:23:32 +01:00
Matthias Radestock 0b3584a355 permit encoding of GossipData into multiple messages 2015-06-15 11:14:24 +01:00
Matthias Radestock 94220f22b2 allow dynamic addition of gossip channels 2015-06-15 11:14:24 +01:00
Matthias Radestock ec85da914a simplify dns-add/remove arg checking 2015-06-15 10:34:59 +01:00
Matthias Radestock bfebfecf6c refactor: simplify test router creation 2015-06-15 08:12:35 +01:00
Matthias Radestock e48ec6a35f clean up erroneous comment 2015-06-15 08:03:02 +01:00
Matthias Radestock a844797d67 cosmetic: reduce test noise 2015-06-14 17:48:21 +01:00
Matthias Radestock 72640f1828 refactor: extract helpers for http calls into weave and weavedns 2015-06-14 17:46:56 +01:00
Matthias Radestock 4ce6a76d1f remove outdated piece of docs 2015-06-14 16:36:37 +01:00
Matthias Radestock bf4c75b1cd don't validate -iprange value
We generally don't validate arguments in the script unless we process
them there.
2015-06-14 16:12:53 +01:00
Matthias Radestock 313a95a467 let -iprange "" start the router w/o IPAM 2015-06-14 16:06:20 +01:00
Matthias Radestock 926c85c6ba more idiomatic 'boolean' in shell 2015-06-14 15:48:08 +01:00
Matthias Radestock afb31d3beb cosmetic: remove unused method 2015-06-14 11:49:03 +01:00
Matthias Radestock c4c5ec1e92 refactor: add a little helper to improve abstraction 2015-06-14 11:09:55 +01:00
Matthias Radestock cea85eb05b cosmetic: move GossipChannel code into separate file 2015-06-14 10:35:51 +01:00
Matthias Radestock 3e0d0a1993 refactor: introduce NewGossipChannel 2015-06-14 10:09:36 +01:00
Matthias Radestock 882ed85d77 tiny refactor 2015-06-14 09:37:13 +01:00
Matthias Radestock eae9928e98 don't complain when weave --local run is invoked without args
leave that to docker, same as we do for `weave run`

Fixes #910.
2015-06-13 00:48:01 +01:00
Matthias Radestock 779d1589c5 Merge pull request #907 from bboreham/819-check-its-alive
Free allocated address if container is not running

Fixes #819.
2015-06-12 17:22:16 +01:00
Bryan Boreham 4c01af4e1d Check if container is still running right after allocating 2015-06-12 17:09:11 +01:00
Bryan Boreham 13944f3811 Refactor is-running check so we can re-use more of the code 2015-06-12 17:09:11 +01:00
Matthias Radestock 0f9f1feb87 Merge pull request #906 from awh/weavedns_restrict_http_listen
DNS HTTP API listens on eth0 only

Fixes #899.
2015-06-12 16:56:22 +01:00
Adam Harrison b6889ec8c3 DNS HTTP API listens on eth0 only 2015-06-12 16:55:27 +01:00
Bryan Boreham 5aafbbeff0 Fix compile error introduced in merge of #904 2015-06-12 16:20:35 +01:00
Matthias Radestock 7462fe91d5 Merge pull request #904 from bboreham/inercia-weave-821
Remove stale records for short-lived containers (bis)

Fixes #821. Replaces and hence closes #865.
2015-06-12 15:36:12 +01:00
Matthias Radestock 79c5343ca5 Merge pull request #905 from bboreham/slashten
Use /10 instead of /9 for default iprange

Patching up #893.
2015-06-12 15:21:38 +01:00
Matthias Radestock d5ebd6a0c4 Merge branch 'latest_release_doc_updates'
Conflicts:
	CHANGELOG.md
	nameserver/cache_test.go
	site/features.md
	site/proxy.md
	weave
2015-06-12 15:16:50 +01:00
Bryan Boreham 12de13c678 Use /10 instead of /9 for default iprange, so it doesn't clash with CircleCI address 2015-06-12 15:15:36 +01:00
Matthias Radestock 97d692df80 don't restart docker in test setup
due to that leaving container debris behind that docker takes ages to
clean up.
2015-06-12 15:01:35 +01:00
Bryan Boreham 7941612dad remove one level of indentation 2015-06-12 15:01:06 +01:00
Matthias Radestock c25706f6a5 Merge pull request #902 from bboreham/885-gossip-race
Keep flushing gossip until it's all gone

A better (i.e. working?) fix for #885.
2015-06-12 15:00:02 +01:00
Bryan Boreham 799e202d6d Make error message more readable 2015-06-12 14:52:20 +01:00
Bryan Boreham 658fbac7aa Keep flushing gossip until it's all gone
A better (i.e. working?) fix for #885.
2015-06-12 14:50:37 +01:00
Bryan Boreham 086daca3d0 Fold communication-checking code into docker.Client.NewClient() 2015-06-12 14:45:29 +01:00
Matthias Radestock f48f9ba475 relax documented weavedns subnet requirements somewhat
Following #763.
2015-06-12 14:22:57 +01:00
Bryan Boreham 29c988d42f Merge pull request #900 from rade/762_dns_ipam
LGTM.  Closes #762.
2015-06-12 14:21:07 +01:00
Matthias Radestock 06183bea1a extensive documentation 2015-06-12 14:01:34 +01:00
Matthias Radestock a2146ca5b0 add tests for launching DNS with various ways of obtaining an IP
As a side effect this also tests repopulation on restart, so we can
remove the separate test for that.
2015-06-12 13:50:22 +01:00
Matthias Radestock 727a213ba1 permit weavedns IP addresses to be choosen by IPAM
Same as for ordinary containers.

Closes #762.
2015-06-12 13:50:22 +01:00
Matthias Radestock 38266f2918 fix layout 2015-06-12 13:35:12 +01:00
Matthias Radestock 6d4c1e49fe fix layout 2015-06-12 13:33:32 +01:00
Matthias Radestock fa00b9faf3 add ToC to ipam docs
also shorten some of the headings, and use H2 instead of H3
2015-06-12 12:24:32 +01:00
Matthias Radestock 685d7d2559 Merge pull request #893 from bboreham/743-default-iprange-in-script
Default value for -iprange

Closes #743. Closes #870.
2015-06-12 11:17:12 +01:00
Matthias Radestock df918ab3c4 revamp ipam docs 2015-06-11 22:24:07 +01:00
Bryan Boreham 404ae010e4 Improve flow of IPAM doc 2015-06-11 18:35:18 +01:00
Bryan Boreham 43d42e6f15 Update docs for default -iprange 2015-06-11 18:01:28 +01:00
Bryan Boreham 328e63828e Check whether netcheck exists before relying on it 2015-06-11 17:55:27 +01:00
Bryan Boreham 465b16e668 Give -iprange a default, and check if it is free 2015-06-11 17:34:43 +01:00
Bryan Boreham 0e6569d78c New program netcheck to check if network overlaps routes 2015-06-11 17:27:20 +01:00
Bryan Boreham 8285046962 Function to check if a network overlaps with existing routes 2015-06-11 17:27:20 +01:00
Matthias Radestock 8e04b135bb check that nsenter is present
for `weave --local ...`

Closes #895.
2015-06-11 16:37:28 +01:00
Matthias Radestock 2b7c785386 don't output container id when we kill it
This was missed from #831.
2015-06-11 16:34:46 +01:00
Paul Bellamy 09f491821b making test executable 2015-06-11 13:51:41 +01:00
Adam Harrison c0cfacdb28 Repatriate itinerant smoke test 2015-06-11 12:54:07 +01:00
Matthias Radestock e96cde1872 Merge pull request #890 from awh/use_container_name_as_hostname
Use container name as hostname

Closes #750.
2015-06-11 12:35:46 +01:00
Adam Harrison 12fc760e4a Refocus documentation around --name 2015-06-11 12:17:05 +01:00
Paul Bellamy d2b17690f9 use dnsutils image in one test instead of awk on all the tests. 2015-06-11 12:13:24 +01:00
Adam Harrison 8d7fe2b9e7 Renamed smoke test to avoid number clash 2015-06-11 11:55:21 +01:00
Adam Harrison 1fa7c24a2a Prefer --name to -h in examples 2015-06-11 11:54:05 +01:00
Adam Harrison 6b80dc035a Simplify smoke test 2015-06-11 11:53:24 +01:00
Adam Harrison 35cfafc319 Defer evaluation of $(dns_domain) until necessary 2015-06-11 11:52:33 +01:00
Matthias Radestock e1c07dce3f permit overriding of DOCKERHUB_USER
which in turn enables operation from private registries

Closes #887.
2015-06-11 11:50:55 +01:00
Paul Bellamy 96bda1639e define weavedns http port as a constant 2015-06-11 10:27:35 +01:00
Adam Harrison a424bfe715 Correctly interpret long form arguments that lack an equals symbol 2015-06-11 10:27:34 +01:00
Adam Harrison 4f6ace8b10 Permit optional trailing dot on hostname 2015-06-11 10:27:34 +01:00
Adam Harrison bccb5065db Update docs with new weave run behaviour 2015-06-11 10:27:34 +01:00
Adam Harrison bed6a130d6 Smoke test for new weave run behaviour 2015-06-11 10:27:34 +01:00
Adam Harrison 108eea8b79 Modify weave run to use container name as fqdn
When run is invoked with `--with-dns` and a container name but no
hostname, synthesise a fully qualified hostname from the container name
and the weaveDNS domain and supply that as a hostname for the container.
2015-06-11 10:27:34 +01:00
Paul Bellamy 678063efec updating proxy docs on hostname/domainname dns 2015-06-11 10:27:34 +01:00
Paul Bellamy 99d9ad7042 [proxy] query weavedns for domain 2015-06-11 10:27:34 +01:00
Paul Bellamy b9850ac200 [proxy] Set hostname and domainname based on container name, when dns
Had to make the assert_dns_record test helper more robust against
'getent hosts' returning duplicates
2015-06-11 10:27:29 +01:00
Adam Harrison 9fddad02ad Add dns_domain helper to weave script 2015-06-11 10:26:07 +01:00
Adam Harrison a1007411ad Add /domain resource to DNS REST API 2015-06-11 10:26:07 +01:00
Matthias Radestock 9955de3e9b cosmetic: shorten usage info 2015-06-11 09:23:58 +01:00
Alvaro Saurin 2eb39d962a Use the scheduled queue for refreshing names
Some minor time tweaks...
2015-06-10 22:56:40 +02:00
Alvaro Saurin d6a9fc57cc New scheduled queue, for scheduling calls to callables 2015-06-10 22:56:38 +02:00
Alvaro Saurin 698d352322 Check with Docker whether the container is really running 2015-06-10 22:27:49 +02:00
Alvaro Saurin 1889a4a87f Simplify the arguments passed to nameserver/http.go:ServeHTTP() (by using information found in some other objects we are already passing, like the server) 2015-06-10 22:27:49 +02:00
Alvaro Saurin 5cb2347f77 Use our own Docker client 2015-06-10 22:27:47 +02:00
David Wragg 5ce4b25f38 Merge rade/746_simplify_frag_test (PR #888): simplify fragmentation test
Closes #746.
2015-06-10 18:28:26 +01:00
Matthias Radestock 267716fed5 Merge pull request #827 from bboreham/675-ipam-subnets
multi-subnet ipam

Closes #675. Fixes #861. Closes #862.
2015-06-10 17:44:17 +01:00
Bryan Boreham a89b549c40 Change command-line syntax to net: prefix instead of --subnet 2015-06-10 17:28:06 +01:00
Bryan Boreham 91ad3ef684 Illustrate mix-and-match of ipam and non-ipam CIDRs on command-line 2015-06-10 17:27:07 +01:00
Bryan Boreham 36f793c1f4 Delete entry from addresses map when slice is empty 2015-06-10 17:27:07 +01:00
Bryan Boreham c27cd5b4ab Extract lookup function for owned addresses 2015-06-10 17:27:07 +01:00
Bryan Boreham 7d881a0f0c Check that weave ps returns exactly the CIDRs we are looking for, and comment assumption 2015-06-10 17:27:07 +01:00
Bryan Boreham 487bd2eaf7 Use zero-cidr-args form of 'weave detach' to test #862 2015-06-10 17:24:36 +01:00
Bryan Boreham e9d194327a Reduce level of noise in debug logs from containers dying 2015-06-10 17:24:36 +01:00
Bryan Boreham c301e6a380 Expand test to use IPAM and check addresses are freed 2015-06-10 17:24:36 +01:00
Bryan Boreham a3d73be8b8 General tidying
tidy Address helper functions,
make ordering of members consistent in allocate and claim,
make linter happier,
remove some unused items, and
update some comments
2015-06-10 17:24:36 +01:00
Bryan Boreham fa0b0042b2 Eradicate the last vestiges of CIDR in Allocator 2015-06-10 17:24:36 +01:00
Bryan Boreham e21f66db0a Use address.Range instead of (start,end) pairs 2015-06-10 17:24:36 +01:00
Bryan Boreham 1e71d2dacb Introduce new '<address_spec>' type in usage text 2015-06-10 17:24:36 +01:00
Bryan Boreham a80e5cb028 Corrected space.Donate() to restrict the space donated to be in-range, and associated unit test changes 2015-06-10 17:24:36 +01:00
Bryan Boreham 40c9adc8d3 Extract common freelist-walking code 2015-06-10 17:24:36 +01:00
Bryan Boreham 147962d101 Clarify some unit test operations 2015-06-10 17:24:36 +01:00
Bryan Boreham 6536034ab6 Move default subnet outside of Allocator 2015-06-10 17:24:36 +01:00
Bryan Boreham 7e7a2227a0 Document multi-subnet IPAM 2015-06-10 17:24:36 +01:00
Bryan Boreham e5113889f4 Move NumFreeAddresses() into test 2015-06-10 17:24:36 +01:00
Bryan Boreham 3cdc3522be Don't overwrite CIDR_ARGS; write new variables ALL_CIDRS and IPAM_CIDRS
Handle manual CIDRs and IPAM CIDRs separately, to avoid inconsistencies and misleading messages
2015-06-10 17:24:35 +01:00
Bryan Boreham 2b4eec39cf Support '--subnet default' 2015-06-10 17:21:16 +01:00
Bryan Boreham 3a9af4413d Rationalize ipam arguments
- rename -defaultsubnet to -ipsubnet
- default subnet defaults to whole -iprange
- parse and check inside ipam package
- removes some error cases
2015-06-10 17:21:16 +01:00
Bryan Boreham f956a76455 Tighten error checking in weave script
- --subnet is used but IPAM is off
 - arg that comes after --subnet is not a cidr
2015-06-10 17:21:16 +01:00
Bryan Boreham ecbd514a83 Tighten error checking 2015-06-10 17:21:16 +01:00
Bryan Boreham 50eaccc60c Allocate() and Lookup() now return a CIDR, to simplify output 2015-06-10 17:21:16 +01:00
Bryan Boreham 2a00b0092d Extend 'Lookup' to multi-subnet 2015-06-10 17:21:16 +01:00
Bryan Boreham d18ccac43b Free IPAM addresses individually in 'weave hide', because the user now has the ability to free some subnets and not others 2015-06-10 17:21:16 +01:00
Bryan Boreham a617e7918c Introduce single-address Free() and rename the previous one to Delete() 2015-06-10 17:21:16 +01:00
Bryan Boreham d20d2e9142 Update smoke tests that use IPAM with default subnet 2015-06-10 17:21:16 +01:00
Bryan Boreham 551394a831 Add subnet info to space requests from one peer to another 2015-06-10 17:21:16 +01:00
Bryan Boreham 0613a06653 IPAM: handle multiple CIDRs in weave script 2015-06-10 17:21:16 +01:00
Bryan Boreham ff545feae3 Add some unit tests for multi-subnet 2015-06-10 17:21:16 +01:00
Bryan Boreham c7a9dfbb3f Remember multiple addresses owned by each container, for multi-subnet use 2015-06-10 17:21:16 +01:00
Bryan Boreham 2553850ed4 Initial implementation of multi-subnet IPAM 2015-06-10 17:21:16 +01:00
Bryan Boreham e6d230042d Introduce address.CIDR type 2015-06-10 17:21:16 +01:00
Bryan Boreham ae8985deb5 Merge pull request #884 from rade/881_get_container_id_on_start
LGTM. Fixes #881
2015-06-10 17:20:25 +01:00
Matthias Radestock 18bc3c2b99 "online dictionary attacks" is better terminology 2015-06-10 16:40:25 +01:00
Matthias Radestock afd0275042 Merge pull request #848 from paulbellamy/proxy-env
add proxy-env and proxy-config

Closes #753.
2015-06-10 15:34:32 +01:00
Paul Bellamy 2d5e362115 [proxy] use logs for getting proxy-env and proxy-config
It's ugly, but beats arg-parsing, inspecting the container and piecing
the address together from exposed ports.

We could just use the host from DOCKER_HOST, but that will fail in the
case of a host with multiple IPs, where the proxy only listens on one.
2015-06-10 15:24:53 +01:00
Matthias Radestock 7a2b5c43e7 feed full container id on weave start to DNS/IPAM
We erroneously assumed that `docker start` returned the full container
id. It doesn't and as a result we populated DNS with records with ids
other than full container ids. And that's also what we told IPAM. As a
result, DNS and IPAM didn't clean up after the container's death,
resulting in stale DNS entries and leaked IPs.

Fixes #881.
2015-06-10 14:53:43 +01:00
Matthias Radestock 0ab7c31bbe Merge pull request #886 from bboreham/885-gossip-race
Avoid gossip test race conditions

Fixes #885.
2015-06-10 13:50:40 +01:00
Bryan Boreham 0cd4127087 Factor out GossipSender.flush() 2015-06-10 12:24:19 +01:00
Bryan Boreham 5ebfc9027b Flush gossip inside the channel lock so we know sender hasn't been Stop()-ed 2015-06-10 12:22:38 +01:00
Matthias Radestock fe6d05fccc Merge pull request #875 from paulbellamy/proxy-port
Add support for custom proxy bind address

Closes #805. Closes #810.
2015-06-10 12:19:41 +01:00
Bryan Boreham 35b3a2d6a6 Inline GossipSender.flush() and don't try to send nil 2015-06-10 12:18:09 +01:00
Paul Bellamy 6bb087cecd [proxy] Renaming flags: -H -> -D, -L -> -H
As per discussion in issue 875
2015-06-10 12:13:52 +01:00
Paul Bellamy 447a00ba7e [proxy] Add support for tcp:// prefix on listen addresses 2015-06-10 12:13:52 +01:00
Paul Bellamy 0da9669e5c [proxy] removing unneeded port expose 2015-06-10 12:13:51 +01:00
Paul Bellamy 4a7d4d3555 [proxy] documenting -L option 2015-06-10 12:13:51 +01:00
Paul Bellamy 1ac5d4fe98 renaming dns_restart_test so it is picked up by test runner 2015-06-10 11:52:58 +01:00
Bryan Boreham bd5353024f Helpful suggestions from the linter 2015-06-10 11:05:04 +01:00
Bryan Boreham 569fd784fa Make flushing of GossipSender wait till done in tests,
and take extra locks to avoid race conditions.
Also removed the sendPendingGossip() from mockChannelConnection.SendProtocolMsg(),
because waiting in flush now creates a deadlock.  Tests will have to
call sendPendingGossip() explicitly if they need it.
2015-06-10 10:59:54 +01:00
Matthias Radestock fbf2208e80 simplify fragmentation test
This is how fragmentation tests used to happen:

    A: conn.stackFrag = false
    A->B: StartFragmentationTest
    B->A: send large non-DF UDP packet
    A->B: FragmentationReceived
    B: conn.stackFrag = true

conn.stackFrag = true means "UDP packets sent to the other peer get
correctly fragmented and re-assembled".

Note how A clears its own stackFrag flag, but the test establishes
whether fragmentation works for B->A, and ends up setting stackFrag on
B. Not only is this weird, it also means that if A previously had
stackFrag=true, it will now start fragmenting packets until B
initiates a fragmentation test.

The new sequence is:

    A: conn.stackFrag = false
    A->B: send large non-DF UDP packet
    B->A: FragmentationReceived
    A: conn.stackFrag = true

Closes #746.
2015-06-10 07:41:37 +01:00
Matthias Radestock bd364f787e fix silent failure in assert_dns_record test
If the name cannot be resolved, getent fails, which in turn causes
assert_dns_record to just return with a non-zero status at that point,
which causes the whole test to just terminate with a non-zero status,
but no indication whatsoever what had gone wrong.
2015-06-09 19:08:59 +01:00
Matthias Radestock ca133d6d9b Call LocalPeer.Encode, not Peer.Encode!
We need the former's locking.

Fixes #883.
2015-06-09 17:19:36 +01:00
Matthias Radestock 94f18f7004 remove outdated comment 2015-06-09 15:52:15 +01:00
Paul Bellamy e324c15b04 Merge pull request #879 from rade/proxy_interceptor_refactor
Proxy interceptor refactor
2015-06-09 14:50:54 +01:00
Matthias Radestock 5c70c7c71a simplify interceptor structs by referencing proxy 2015-06-09 14:45:50 +01:00
Matthias Radestock 020a9ea396 rename file 2015-06-09 14:45:50 +01:00
Matthias Radestock 3f9c7a5c00 remove pointless indirection 2015-06-09 14:45:50 +01:00
Matthias Radestock f025b6ea36 refactor interceptor invocation 2015-06-09 14:45:42 +01:00
Paul Bellamy 03fa95fcb5 Merge pull request #878 from rade/877_remove_proxy_status
remove most of proxy status
2015-06-09 14:24:53 +01:00
Matthias Radestock fee2898c05 remove detailed proxy status
There are two problems with obtaining the proxy status via the normal
proxy endpoint...

1. when TLS is enabled, this requires using TLS at the client end

2. the status URL is mixed in with the docker remote API, which is
rather unclean

There is limited value to having some status output from the proxy,
since all the output is constant.

So instead we log the version and command line args, and in `weave
status` only report whether the proxy is running.

We still want a way to wait for the proxy to start up, and log a nice
error if it dies. We do this by polling the docker logs for a startup
message.

Fixes #877. Fixes #876.

Undoes most of #756, #800, #854.
2015-06-09 14:03:52 +01:00
Matthias Radestock 2d70197221 cosmetic: more formal command grammar 2015-06-08 23:57:53 +01:00
Matthias Radestock f9c325c793 refactor: more sensible field order 2015-06-08 21:57:49 +01:00
Matthias Radestock a4b323c5df mention docker logs weavedns for debugging 2015-06-08 18:39:26 +01:00
Fintan Ryan 365edac5d5 Update strapline 2015-06-08 18:37:51 +01:00
Adam Harrison 89cf5939b8 Merge branch '0.11.2' into latest_release_doc_updates 2015-06-08 17:59:55 +01:00
David Kaltschmidt b7f69c77f1 [site] header markup needs change after refactor
due to change in stylesheet in website repo

this change does not affect current deployment, but has to be deployed
when the website is deployed again
2015-06-08 15:09:04 +01:00
Ilya Dmitrichenko 235acc16f6 Merge pull request #874 from weaveworks/header-markup-refactor
[site] header markup needs change after refactor
2015-06-08 15:07:08 +01:00
Bryan Boreham 011c86fdca Merge pull request #852 from rade/816_make_launch_args_order_insensitive
LGTM. Fixes #816
2015-06-08 14:34:46 +01:00
Alvaro Saurin bb3dd55a10 Merge branch '0.11'
Conflicts:
	nameserver/cache_test.go
2015-06-08 13:41:38 +02:00
Matthias Radestock 3f274d02ce make weave launch args insensitive to order
Fixes #816.
2015-06-08 12:41:26 +01:00
David Kaltschmidt f65e02477e [site] header markup needs change after refactor
due to change in stylesheet in website repo

this change does not affect current deployment, but has to be deployed
when the website is deployed again
2015-06-08 13:19:58 +02:00
Matthias Radestock 8a5725fa74 correct docs for proxy's -H 2015-06-08 10:26:21 +01:00
Adam Harrison 0df28f58df Merge pull request #849 from inercia/weave-fix-neg-ttl
Do not overwrite negLocal entries in the cache
2015-06-08 09:59:32 +01:00
Matthias Radestock 9d707b9670 add proxy troubleshooting docs
Closes #854.
2015-06-07 13:32:02 +01:00
Matthias Radestock ad92bbc8c8 get rid of proxy 'Advantages' section
instead point out the main purpose right at the top, and list further
benefits in the 'Usage'.

Also, expand docs on configuring the listener.
2015-06-06 23:57:20 +01:00
Matthias Radestock e1ba892827 go back to using the tcp:// prefix in DOCKER_HOST
seems to be the recommended way
2015-06-06 23:54:46 +01:00
Matthias Radestock 4012b3c011 raise profile of proxy 2015-06-06 23:20:56 +01:00
Matthias Radestock 897f625db9 substantial reworking of the proxy TLS docs 2015-06-06 23:08:08 +01:00
Matthias Radestock 33c03e00e4 rewrite proxy dns docs, and add a complete multi-host example 2015-06-06 21:34:26 +01:00
Matthias Radestock 03ede29e7e ditch proxy 'Limitations' section 2015-06-06 21:22:09 +01:00
Matthias Radestock 4ea451378e cosmetic 2015-06-06 21:18:57 +01:00
Matthias Radestock 542f966dcd typo 2015-06-06 21:14:44 +01:00
Matthias Radestock 198b7db463 simplify examples - don't specify a command on container start 2015-06-06 21:13:46 +01:00
Matthias Radestock b22fbd3734 expand proxy setup documentation 2015-06-06 21:11:39 +01:00
Matthias Radestock 06716ba132 rewrite proxy ipam docs 2015-06-06 16:57:50 +01:00
Matthias Radestock 52509087a7 cosmetic 2015-06-06 16:19:44 +01:00
Matthias Radestock 7e88302d01 mention docker logs weavedns for debugging 2015-06-06 16:17:24 +01:00
David Kaltschmidt 6bf0feeffc Wrapping content area to allow for sticky footer 2015-06-05 16:46:29 +01:00
Ilya Dmitrichenko e7f02c954c Merge pull request #866 from weaveworks/fix-doc-layout
Fix doc layout
2015-06-05 16:44:18 +01:00
David Kaltschmidt cdcd37e15a Wrapping content area to allow for sticky footer 2015-06-05 17:36:30 +02:00
Alvaro Saurin 8b5df952c9 Do not overwrite negLocal entries in the cache
Unit tests
2015-06-05 16:31:57 +02:00
Paul Bellamy 525b7c8eeb Merge pull request #853 from rade/847_option_to_disable_peer_discovery
introduce '-nodiscovery' option to disable automatic peer discovery
2015-06-05 15:31:51 +01:00
Matthias Radestock 8f85a07ecc introduce '-nodiscovery' option to disable automatic peer discovery
Closes #847.
2015-06-05 15:13:48 +01:00
Paul Bellamy 5f5c0079d3 Merge pull request #863 from rade/onoff
introduce OnOff helper, for consistency in status output
2015-06-05 15:05:24 +01:00
Matthias Radestock c10f1dacad introduce OnOff helper, for consistency in status output 2015-06-05 15:00:02 +01:00
Michael Bridgen 1c14660ed5 Merge pull request #859 from weaveworks/website_39_again
Update strapline
2015-06-05 14:51:30 +01:00
Matthias Radestock 87e30d8382 Merge pull request #815 from paulbellamy/proxy-ssl
Proxy TLS Support

Closes #506.
2015-06-05 14:48:54 +01:00
Paul Bellamy edeb531940 [docs] rewording proxy TLS docs 2015-06-05 14:35:00 +01:00
Paul Bellamy 14cc33c512 reordering args to launch-proxy docker command 2015-06-05 14:10:38 +01:00
Paul Bellamy bddf79855d [proxy] refactor tls arg parsing 2015-06-05 13:59:30 +01:00
Fintan Ryan 124d98246b Update strapline 2015-06-05 13:51:03 +01:00
Paul Bellamy 127cffba6f [proxy] add TLS to /status 2015-06-05 13:38:55 +01:00
Matthias Radestock 3e8813e559 Merge pull request #858 from weaveworks/0.11
Respect `DOCKER_CLIENT_ARGS` in `weave run`
2015-06-05 13:36:27 +01:00
Matthias Radestock 4fc0671d0d Merge pull request #857 from weaveworks/weave-run-client-args-855
Respect `DOCKER_CLIENT_ARGS` in `weave run` (close #855)
2015-06-05 13:28:20 +01:00
Ilya Dmitrichenko e1537000c2 Respect DOCKER_CLIENT_ARGS in weave run (close #855) 2015-06-05 13:24:05 +01:00
Paul Bellamy b8595b9062 [proxy] cleaner default args 2015-06-05 13:23:15 +01:00
Paul Bellamy fa6707effa [docs] adding paragraph about docker listening on unix socket for proxy 2015-06-05 13:23:15 +01:00
Paul Bellamy a1ffbb528c adding documentation on using the proxy with tls 2015-06-05 13:23:14 +01:00
Paul Bellamy c0cf9e509c [proxy] Added proxy.Config struct for initialization 2015-06-05 13:23:14 +01:00
Paul Bellamy c31358259f [proxy] Add tls support
Caveats:
* TLS files must be present on the target server (and readable)
* TLS file paths cannot contain spaces
* TLS file paths must be absolute (i.e. cannot be relative)
* Bash argument parsing is terrible
2015-06-05 13:23:14 +01:00
Matthias Radestock 8514172e57 explain meaning of 'Encryption' line in weave status output 2015-06-05 11:27:38 +01:00
Matthias Radestock 3a0a8ba939 cosmetic 2015-06-05 10:31:34 +01:00
Matthias Radestock 16410d6014 refactor: make encryption status part of router status 2015-06-05 10:05:17 +01:00
Matthias Radestock 34e3f0ba3f refactor: simplify topology gossip gob decoder initialisation
Should be more efficient too due to less copying.
2015-06-05 07:39:34 +01:00
Matthias Radestock 62ee70f388 recommend strong password
Closes #641.
2015-06-04 15:19:47 +01:00
Matthias Radestock 441e58e422 excise reference to crypto implementation from main docs
It's too scary for the uninitiated.
2015-06-04 15:19:37 +01:00
Paul Bellamy c917b261f7 Capitalizing and standardizing titles of pages in the docs.
Also re-wording to make them match the page title.
2015-06-04 15:19:26 +01:00
Paul Bellamy d3daaf32f9 [docs] re-ordering proxy doc sections 2015-06-04 15:19:13 +01:00
Bryan Boreham 62bbaf57a2 Merge pull request #839 from rade/837_tcp_accept_delay
LGTM. Closes #837
2015-06-04 14:29:58 +01:00
Bryan Boreham 7acb4be13f Merge pull request #844 from rade/641_recommend_strong_password
LGTM. Closes #641
2015-06-04 14:28:22 +01:00
Matthias Radestock 044992eea0 limit acceptance rate on peer connections
The main purpose of this is to set an upper bound on the rate at which
an attacker might execute a brute force attack on the weave password.

No need to get clever or precise here.

Closes #837.
2015-06-04 14:21:35 +01:00
Bryan Boreham 2a244e5699 Simplify paxos.Consensus() call 2015-06-04 13:30:15 +01:00
Fintan Ryan bee5c300db Docs look and feel update 2015-06-04 12:36:13 +01:00
Matthias Radestock e31233c473 recommend strong password
Closes #641.
2015-06-03 18:15:32 +01:00
Matthias Radestock 720fdf714c excise reference to crypto implementation from main docs
It's too scary for the uninitiated.
2015-06-03 18:10:38 +01:00
Paul Bellamy 6f9c0d6cde Merge pull request #834 from weaveworks/docs_lookandfeel
Docs look and feel update
2015-06-03 17:29:29 +01:00
Paul Bellamy a7782359b1 Merge pull request #838 from paulbellamy/docs-capitals
Capitalizing and standardizing titles of pages in the docs.
2015-06-03 16:29:37 +01:00
Fintan Ryan e96a22bd6d Docs look and feel update 2015-06-03 16:04:01 +01:00
Paul Bellamy a957ed253c Capitalizing and standardizing titles of pages in the docs.
Also re-wording to make them match the page title.
2015-06-03 15:59:40 +01:00
Matthias Radestock dc8a82e913 cosmetic: consistency in launchers 2015-06-03 14:22:20 +01:00
Bryan Boreham c1f8b62e11 Merge pull request #832 from rade/412_min_backoff
LGTM. Fixes #412
2015-06-03 12:47:07 +01:00
Paul Bellamy c91e699a27 Merge pull request #831 from rade/192_kill_container_on_network_config_error
kill container on network config error
2015-06-03 12:45:23 +01:00
Adam Harrison 4a8850afb3 Fix comment 2015-06-03 12:08:13 +01:00
Matthias Radestock d1c41a97b1 encapsulate retry delay calculation 2015-06-03 12:04:33 +01:00
Matthias Radestock fe5102580d fix connection retry delay calculation logic
The delay d(n) for the nth retry was
d(1) = rand(initial_interval)
d(n+1) = d(n) + rand(d(n))

There are two problem with this:

1) The entire sequence is dominated by the random value for d(1). If
this is a small value, lots of retries at short interval ensue. In
extremis, if d(1) is 0, indefinite immediate retries would ensue.

2) The delay is not a true exponential backoff; the upper bound only
increases exponentially *probabilistically*.

The new algorithm calculates

d(n) = random_value in range [i-i/2,i+i/2],
       where i = initial_interval * 1.5^(n-1).

Thus d(1) is at least initial_interval/2, and successive values are
independent of previous values, forming a true exponential sequence of
intervals bounds between which the retry delay is chosen randomly.

Due to the change in algorithm we reduce...

- the initial interval from 5s to 2s. Recall that previously d(1) was
  in the range [0,initial_interval=5s]. It is now [2-2/2=1s,2+2/2=3s].

- the max interval from 10 minutes to 6. Previously, once that was
  reached, it would stay exactly there. It is now randomly chosen in
  the range [6-6/2=3m,6+6/2=9min].

Thus previously delays would range from 0 to 10 minutes, now they
range from 1s to 9 minutes.

Fixes #412.
2015-06-03 11:29:55 +01:00
Matthias Radestock d909a86fb0 Merge pull request #828 from rade/666_no_timeout_on_wait_for_status
no timeout on wait for status

Fixes #666.
2015-06-03 11:20:37 +01:00
Matthias Radestock 4e68bde7b5 don't time out waiting for weave infrastructure containers to start
instead keep trying, until we succeed or the container dies

Fixes #666.
2015-06-03 11:19:51 +01:00
Matthias Radestock 52f31f0596 Merge pull request #830 from rade/829_fix_container_death_check
kill -0 $CONTAINER_PID does not work inside weaveexec container

Fixes #829.
2015-06-03 11:17:23 +01:00
Matthias Radestock fa8b77b060 kill -0 $CONTAINER_PID does not work inside weaveexec container
since $CONTAINER_PID is in a different process namespace.

Fixes #829.
2015-06-03 11:16:08 +01:00
Matthias Radestock 83fe4e59f6 kill container on network config error
but only if we have just started it; killing other containers, e.g. on
`weave attach`, would be rather impolite.

Closes #192.
2015-06-02 20:26:20 +01:00
Matthias Radestock 8de1ddd255 cosmetic 2015-06-02 20:21:56 +01:00
Matthias Radestock 395aea28c6 cosmetic 2015-06-02 20:16:25 +01:00
Matthias Radestock 5e7d1cd0eb Merge remote-tracking branch 'upstream/master' 2015-06-02 18:46:30 +01:00
Michael Bridgen 3344e45a9f Merge pull request #825 from squaremo/discover_ipam_ip
Allow lookup of IPAM-allocated addresses
2015-06-02 18:04:11 +01:00
Matthias Radestock d020999e82 cosmetic: more sensible function order 2015-06-02 17:52:39 +01:00
Matthias Radestock d105d255ca Merge pull request #824 from paulbellamy/weavewait-race-condition
[proxy] We can only rely on receiving a signal when we are a container

This got broken in #820.
2015-06-02 17:39:28 +01:00
Michael Bridgen 791584d9f3 Allow lookup of IPAM-allocated addresses 2015-06-02 17:31:25 +01:00
Matthias Radestock 48b54ef722 cosmetic: consistency 2015-06-02 17:25:56 +01:00
Paul Bellamy e2447721eb [proxy] We can only rely on receiving a signal when we are a container
Due to https://github.com/docker/docker/issues/9098, there is no way to
signal an exec. Instead we'll have to just poll the interface and hope.

Adds `weavewait -s` which is the way to tell weavewait to skip waiting
for a signal, which we use on execs
2015-06-02 17:21:41 +01:00
Bryan Boreham 89074715bc Merge pull request #823 from bboreham/818-claim-no-trunc
Fixes #818
2015-06-02 16:12:47 +01:00
Bryan Boreham 4968f0f3c4 Merge pull request #822 from bboreham/802-test-race
Fix race condition in allocator fuzz-test - fixes #802
2015-06-02 16:12:22 +01:00
Bryan Boreham aa7c7a9a9d Add --no-trunc flag to docker ps for ipam_claim 2015-06-02 16:07:48 +01:00
Bryan Boreham 6a1b658f59 Fix race condition in allocator fuzz-test
It was possible to free an address between deciding to re-test it
and actually re-testing it.  So introduced a flag 'block' to prevent
an address from being freed during the re-test.
2015-06-02 16:04:35 +01:00
Matthias Radestock e2805c01f4 cosmetic: remove stray trailing whitespace 2015-06-02 15:57:50 +01:00
Matthias Radestock 04c10233f7 Merge pull request #820 from paulbellamy/weavewait-race-condition
Use USR2 signal to tell weavewait when to continue

Fixes #812.
2015-06-02 15:52:22 +01:00
Paul Bellamy 92444a75eb [proxy] Use USR2 signal to tell weavewait when to continue
There was a race condition with containers running and exiting before
`weave attach` was finished, which would cause an error.
2015-06-02 15:48:49 +01:00
Paul Bellamy cb92e6b0d2 Merge pull request #817 from rade/420_move_exe_image_to_subdir
move exe and docker image producing dirs to subdir
2015-06-02 14:18:49 +01:00
Matthias Radestock 5b04efac7c move weaver 2015-06-02 14:04:02 +01:00
Matthias Radestock 485db6e48b move weavedns 2015-06-02 13:51:19 +01:00
Matthias Radestock ee28cf91e1 move weaveexec 2015-06-02 13:46:02 +01:00
Matthias Radestock 8d4a97fed5 move sigproxy, weaveproxy, weavewait 2015-06-02 13:19:16 +01:00
Matthias Radestock 46ef954057 cosmetic: rename: trains station 2015-06-02 12:58:09 +01:00
Paul Bellamy f28fe80861 Merge pull request #814 from weaveworks/revert-813-proxy-ssl
Revert "First pass at Proxy SSL Support"
2015-06-02 12:49:08 +01:00
Paul Bellamy 91375a1095 Revert "First pass at Proxy SSL Support" 2015-06-02 12:48:38 +01:00
Paul Bellamy 3586ddcd63 Merge pull request #813 from paulbellamy/proxy-ssl
First pass at Proxy SSL Support
2015-06-02 12:48:31 +01:00
Matthias Radestock fca02eb489 Merge pull request #706 from awh/dns_delete_individual_records
delete individual dns records

Closes #631. Closes #654.
2015-06-02 12:35:50 +01:00
Adam Harrison 56160e0798 Merge pull request #728 from paulbellamy/test-runner
allow test/run_all.sh to run specific test files
2015-06-02 12:30:15 +01:00
Matthias Radestock 0b72338400 Merge remote-tracking branch 'upstream/master' 2015-06-02 11:58:38 +01:00
Matthias Radestock cc1a5548af reduce smoke test noise 2015-06-02 11:57:49 +01:00
Matthias Radestock a8b8a0948f cosmetic(ish): banish double bracket bashism 2015-06-02 11:56:27 +01:00
Paul Bellamy e7f73900cb allow test/run_all.sh to run specific test files 2015-06-02 11:45:43 +01:00
Paul Bellamy 927d40f47f Correctly building the client cert subjectAltNames
Still haven't managed to try it due to:
https://github.com/docker/docker/issues/8943
2015-06-02 11:34:54 +01:00
Matthias Radestock 294aafde14 cosmetic: s/when_has_fqdn/with_container_fqdn 2015-06-02 10:52:58 +01:00
Matthias Radestock dcedf241bb simplify dns-add/remove 2015-06-02 10:52:58 +01:00
Matthias Radestock bf8e82ba16 refactor: get rid of with_full_container_id 2015-06-02 10:52:58 +01:00
Paul Bellamy 79cc2d6d25 add note about not handling args with spaces for proxy tls files 2015-06-02 10:20:06 +01:00
Adam Harrison a4582fb529 Optimise DeleteRecords when explicit values are passed 2015-06-02 10:09:26 +01:00
Adam Harrison 30447ada52 Remove obsolete methods 2015-06-02 10:09:22 +01:00
Adam Harrison 66de361fd6 Smoketest dns-remove -h 2015-06-02 09:57:28 +01:00
Adam Harrison 9da5511484 Support -h argument to dns-remove 2015-06-02 09:57:28 +01:00
Adam Harrison e02bd8bb30 Add HTTP routes for wildcard deletion 2015-06-02 09:57:28 +01:00
Adam Harrison e21592d74f Add DeleteRecords method 2015-06-02 09:57:28 +01:00
Adam Harrison 5ead7eb020 Fix TTL breakage + cosmetic fixes 2015-06-02 09:42:59 +01:00
Adam Harrison 2a5f3f5b2d Merge pull request #737 from inercia/weave-cache-tests
WeaveDNS cache tests
2015-06-02 09:30:36 +01:00
Paul Bellamy d80ffa8ad2 working on bash argument parsing 2015-06-01 16:50:52 +01:00
Paul Bellamy 74afbc5505 Proof-of-Concept for proxy TLS support
The code is quite messy, but particularly the argument parsing and
volume-mounting. Also, it doesn't support args with spaces, or
non-absolute file-paths.
2015-06-01 16:50:52 +01:00
Paul Bellamy 4774043295 Add release 0.11.1 to CHANGELOG 2015-06-01 16:23:40 +01:00
Matthias Radestock 1237bfe840 cosmetic 2015-06-01 14:40:39 +01:00
Paul Bellamy c4fc2ecf09 Merge remote-tracking branch 'upstream/0.11' 2015-06-01 13:35:37 +01:00
Adam Harrison 59f919bda3 Merge pull request #795 from inercia/weave-711
Make the TTL configurable
2015-06-01 12:51:45 +01:00
Matthias Radestock 84c0daa000 remove out-of-date info from ipam docs 2015-06-01 12:41:39 +01:00
Matthias Radestock 415b9ead52 cosmetic 2015-06-01 12:41:32 +01:00
Matthias Radestock 7ccf650e48 cosmetic 2015-06-01 12:41:14 +01:00
Matthias Radestock a29831b7fa expand weavedns example to cover multi-host 2015-06-01 12:41:08 +01:00
Alex Chan 70dc8b027d Minor spelling corrections in docs 2015-06-01 12:41:00 +01:00
Paul Bellamy 4e1d388017 weave status should look for proxy at 127.0.0.1 (since PROXY_HOST is gone) 2015-06-01 12:21:58 +01:00
Matthias Radestock ac90086fb1 Merge pull request #808 from paulbellamy/proxy-short-docker-host
weave PROXY_HOST is always localhost, so just hardcode it as that

Closes #807.
2015-06-01 11:55:58 +01:00
Paul Bellamy bd94c00e96 weave PROXY_HOST is always localhost, so just hardcode it as that
Because launch-proxy runs in weaveexec container, DOCKER_HOST is never
set.
2015-06-01 11:51:32 +01:00
Bryan Boreham 2698f3f376 Merge remote-tracking branch 'upstream/0.11' 2015-06-01 11:42:30 +01:00
Matthias Radestock fd0aa3f6ae remove out-of-date info from ipam docs 2015-06-01 11:13:16 +01:00
Matthias Radestock b86ead2737 fix tests post 9a1e8c07ac 2015-05-31 13:11:28 +01:00
Matthias Radestock 21ee0fdcf7 Merge branch '0.11' 2015-05-31 11:54:54 +01:00
Matthias Radestock 8d0adb9359 refactor(ish): use full container id when we have it 2015-05-31 11:25:13 +01:00
Matthias Radestock 79eb4c298c refactor: extract helper for and simplify get_ipam_cidr 2015-05-31 09:59:32 +01:00
Matthias Radestock 6f57bcb477 tiny refactor - use full container id, since we happen to have it 2015-05-31 09:35:53 +01:00
Matthias Radestock 54dbc2f582 cosmetic 2015-05-31 09:03:45 +01:00
Matthias Radestock 1a8f2117b1 explain Direct Peers status 2015-05-29 17:35:21 +01:00
Matthias Radestock 59fd53ee99 Merge pull request #800 from paulbellamy/proxy-status
Add proxy info to 'weave status' output

Closes #756.
2015-05-29 17:13:33 +01:00
Matthias Radestock 8c27d469a1 add Direct Peers to status output example
This was missed in #764.
2015-05-29 17:05:34 +01:00
Paul Bellamy 7f62ba6ebe Add proxy info to './weave status' output 2015-05-29 17:05:25 +01:00
Matthias Radestock 9a1e8c07ac cosmetic: report direct peers on one line in status 2015-05-29 17:03:33 +01:00
Matthias Radestock b7df116491 make weave reset stop the proxy
Missed this in #790.
2015-05-29 16:43:18 +01:00
Paul Bellamy ece1fa1b1b Merge remote-tracking branch 'upstream/0.11' 2015-05-29 16:35:59 +01:00
Matthias Radestock 99b1e00a75 Merge pull request #794 from paulbellamy/connect-replace
add 'weave connect --replace ...'

Closes #658.
2015-05-29 15:52:32 +01:00
Matthias Radestock e0f4da4641 Merge pull request #792 from rade/720_auto_assigned_dns_http_test_port
use an automatically assigned port for http tests

Fixes #720.
2015-05-29 15:51:38 +01:00
Paul Bellamy 2be69634df replace proxy /weave endpoint with /status
which is more standard with others, and doesn't conflict with docker api
2015-05-29 15:48:33 +01:00
Paul Bellamy 858356de22 add 'weave connect --replace ...' 2015-05-29 15:44:45 +01:00
Matthias Radestock 08a17ec376 no need for sleeps to wait for http server
Since we start the tcp listener in the main thread now, connections
can be made immediately; they will just queue up until there is a
handler.
2015-05-29 14:17:03 +01:00
Matthias Radestock 3ad08c0f2a don't print the test port
it's of no interest whatsoever
2015-05-29 14:05:24 +01:00
Tom Wilkie 6e2bb075a6 Merge pull request #797 from weaveworks/timeout
Various fixes to circleci integration tests
2015-05-29 13:57:42 +01:00
Paul Bellamy 587a56cf31 Merge remote-tracking branch 'upstream/0.11'
Conflicts:
	weave
2015-05-29 13:37:21 +01:00
Tom Wilkie 0a945a04f3 Add smarter scheduler to decide which tests to run on which shard on circle. 2015-05-29 12:35:43 +00:00
Tom Wilkie 332a1bf58d Checkin the assert.sh script, so we can expose test run time. 2015-05-29 11:48:49 +00:00
Matthias Radestock fb721558af auto-assign port in ipam tests 2015-05-29 12:35:23 +01:00
Bryan Boreham 0ab2263a41 Merge pull request #793 from bboreham/ipam-avoid-unittest-races
[ipam] Fix race conditions in unit tests
2015-05-29 12:30:39 +01:00
Tom Wilkie 3642dc5514 Add some timeouts to the circle/gce tests. 2015-05-29 11:29:43 +00:00
Tom Wilkie 28781ef08c Don't pull weavebuild container from docker hub if you don't have a cached version, build it. 2015-05-29 11:28:58 +00:00
Alvaro Saurin 8a188e23d9 Documented the '--ttl' argument 2015-05-29 12:56:45 +02:00
Alvaro Saurin 343e9b1f5a Provide the '--neg-ttl' argument too... 2015-05-29 12:56:45 +02:00
Alvaro Saurin 858a6dd253 Make the TTL returned for local answers configurable. 2015-05-29 12:50:18 +02:00
Bryan Boreham adeb0d3934 Don't bypass the actor mechanism in unit tests, to avoid race conditions 2015-05-29 10:43:19 +01:00
Bryan Boreham 0ee872def4 Lock round mockGossipComms to avoid race conditions 2015-05-29 10:27:17 +01:00
Matthias Radestock c93e789b6b use an automatically assigned port for http tests
instead of random port, which can clash

Fixes #720.
2015-05-29 10:21:41 +01:00
Paul Bellamy db217cd56f Merge pull request #785 from rade/710_reduce_interface_check_interval
reduce interface availability check interval
2015-05-29 10:17:13 +01:00
Bryan Boreham 2befd9d473 Merge remote-tracking branch 'origin/0.11' 2015-05-29 09:56:53 +01:00
Paul Bellamy 22aa1f8fe3 Merge pull request #790 from rade/754_stop_proxy
add `weave stop_proxy`
2015-05-29 09:53:32 +01:00
Bryan Boreham e37f7de0ad Improve error reporting of too much free space 2015-05-29 09:44:24 +01:00
Bryan Boreham 72b30bc699 Fix incorrect calculation of free space
when granting a range that spans a token and inserting a new token, the
free space on the last token that we are handing over has to change.
Add unit test for this too.
2015-05-29 09:44:14 +01:00
Matthias Radestock e31f21a6d2 add weave stop_proxy
Closes #754.
2015-05-29 09:20:56 +01:00
Matthias Radestock c87da5e873 Merge pull request #789 from rade/784_status_fail
make `weave status` fail when weave isn't running

Closes #784.
2015-05-28 23:08:43 +01:00
Matthias Radestock b0633281a1 make weave status fail when weave isn't running
but still always show weavedns status, if present

Closes #784.
2015-05-28 21:41:56 +01:00
Matthias Radestock 8dcdf8d314 reduce interface availability check interval
in order to reduce container startup times

Closes #710.
2015-05-28 19:05:09 +01:00
Paul Bellamy e3e5934c51 Merge remote-tracking branch 'upstream/0.11'
Conflicts:
	proxy/common.go
2015-05-28 17:43:30 +01:00
Matthias Radestock 8dc5ae662a simplify dependencies
This isn't as precise, but these common dependencies rarely change.
2015-05-28 17:16:22 +01:00
Matthias Radestock ec6a251b7c fix dependencies 2015-05-28 17:10:42 +01:00
Adam Harrison ed133dfe0d Merge pull request #773 from inercia/weave-restore-fallback
Restore the "--fallback" argument in WeaveDNS
2015-05-28 16:12:54 +01:00
Matthias Radestock 374b4c523c cosmetic: remove some more dead code 2015-05-28 15:24:51 +01:00
Matthias Radestock 9c71f7f1e9 cosmetic: remove some more dead code 2015-05-28 15:23:34 +01:00
Matthias Radestock ba064a906e cosmetic: remove dead code 2015-05-28 15:17:20 +01:00
Alvaro 5c1297d560 Merge pull request #775 from rade/736_load_balancing_example
add load balancing example
2015-05-28 16:01:55 +02:00
Matthias Radestock 323229dacf add load balancing example
Closes #736.
2015-05-28 14:58:04 +01:00
Matthias Radestock 0b48ea01d7 cosmetic 2015-05-28 14:48:08 +01:00
Matthias Radestock 54d34ea796 expand weavedns example to cover multi-host 2015-05-28 13:36:32 +01:00
Matthias Radestock ccd7153b9d refactor: remove excessive escaping 2015-05-28 12:29:58 +01:00
Paul Bellamy 4f89ad2342 Merge pull request #769 from rade/768_shorten_proxy_entrypoint
shorten proxy entrypoint
2015-05-28 12:16:24 +01:00
Matthias Radestock 0ed1ef1600 Merge pull request #764 from paulbellamy/status-connection-maker
Add "Direct Peers" to weave status

Closes #659. Closes #660.
2015-05-28 12:02:47 +01:00
Alvaro Saurin 7202f7e1d6 Restored "fallback" argument for forcing a fallback server (used for testing/debugging) 2015-05-28 12:57:24 +02:00
Paul Bellamy 998130fa9e Reformatting connection maker target JSON output
So `LastError` is forced to a string, not an object.
2015-05-28 11:49:46 +01:00
Paul Bellamy 637215fcff add status of connection-maker to status-json 2015-05-28 11:49:46 +01:00
Paul Bellamy d16395b8b9 weave status should include 'Direct Peers' set with 'weave connect' 2015-05-28 11:49:46 +01:00
Adam Harrison e110a8ab9c Fix erroneous use of nil value 2015-05-28 10:23:02 +01:00
Bryan Boreham cb03d1d763 Merge pull request #772 from alexwlchan/master
Thanks!
2015-05-28 10:11:58 +01:00
Alex Chan 2a1150b74e Minor spelling corrections in docs 2015-05-28 10:10:16 +01:00
Alvaro Saurin 91cbd75f92 Unit test for cache expirations 2015-05-28 11:09:07 +02:00
Alvaro Saurin 156f5be4d4 Unit test for cache invalidations as a result of AddRecord()/DeleteRecord()/etc... 2015-05-28 11:09:07 +02:00
Adam Harrison 037b6df385 Merge pull request #761 from inercia/weave-583-2
Background updates for names in the Zone database. Fixes #226.
2015-05-28 10:00:32 +01:00
Alvaro Saurin 0a803c61ff Smoke tests 2015-05-28 10:05:22 +02:00
Alvaro Saurin b8d4068a26 Force 8.8.8.8 as the DNS server in VirtualBoxes 2015-05-28 10:05:22 +02:00
Alvaro Saurin 6d2317d60e Silence "golint" errors
Silence "go vet" errors
Run goimports
2015-05-28 10:05:22 +02:00
Alvaro Saurin 40d7b2a87d Dump the zone database status on "weave status"
Fix the smoke test by updating the regexps used for parsing "weave status" output
2015-05-28 09:12:53 +02:00
Alvaro Saurin 32627eccbf Fix the timeout for the fallback server client connection 2015-05-28 09:12:53 +02:00
Matthias Radestock fc9475592d shorten proxy entrypoint
...so that the default output of the likes of `docker ps` shows some
of the real entrypoint/command.

Closes #768.
2015-05-28 06:35:10 +01:00
Matthias Radestock e950d37ed2 cosmetic: reduce noise 2015-05-28 06:31:05 +01:00
Matthias Radestock 5e0d1e6036 refactor: add some lists
in order to reduce likelihood of adding an item in one place and
forgetting to do so in another.
2015-05-27 19:04:39 +01:00
Matthias Radestock 7fc51a508a cosmetic: consistency 2015-05-27 18:28:16 +01:00
Matthias Radestock cd6ba31cfa add weavewait to 'make update' target 2015-05-27 18:27:56 +01:00
Paul Bellamy ce2e80d861 fixing build on master (broken by 68ef0e) 2015-05-27 17:37:13 +01:00
Matthias Radestock a27516b0bf Merge pull request #765 from rade/run_linter_on_travis
Run linter on travis
2015-05-27 17:31:12 +01:00
Matthias Radestock 4dc2ee034c run linter on travis 2015-05-27 17:27:22 +01:00
Matthias Radestock d68dd39839 build all exes 2015-05-27 17:22:56 +01:00
Bryan Boreham b10c2e554c Remove redundant variable 2015-05-27 16:59:12 +01:00
Matthias Radestock ac8d7a5c55 cosmetic: this is somewhat gross, but the last barrier to linter bliss 2015-05-27 16:58:12 +01:00
Matthias Radestock 68ef0e845a cosmetic: yet more linter happiness 2015-05-27 16:56:38 +01:00
Matthias Radestock c6604a6442 cosmetic: more linter happiness 2015-05-27 16:52:08 +01:00
Matthias Radestock 5920927a52 make the linter (almost) happy with ipam 2015-05-27 16:43:18 +01:00
David Wragg e30ab8abba Reduce obfuscation 2015-05-27 14:50:06 +01:00
Matthias Radestock cee6ea6762 cosmetic: it has been decreed that this was "just silly" 2015-05-27 14:18:22 +01:00
Matthias Radestock 84874b9676 cosmetic: more consistency - then on same line as if 2015-05-27 14:14:51 +01:00
Matthias Radestock f281eeb02a cosmetic: missed one 2015-05-27 13:59:09 +01:00
Alvaro Saurin 6f7e385c74 Unit tests for multiple IPs through the HTTP API 2015-05-27 14:54:30 +02:00
Alvaro Saurin 954c5cb394 Limit the number of answers we provide to users. 2015-05-27 14:54:29 +02:00
Paul Bellamy b9d666d4a5 Merge branch '0.11' 2015-05-27 13:52:13 +01:00
Matthias Radestock 09feb0c53a Merge pull request #697 from paulbellamy/peer-replacement
weave connect/forget take multiple peers

Closes #759.
2015-05-27 13:39:50 +01:00
Matthias Radestock de27c465ca cosmetic: remove stray semicolon 2015-05-27 13:24:53 +01:00
Matthias Radestock dd33c94188 cosmetic: semicolon shall always be preceded by a space 2015-05-27 13:23:34 +01:00
Matthias Radestock 901f0bf04e cosmetic: replace all implict $@s 2015-05-27 13:20:51 +01:00
Matthias Radestock cfbd9dc310 Merge pull request #748 from dpw/gossip-channel-names
Make gossip use channel names on the wire, not channel name hashes

Closes #745.
2015-05-27 13:03:05 +01:00
David Wragg 530a39350b Make gossip use channel names on the wire, not channel name hashes 2015-05-27 12:51:14 +01:00
Alvaro Saurin 2d919d0a5f Remove duplicates in answers 2015-05-26 21:27:53 +02:00
Alvaro Saurin c4b07fd44e Shuffle all the replies, not only the ones from the cache... 2015-05-26 21:24:28 +02:00
Alvaro Saurin b87b942363 Check we can use our mDNS client with our mDNS server 2015-05-26 21:24:26 +02:00
Alvaro Saurin 5fe0a7fbb2 Make Stop() idempotent 2015-05-26 21:20:44 +02:00
Alvaro Saurin a159ac44d9 Unit tests for cache invalidations as a result of names updates 2015-05-26 21:20:44 +02:00
Alvaro Saurin 836d012459 Command line arg for changing the number of background updaters
Default number of background updaters raised to 4
2015-05-26 21:20:44 +02:00
Alvaro Saurin 07d15092aa Do not invoke the mDNS lookups from the server: they are used from the Zone database now...
Improved DNS server:
- simplify the handlers code, removing duplicated code
- more configuration parameters (eg, we can now disable the cache)
- we can now bind to port 0 and let the server get a free port (so we can get rid of the mess we had in the unit tests...)
2015-05-26 21:20:42 +02:00
Alvaro Saurin a23462e830 Command line option for disabling the cache 2015-05-26 21:17:24 +02:00
Alvaro Saurin 6fc6afa6a7 Unit tests for the zone lookups and names updates 2015-05-26 21:17:24 +02:00
Alvaro Saurin 64090d0b95 Improved mocks 2015-05-26 21:17:24 +02:00
Alvaro Saurin dbce56ed30 Background updates for names 2015-05-26 21:17:21 +02:00
Alvaro Saurin ea808bd08b Domain lookups, using mDNS
Added DomainLookup* to the Zone interface
2015-05-26 21:14:09 +02:00
Alvaro Saurin da2d66a6df New zone database 2015-05-26 21:14:06 +02:00
Alvaro Saurin c1d124df4c Interfaces for the mDNS client and server 2015-05-26 21:11:34 +02:00
Paul Bellamy dafe2bbc83 adding basic connect/forget test
The test for multiple connect/forget options is not amazing, because we
only have 2 test VMs to connect to each other
2015-05-26 14:37:22 +01:00
Paul Bellamy b392a7d24d weave connect should be best-effort, and return errors for any fails 2015-05-26 14:37:22 +01:00
Paul Bellamy d18640fc8c use @dpw's shell join, and remove non-posix 'local' 2015-05-26 14:37:22 +01:00
Paul Bellamy 781686ee4a weave connect/forget take multiple peers 2015-05-26 14:37:22 +01:00
454 changed files with 35199 additions and 13696 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
--ignore-dir=vendor
--ignore-dir=.pkg
+38 -15
View File
@@ -25,25 +25,48 @@ _testmain.go
*.prof
profile.cov
coverage.html
.pkg
# Emacs backup files
*~
# Vim backup files
*.swp
# Project specific
weaver/weaver
weavedns/weavedns
weaveproxy/weaveproxy
sigproxy/sigproxy
weavewait/weavewait
tools/bin
tools/build
prog/weaver/weaver
prog/weavedns/weavedns
prog/weavehosts/weavehosts
prog/weaveproxy/weaveproxy
prog/sigproxy/sigproxy
prog/weavewait/weavewait
prog/weavewait/weavewait_noop
prog/weavewait/weavewait_nomcast
prog/weaveutil/weaveutil
prog/*/Dockerfile.weaveworks
prog/kube-peers/kube-peers
prog/weave-kube/kube-peers
prog/weave-npc/weave-npc
prog/plugin/plugin
testing/cover/cover
testing/runner/runner
releases
weave.tar
weavedns.tar
weaveexec.tar
weaveexec/weave
weaveexec/weaveproxy
weaveexec/weavewait
weaveexec/sigproxy
weaveexec/docker*.tgz
.*.uptodate
weave*.tar.gz
prog/weaveexec/weave
prog/weaveexec/weavehosts
prog/weaveexec/weaveproxy
prog/weaveexec/weavewait
prog/weaveexec/weavewait_noop
prog/weaveexec/weavewait_nomcast
prog/weaveexec/sigproxy
prog/weaveexec/weaveutil
prog/weaveexec/docker*
Vagrantfile.local
test/tls/tls
test/tls/*.pem
test/coverage
test/coverage.*
*qemu-*-static
terraform.tfstate
terraform.tfstate.backup
+126
View File
@@ -0,0 +1,126 @@
[submodule "tools"]
path = tools
url = https://github.com/weaveworks/build-tools
[submodule "vendor/github.com/vishvananda/netlink"]
path = vendor/github.com/vishvananda/netlink
url = https://github.com/vishvananda/netlink.git
[submodule "vendor/github.com/gorilla/mux"]
path = vendor/github.com/gorilla/mux
url = https://github.com/gorilla/mux.git
[submodule "vendor/github.com/gorilla/context"]
path = vendor/github.com/gorilla/context
url = https://github.com/gorilla/context.git
[submodule "vendor/github.com/google/gopacket"]
path = vendor/github.com/google/gopacket
url = https://github.com/google/gopacket.git
[submodule "vendor/github.com/weaveworks/go-odp"]
path = vendor/github.com/weaveworks/go-odp
url = https://github.com/weaveworks/go-odp.git
[submodule "vendor/github.com/opencontainers/runc"]
path = vendor/github.com/opencontainers/runc
url = https://github.com/opencontainers/runc.git
[submodule "vendor/github.com/fsouza/go-dockerclient"]
path = vendor/github.com/fsouza/go-dockerclient
url = https://github.com/fsouza/go-dockerclient.git
[submodule "vendor/github.com/docker/libnetwork"]
path = vendor/github.com/docker/libnetwork
url = https://github.com/docker/libnetwork.git
[submodule "vendor/github.com/docker/docker"]
path = vendor/github.com/docker/docker
url = https://github.com/docker/docker.git
[submodule "vendor/github.com/Sirupsen/logrus"]
path = vendor/github.com/Sirupsen/logrus
url = https://github.com/Sirupsen/logrus.git
[submodule "vendor/github.com/andybalholm/go-bit"]
path = vendor/github.com/andybalholm/go-bit
url = https://github.com/andybalholm/go-bit.git
[submodule "vendor/github.com/miekg/dns"]
path = vendor/github.com/miekg/dns
url = https://github.com/miekg/dns.git
[submodule "vendor/github.com/stretchr/testify"]
path = vendor/github.com/stretchr/testify
url = https://github.com/stretchr/testify.git
[submodule "vendor/golang.org/x/crypto"]
path = vendor/golang.org/x/crypto
url = https://github.com/golang/crypto.git
[submodule "vendor/github.com/docker/machine"]
path = vendor/github.com/docker/machine
url = https://github.com/docker/machine.git
[submodule "vendor/github.com/weaveworks/mesh"]
path = vendor/github.com/weaveworks/mesh
url = https://github.com/weaveworks/mesh
[submodule "vendor/github.com/vishvananda/netns"]
path = vendor/github.com/vishvananda/netns
url = https://github.com/vishvananda/netns.git
[submodule "vendor/github.com/boltdb/bolt"]
path = vendor/github.com/boltdb/bolt
url = https://github.com/boltdb/bolt
[submodule "vendor/github.com/weaveworks/go-checkpoint"]
path = vendor/github.com/weaveworks/go-checkpoint
url = https://github.com/weaveworks/go-checkpoint
[submodule "vendor/github.com/hashicorp/go-cleanhttp"]
path = vendor/github.com/hashicorp/go-cleanhttp
url = http://github.com/hashicorp/go-cleanhttp
[submodule "vendor/github.com/appc/cni"]
path = vendor/github.com/appc/cni
url = https://github.com/appc/cni
[submodule "vendor/github.com/coreos/go-iptables"]
path = vendor/github.com/coreos/go-iptables
url = https://github.com/coreos/go-iptables
[submodule "vendor/github.com/pkg/profile"]
path = vendor/github.com/pkg/profile
url = https://github.com/pkg/profile
[submodule "vendor/github.com/j-keck/arping"]
path = vendor/github.com/j-keck/arping
url = https://github.com/j-keck/arping
[submodule "vendor/github.com/aws/aws-sdk-go"]
path = vendor/github.com/aws/aws-sdk-go
url = https://github.com/aws/aws-sdk-go
[submodule "vendor/golang.org/x/sys"]
path = vendor/golang.org/x/sys
url = https://go.googlesource.com/sys
[submodule "vendor/github.com/beorn7/perks"]
path = vendor/github.com/beorn7/perks
url = https://github.com/beorn7/perks
[submodule "vendor/github.com/prometheus/procfs"]
path = vendor/github.com/prometheus/procfs
url = https://github.com/prometheus/procfs
[submodule "vendor/github.com/prometheus/client_golang"]
path = vendor/github.com/prometheus/client_golang
url = https://github.com/prometheus/client_golang
[submodule "vendor/github.com/prometheus/client_model"]
path = vendor/github.com/prometheus/client_model
url = https://github.com/prometheus/client_model
[submodule "vendor/github.com/prometheus/common"]
path = vendor/github.com/prometheus/common
url = https://github.com/prometheus/common
[submodule "vendor/github.com/golang/protobuf"]
path = vendor/github.com/golang/protobuf
url = https://github.com/golang/protobuf
[submodule "vendor/github.com/matttproud/golang_protobuf_extensions"]
path = vendor/github.com/matttproud/golang_protobuf_extensions
url = https://github.com/matttproud/golang_protobuf_extensions
[submodule "vendor/k8s.io/client-go"]
path = vendor/k8s.io/client-go
url = https://github.com/kubernetes/client-go
[submodule "vendor/github.com/pkg/errors"]
path = vendor/github.com/pkg/errors
url = https://github.com/pkg/errors
[submodule "vendor/github.com/spf13/cobra"]
path = vendor/github.com/spf13/cobra
url = https://github.com/spf13/cobra
[submodule "vendor/github.com/spf13/plag"]
path = vendor/github.com/spf13/plag
url = https://github.com/spf13/pflag
[submodule "vendor/github.com/spf13/pflag"]
path = vendor/github.com/spf13/pflag
url = https://github.com/spf13/pflag
[submodule "vendor/github.com/mgutz/ansi"]
path = vendor/github.com/mgutz/ansi
url = https://github.com/mgutz/ansi
[submodule "vendor/github.com/estesp/manifest-tool"]
path = vendor/github.com/estesp/manifest-tool
url = https://github.com/estesp/manifest-tool
[submodule "vendor/github.com/weaveworks/common"]
path = vendor/github.com/weaveworks/common
url = https://github.com/weaveworks/common
+27
View File
@@ -0,0 +1,27 @@
# IMPORTANT: Please only use GLOBs to ignore files and directories.
# Do not lint the below bash scripts in Weave Net, in order to
# avoid breaking the build on make lint:
bin/circle-deploy-issues
bin/circle-deploy-master
bin/circle-teardown-pre
bin/circle-test-teardown
bin/circle-test-unit
bin/install-wordepress
bin/multiweave
bin/publish-site
bin/release
build/build.sh
prog/weave-kube/launch.sh
prog/weaveexec/symlink
test/*_test.sh
test/600_proxy_docker_py.sh
test/assert.sh
test/config.sh
test/gce.sh
test/gen_coverage_reports.sh
test/run_all.sh
test/sanity_check.sh
test/setup.sh
vendor/*.sh
weave
-28
View File
@@ -1,28 +0,0 @@
language: go
sudo: false
go:
- 1.4
env:
- PATH="${PATH}:${HOME}/.local/bin"
addons:
apt:
packages:
- libpcap-dev
install:
- go clean -i net
- go install -tags netgo std
- pip install --user --upgrade gcloud gsutil
- bin/setup-ci-secrets $encrypted_5ba036e89377_key $encrypted_5ba036e89377_iv
- make travis
script:
- bin/lint .
- make tests
after_success:
- go get github.com/mattn/goveralls
- $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci
- test "${TRAVIS_PULL_REQUEST}" = "false" && site/build-and-publish.sh
+522
View File
@@ -1,3 +1,525 @@
## Release 1.9.2
Bug fixes and minor improvements
* Fix a weave-kube bug when `br_netfilter` or `xt_set` module is compiled into
kernel #2820/#2821
* Detect the absence of the required `xt_set` kernel module #2821
## Release 1.9.1
Bug fixes and minor improvements
* Fix a race condition when the Weave Net container is restarted
which could allow a new container to be allocated the same IP
address as an existing one #2784,#2787
* Handle the message type received when a pod has been deleted during
Kubernetes api-server fail-over #2772,#2773
* Make weave-kube work with `dockerd --iptables=false` #2726
* Ensure we have the right kernel modules loaded for Network Policy in weave-kube #2819
* Reference-count addresses in Network Policy Controller, to avoid
errors when updates come in an unexpected order #2792,#2795
* Allow the soft connection limit to be raised in weave-kube, so
larger clusters can be created #2781
* WeaveDNS was incorrectly case-sensitive for reverse DNS lookups #2817,#2818
Build and Testing
* Scripts to create VMs to run automated tests were rewritten to use
Terraform and Ansible, to make it much easier to test with different
versions of components such as Docker and Kubernetes #2647,#2694,#2775,#2796
* Upgrade to latest Weaveworks common build-tools #2780
* Improve encryption tests #2793
* Update vishvananda/netlink library to bring in changes we had previously forked #2790
* Slight change to the build container to avoid permission errors and slow builds #2761,#2802
## Release 1.9.0
Highlights:
* Encryption is now available for Fast Datapath connections, which
greatly improves the performance. #1644,#2687
* We now build images for Intel/AMD 64-bit, ARM and ARM 64-bit. #2713
* Weave Net Docker images are now labelled with description, vendor, etc. #2712
* `weave status connections` now shows the MTU #2389,#2663
* CNI plugin is now a stand-alone binary that does not depend on Docker #2594,#2662
* Embedded docker client updated to version 1.10.3 #2395
**NOTE:** The move to multi-architecture required that we update the
embedded Docker client, and this has the effect that this release of
Weave Net will not work with Docker installations older than
1.10.
[Full list of changes](https://github.com/weaveworks/weave/issues?q=milestone%3A1.9.0).
## Release 1.8.2
Bug fixes and minor improvements
* Fixed a bug where looping flows were installed which caused high CPU
usage #2650, #2674
* Fixed a bug where Kubernetes master could not contact pods #2673, #2683
* Fixed a bug where weave-kube was crashing in a loop due to invalid
Weave bridge state #2657
* Fixed a bug where iptables NAT rules were not appended due to
"temporary unavailable" iptables error #2679
* Added a detection of enabling the hairpin mode on the Weave bridge port
which caused installation of looping flows #2674
* Added a detection of overlaps between Weave and the host IP address
ranges when launching weave-kube #2669, #2672
* Added logging of connections blocked by weave-npc #2546, #2573
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.8.2).
## Release 1.8.1
Bug fixes and minor improvements
* Fixed weave-npc crash from Succeeded/Failed pods #2632,#2658
* Fixed occasional failure to create Weave bridge on node reboot
#2617,#2637
* Fixed a bug where weave-kube would fail to install when run with
unrelease snapshot builds #2642
* Improved conformance to CNI spec by not releasing IP addresses when
a container dies #2643
* Improved troubleshooting of install failure by creating CNI config
after Weave Net is up #2570
* "up to date" shown even when the version check was blocked by
firewall #2537,#2565,#2645
* "Unable to claim" message on re-launching Weave after using CNI
#2548,#2577
* Eliminated spurious IP reclaim operations when IPAM was disabled
#2567,#2644
* Include `jq` tool in our build VM configuration #2656
## Release 1.8.0
Highlights:
* Exposed network policy controller Prometheus metrics
weaveworks/weave-npc#23, #2595, #2549
* Exposed router Prometheus metrics #2535, #2547, #2523, #2579, #2578,
#2568, #2560, #2561
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.8.0).
## Release 1.7.2
Bug fixes and minor improvements
* Fixed an error where the Docker plugin could fail to attach a
container with a `bridge "weave" not present` error #2540/#2541
* Fixed `cannot connect to itself` panic on weave launch #2527/#2543
* Fixed inferred initial peer count when target peers includes self
#2481/#2543
* Fixed compilation on Raspberry Pi #2506/#2538
## Release 1.7.1
Bug fixes and minor improvements
* Added utility to recover container addresses without asking Docker #2531
* Improved CI #2274
## Release 1.7.0
Highlights:
* weave-kube - Deploy Weave Net to Kubernetes with a single command
* weave-npc - Kubernetes network policy controller implementation
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.7.0).
## Release 1.6.2
Bug fixes and minor improvements
* Fixed hang after stopping and restarting on Docker 1.12 #2469/#2502
* Avoid an error on Google container images by checking for tx offload support #2504
* Fixed an issue where the supplied peer list could be ignored when restarting after failure #2503/#2509
* Check for empty peer name on launch #2495/#2501
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.6.2).
## Release 1.6.1
Bug fixes and minor improvements
* `weave ps` was occasionally failing to list allocated addresses of containers #2388/#2418/#2445
* `weave launch[-router]` on 4.2 kernel would appear to succeed even if the fast datapath VXLAN UDP port was in use by a different process #2375/#2474
* Launching the proxy would fail when the Docker daemon could not be detected #2457/#2424
* The CNI plugin did not work with Apache Mesos #2394/#2442
* Router stopped working after a restart in the AWSVPC mode #2381/#2409
* Router crashed when the Docker API endpoint parameter was explicitly set to empty #2421/#2467
* The CNI plugin did not work on recent versions of Docker for Mac #2434/#2442
* The CNI plugin assigns an IP to the bridge if necessary, which avoids failures if `weave expose` has not run yet #2471
* Distinguish peer name collisions from attempts to connect to self in logs #2460
* Improve host clock skew detection message #2174
* Improve the error message returned when executing `weave launch-plugin` without the router running #2293/#2416
* The `create-bridge` subcommand was not enabled in the fast datapath mode #2464/2466
* Allow users to omit `weave setup[-cni]` by initializing the CNI plugin on the `launch[-router]` subcommand #2435/#2442
* Reduce verbosity of fast datapath miss event logs #1852/#2417
* Include the `ipam` option in the help output of the `status` subcommand #2425/#2426
* Remove a harmless duplication of the `--no-dns` parameter #2430
* Internal refactoring
* Improvements to testing and building
* Improvements to the documentation
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.6.1).
## Release 1.6.0
## Highlights
* A new [AWS VPC](https://weave.works/docs/net/latest/using-weave/awsvpc/) mode
that leverages Amazon Virtual Private Cloud for near-native network
performance, as an alternative to the Sleeve and Fast Datapath
overlays
* Docker 1.12 introduced some internal changes that made it
incompatible with previous version of Weave Net - this version
restores compatibility
* An [operational guide](https://weave.works/docs/net/latest/operational-guide)
detailing best practices for deploying and operating Weave Net
* Changes to the target peer list are remembered across restarts,
making it much easier to deploy resilient networks
* The version checkpoint now transmits network mode (e.g. 'awsvpc')
and kernel/docker versions to us to inform and guide our development
efforts. See the [installation documentation](https://weave.works/docs/net/latest/installing-weave/)
for instructions on disabling the checkpoint feature.
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.6.0).
## Release 1.5.2
Bug fixes and minor improvements
* Weave Proxy did not flush the initial http header in the Docker event stream, which could cause Docker Swarm to show all nodes pending. #2306/#2311
* When using the CNI plugin, if a container was removed and quickly replaced by another using the same IP address, other containers might be unable to contact it. Send an address resolution protocol message to update them. #2313
* Avoid Docker hanging for 1 minute in `weave launch` if the plugin had not shut down cleanly #2286/#2292
* Print an error message when Weave bridge mode is changed without `weave reset` #2304
* Eliminate spurious warning message from IP allocator on plugin shutdown #2300/#2319
* Display error message when address requested in a subnet that is too small (/31 or /32) #2282/#2321
* Add short wait after `weave reset` to allow updates to reach peers #2280
* Weave was occasionally unable to claim existing IP address immediately after launch #2275/#2281
* Refactor some integration tests to run faster and more reliably #2291
## Release 1.5.1
Bug fixes and minor improvements
* Persisted data that was rendered invalid by changing peer name or
allocation range is detected and removed automatically, preventing
crashes and hangs #2246/#2209/#2249
* `weave rmpeer` persists the range takeover in case the peer on which
it was executed dies subsequently #2238
* Launching a container with an explicit `WEAVE_CIDR` in the
allocation range now waits instead of erroring if the allocator
hasn't finished initialising #2232/#2265
* Weave DNS now responds to AAAA queries with an empty answer section,
instead of NXDOMAIN which could be cached and block subsequent
resolution of A records #2244/#2252
* Many improvements to the documentation.
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.5.1).
## Release 1.5.0
## Highlights
- A new [Container Network Interface](https://github.com/appc/cni#cni---the-container-network-interface) plugin.
- This release is much more robust against unscheduled restarts,
because it persists key data to disk.
- New configuration options that are useful when you create or
auto-scale larger networks.
- Weave now periodically checks for updates (can be disabled)
Plus many bug fixes and minor enhancements. More details below and in
the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.5.0).
## Release 1.4.6
Fixes some issues encountered by our users.
* Restarting a peer could leave stale entries in WeaveDNS
#1867/#2023/#2081
* Weave proxy occasionally failing to attach any new containers
#2016/#2049
Other fixes:
* Resolved a crash when a restarting peer re-connected to a peer that
had not received the latest IPAM data #2083/#2092
* Make IP address space available immediately after a dead peer is
removed #2068
## Release 1.4.5
Higher performance for multicast and broadcast traffic when using
Weave's Fast Datapath
* The flow rule to deliver broadcast and multicast packets in-kernel
was not created correctly, hence every such packet caused a
context-switch to the software router #2003/#2008
Other fixes:
* Remove DNS entries for containers that are being restarted by Docker
but are not live yet #1977/#1989
* Don't let one failing allocation attempt prevent others from
succeeding; they could be in different subnets which are more
available #1996/#2001
* Don't complain on second router launch on kernels that lack support
for Fast Datapath #1929/#1983
* Fix build broken by change in libnetwork IPAM API #1984/#1985
## Release 1.4.4
Fixing a rather serious issue that slipped through our preparations
for Docker 1.10:
* Restarting Docker or rebooting your machine while the Weave Net
plugin is running causes Docker 1.10.0 to fail to start #1959/#1963
Also one other small fix:
* Avoid a hang when trying to use plugin and proxy at the same time
#1956/#1961
## Release 1.4.3
Preparing for Docker 1.10, plus some bug-fixes.
* Avoid hang in Docker v1.10 on `docker volume ls` after `weave stop`,
`weave stop-plugin` or `weave reset` #1934/#1936
* Fix "unexpected EOF" from Docker 1.10 on `docker exec` with Weave
proxy `--rewrite-inspect` enabled #1911/#1917
* Avoid losing DNS entries and potentially double-allocating IP
Addresses allocated via plugin, on router restart; also extend
`weave ps` to show IP addresses allocated via plugin #1745/#1921
* Stop creating lots of copies of `weavewait` program in Docker
volumes #1757/#1935
* Prevent container starting prematurely when proxy in
`--no-multicast-route` mode #1942/#1943
* Log error message from plugin rather than crashing when weave not
running #1906/#1918
* Warn, don't error, if unable to remove plugin network in 'weave
stop', to avoid breaking the usual upgrade or config change process
#1900/#1919
* Don't crash if network conditions suggest only very small packets
will get through #1905/#1926
* Cope with unexpected errors during route traversal when starting
container via proxy #1909/#1910/#1932
## Release 1.4.2
Bug-fixes and minor improvements.
* A race condition in weavewait that would occasionally hang
containers at startup #1882/#1884
* Having the plugin auto-restart prevents successful `weave launch` on
reboot #1869
* Work round weave router failure on CoreOS 4.3 caused by kernel bug
#1854
* `weave launch` would exit with error code on docker <1.9 #1851
* Running `eval $(weave env)` multiple times would break `eval $(weave
env --restore)` #1824/#1825
* Don't complain in `weave stop` about "Plugin is not running" when
plugin is not enabled #1840/#1841
* `weave --local launch` would fail if utility program
`docker_tls_args` could not be found #1844
* Improved error reporting when TLS arg detection fails #1843
* Improve error reporting when docker isn't running #1845
* Add `--trusted-subnets` usage to `weave` script #1842
* weave run can hang under rare combinations of options #1858
## Release 1.4.1
This is a bug-fix release to cover a few issues that came up since the
release of 1.4.0.
* Weave would fail to launch when `$DOCKER_HOST` was set to a TCP socket secured with TLS #1820/#1822
* Weave would fail to stop when run against Docker pre-1.9 #1815/#1817
* Issue a warning instead of failing on `--with-dns` option to proxy, which was removed #1810/#1812
* Make `weave version` show the plugin version #1797/#1813
* Make `weave launch` show when the a container is restarting #1778/#1814
* Make `weave launch` fail if the plugin is running, for consistency with router and proxy. #1818/#1819
More details in the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.4.1).
## Release 1.4.0
**Highlights**
* The Docker Network plugin can now operate without a cluster store, so it is now run by default.
* You can now use the fast datapath over trusted links and Weave encryption over untrusted links, in the same network.
Plus many bug fixes and minor enhancements. More details below and in
the [change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.4.0).
## Release 1.3.1
**Highlights**
* The minimum Docker version has been increased to 1.6 due to the
[upcoming deprecation of Dockerhub access](https://blog.docker.com/2015/10/docker-hub-deprecation-1-5/)
for old clients. From December 7th onwards previous versions of the
`weave` script will fail to pull down images from the hub; if you
are unable to upgrade to 1.3.1 immediately you can work around this
by running `weave --local setup` in conjunction with a compatible
Docker client installation
* Docker networking plugin now works with older kernels and allows you
to configure the MTU
More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.3.1).
## Release 1.3.0
**Highlights**
This release includes a Docker Plugin, so you have the option to use
Weave Net that way. More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.3.0).
## Release 1.2.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.2.1).
The release is fully compatible with 1.2.0 versions, so existing
clusters can be upgraded incrementally.
## Release 1.2.0
**Highlights**
This release introduces the
[Fast Data Path](http://docs.weave.works/weave/master/head/features.html#fast-data-path),
which allows Weave networks to operate at near wire-level speeds. This
new feature is enabled by default.
Other highlights:
- auto-configuration of TLS for the Weave Docker API proxy, making it
easier to run Weave on Macs and in conjunction with tools like
Docker Swarm
- support for restart policies on application containers and weave
infrastructure containers
- better compatibility with recent and future Docker versions
More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.2.0).
## 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
**Highlights**:
- `weave launch` now launches all weave components, simplifying
startup.
- `weave status` has been completely revamped, with a much improved
presentation of the information, and the option to select and output
data in JSON.
- weaveDNS has been rewritten and embedded in the router. The new
implementation simplifies configuration, improves performance, and
provides fault resilience for services.
- the weave Docker API proxy now provides an even more seamless user
experience, and enables easier integration of weave with other
systems such as kubernetes.
- many usability improvements
- a few minor bug fixes, including a couple of security
vulnerabilities
More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.1.0).
## Release 1.0.3
This release contains a weaveDNS feature enhancement as well as minor fixes for
improved stability and robustness.
More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.0.3).
The release is fully compatible with other 1.0.x versions, so existing
clusters can be upgraded incrementally.
## Release 1.0.2
This release fixes a number of bugs, including some security
vulnerabilities in the Weave Docker API proxy, hangs and failures in
address allocation, and sporadic failures in name resolution.
More details in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.0.2).
The release is fully compatible with other 1.0.x versions, so existing
clusters can be upgraded incrementally.
## Release 1.0.1
This is a bug fix release, addressing the following issue:
- executing `docker run` from a Docker 1.7 client against the weave
proxy would report a `no such image` error when the requested image
wasn't present on the Docker host, instead of downloading it.
## Release 1.0.0
**Highlights**:
- It is now easier than ever to start containers and for them to
communicate, across multiple hosts. Automatic IP address allocation,
and name resolution via weaveDNS are now enabled by default, and the
proxy has become more fully-featured. In short, once weave has been
launched the following is possible:
````
host1$ docker run --name=pingme -dti ubuntu
host2$ docker run -ti ubuntu
root@d11e9287f65b:/# ping pingme
````
- Containers can now be
[load-balanced](http://docs.weave.works/weave/latest_release/weavedns.html#load-balancing)
easily.
- IP address allocation is now available across [multiple
subnets](http://docs.weave.works/weave/latest_release/ipam.html#range),
and hence can be employed when running multiple, isolated
applications.
- The proxy now supports [TLS
connections](http://docs.weave.works/weave/latest_release/proxy.html#tls),
enabling its deployment when the communication between docker
clients and the server must be secured.
There are many other new features, plus the usual assortment of bug
fixes and improvements under the hood. More detail below and in the
[change log](https://github.com/weaveworks/weave/issues?q=milestone%3A1.0.0).
*NB: This release changes the weave protocol version. Therefore, when
upgrading an existing installation, all hosts need to be upgraded in
order to for them to be able to communicate and form a network.*
## Release 0.11.2
This is a bug fix release, addressing the following issues:
+32
View File
@@ -0,0 +1,32 @@
Thanks for your interest in contributing to this project and for
taking the time to read this guide.
# Code of conduct
**Be respectful:** disagreements between people are to be expected and are usually the sign of healthy debate and engagement. Disagreements can lead to frustration and even anger for some members. Turning to personal insults, intimidation or threatening behaviour does not improve the situation. Participants should thus take care to ensure all communications / interactions stay professional at all times.
**Be considerate:** remember that the community has members with a diverse background, many of whom have English as a second language. What might appear impolite, may simply be a result of a lack of knowledge of the English language. Bear in mind that actions will have an impact on other community members and the project as a whole, so take potential consequences into account before pursuing a course of action.
**Be forgiving:** humans are fallible and as such prone to make mistakes and inexplicably change their positions at times. Don't assume that other members are acting with malicious intent. Be prepared to forgive people who make mistakes and assist each other in learning from them. Playing a blame game doesn't help anyone.
# Issues
* Before reporting an issue make sure you search first if anybody has already reported a similar issue and whether or not it has been fixed.
* Make sure your issue report sufficiently details the problem:
* If you set up weave in some way other than that described by our [main instructions](https://github.com/zettio/weave#installation), please mention that.
* Include step-by-step instructions to reproduce the issue.
* State the OS platform you are using, i.e. `uname -a`
* `iptables` rules and firewalls can have a great impact on any Linux network; please note whether you have set up any rules and/or are running a firewall on your machine(s).
* If you want to tackle any open issue, make sure you let people know you are working on it.
## Pull Requests
* Please be generous describing your changes.
* Although it is highly suggested to include tests, they are not a hard requirement in order to get your contributions accepted.
* Keep pull requests small so core developers can review them quickly.
* Keep each pull request focused on a specific topic. If you have two things to change, create two pull requests. This helps reviewers to understand the meat of your contribution.
## Workflow
See [WorkingOnWeave](https://github.com/weaveworks/weave/wiki/WorkingOnWeave)
# Acknowledgements
Much of this taken from https://github.com/cloudescape/gowsdl/blob/master/CONTRIBUTING.md
+3
View File
@@ -0,0 +1,3 @@
DOCKER_VERSION=1.11.2
KUBERNETES_VERSION=1.5.2
KUBERNETES_CNI_VERSION=0.3.0.1
+1 -1
View File
@@ -176,7 +176,7 @@
END OF TERMS AND CONDITIONS
Copyright 2014-2015 Weaveworks Ltd.
Copyright 2014-2016 Weaveworks Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+350 -81
View File
@@ -1,109 +1,378 @@
PUBLISH=publish_weave publish_weavedns publish_weaveexec
.DEFAULT: all
.PHONY: all update tests publish $(PUBLISH) clean prerequisites build travis run-smoketests
.PHONY: all exes testrunner update tests lint publish-one-arch $(PUBLISH) clean clean-bin prerequisites build run-smoketests
# If you can use docker without being root, you can do "make SUDO="
SUDO=sudo
SUDO=$(shell docker info >/dev/null 2>&1 || echo "sudo -E")
BUILD_IN_CONTAINER=true
RM=--rm
RUN_FLAGS=-ti
COVERAGE=
DOCKERHUB_USER=weaveworks
WEAVE_VERSION=git-$(shell git rev-parse --short=12 HEAD)
WEAVER_EXE=weaver/weaver
WEAVEDNS_EXE=weavedns/weavedns
WEAVEPROXY_EXE=weaveproxy/weaveproxy
SIGPROXY_EXE=sigproxy/sigproxy
WEAVEWAIT_EXE=weavewait/weavewait
WEAVER_IMAGE=$(DOCKERHUB_USER)/weave
WEAVEDNS_IMAGE=$(DOCKERHUB_USER)/weavedns
WEAVEEXEC_IMAGE=$(DOCKERHUB_USER)/weaveexec
WEAVER_EXPORT=weave.tar
WEAVEDNS_EXPORT=weavedns.tar
WEAVEEXEC_EXPORT=weaveexec.tar
# This specifies the architecture we're building for
ARCH?=amd64
WEAVEEXEC_DOCKER_VERSION=1.3.1
DOCKER_DISTRIB=weaveexec/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
# We're using QEMU to be able to build Docker images for other architectures
# from amd64 machines.
QEMU_VERSION=v2.7.0
all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)
# A list of all supported architectures here. Should be named as Go is naming platforms
# All supported architectures must have an "ifeq" block below that customizes the parameters
ALL_ARCHITECTURES=amd64 arm arm64
ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64
travis: $(WEAVER_EXE) $(WEAVEDNS_EXE)
ifeq ($(ARCH),amd64)
# The architecture to use when downloading the docker binary
WEAVEEXEC_DOCKER_ARCH?=x86_64
update:
go get -u -f -v -tags -netgo ./$(dir $(WEAVER_EXE)) ./$(dir $(WEAVEDNS_EXE)) ./$(dir $(SIGPROXY_EXE)) ./$(dir $(WEAVEPROXY_EXE))
# The name of the alpine baseimage to use as the base for weave images
ALPINE_BASEIMAGE?=alpine:3.4
$(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE): common/*.go
go get -tags netgo ./$(@D)
go build -ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -o $@ ./$(@D)
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
rm $@; \
echo "\nYour go standard library was built without the 'netgo' build tag."; \
echo "To fix that, run"; \
echo " sudo go clean -i net"; \
echo " sudo go install -tags netgo std"; \
false; \
}
# The extension for the made images
# Specifying none means for example weaveworks/weave:latest
ARCH_EXT?=
$(WEAVER_EXE): router/*.go ipam/*.go ipam/*/*.go weaver/main.go
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go
$(WEAVEPROXY_EXE): proxy/*.go weaveproxy/main.go
$(WEAVEWAIT_EXE): weavewait/*.go weavewait/main.go
# The name of the gcc we're using for compiling C code
CC=gcc
# Sigproxy needs separate rule as it fails the netgo check in the main
# build stanza due to not importing net package
$(SIGPROXY_EXE): sigproxy/main.go
go build -o $@ ./$(@D)
# Optional parameters that can be passed when linking C code into the Go binary
CGO_LDFLAGS=
endif
ifeq ($(ARCH),arm)
# The architecture to use when downloading the docker binary
WEAVEEXEC_DOCKER_ARCH?=armel
$(WEAVER_EXPORT): weaver/Dockerfile $(WEAVER_EXE)
$(SUDO) docker build -t $(WEAVER_IMAGE) weaver
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
# Using the (semi-)official alpine image
ALPINE_BASEIMAGE?=armhf/alpine:3.4
$(WEAVEDNS_EXPORT): weavedns/Dockerfile $(WEAVEDNS_EXE)
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) weavedns
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@
# arm images have the -arm suffix, for instance weaveworks/weave-arm:latest
ARCH_EXT?=-arm
$(WEAVEEXEC_EXPORT): weaveexec/Dockerfile $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE)
cp weave weaveexec/weave
cp $(SIGPROXY_EXE) weaveexec/sigproxy
cp $(WEAVEWAIT_EXE) weaveexec/weavewait
cp $(WEAVEPROXY_EXE) weaveexec/weaveproxy
cp $(DOCKER_DISTRIB) weaveexec/docker.tgz
$(SUDO) docker build -t $(WEAVEEXEC_IMAGE) weaveexec
$(SUDO) docker save $(WEAVEEXEC_IMAGE):latest > $@
# The name of the gcc binary
CC=arm-linux-gnueabihf-gcc
# The architecture name to use when downloading a prebuilt QEMU binary
QEMUARCH=arm
# In the weaveworks/build image; libpcap libraries for arm are placed here
# Tell the gcc linker to search for libpcap here
CGO_LDFLAGS="-L/usr/local/lib/$(CC)"
endif
ifeq ($(ARCH),arm64)
# Use the arm 32-bit docker client variant
WEAVEEXEC_DOCKER_ARCH?=armel
# Using the (semi-)official alpine image
ALPINE_BASEIMAGE?=aarch64/alpine:3.5
# arm64 images have the -arm64 suffix, for instance weaveworks/weave-arm64:latest
ARCH_EXT?=-arm64
# The name of the gcc binary
CC=aarch64-linux-gnu-gcc
# The architecture name to use when downloading a prebuilt QEMU binary
QEMUARCH=aarch64
# In the weaveworks/build image; libpcap libraries for arm64 are placed here
# Tell the gcc linker to search for libpcap here
CGO_LDFLAGS="-L/usr/local/lib/$(CC)"
endif
# The name of the user that this Makefile should produce image artifacts for. Can/should be overridden
DOCKERHUB_USER?=weaveworks
# The default version that's chosen when pushing the images. Can/should be overridden
WEAVE_VERSION?=git-$(shell git rev-parse --short=12 HEAD)
# Paths to all relevant binaries that should be compiled
WEAVER_EXE=prog/weaver/weaver
WEAVEPROXY_EXE=prog/weaveproxy/weaveproxy
SIGPROXY_EXE=prog/sigproxy/sigproxy
KUBEPEERS_EXE=prog/kube-peers/kube-peers
WEAVENPC_EXE=prog/weave-npc/weave-npc
WEAVEWAIT_EXE=prog/weavewait/weavewait
WEAVEWAIT_NOOP_EXE=prog/weavewait/weavewait_noop
WEAVEWAIT_NOMCAST_EXE=prog/weavewait/weavewait_nomcast
WEAVEUTIL_EXE=prog/weaveutil/weaveutil
PLUGIN_EXE=prog/plugin/plugin
RUNNER_EXE=tools/runner/runner
MANIFEST_TOOL_DIR=vendor/github.com/estesp/manifest-tool
MANIFEST_TOOL_EXE=$(MANIFEST_TOOL_DIR)/manifest-tool
TEST_TLS_EXE=test/tls/tls
# All binaries together in a list
EXES=$(WEAVER_EXE) $(SIGPROXY_EXE) $(KUBEPEERS_EXE) $(WEAVENPC_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) $(PLUGIN_EXE) $(RUNNER_EXE) $(TEST_TLS_EXE) $(MANIFEST_TOOL_EXE)
# These stamp files are used to mark the current state of the build; whether an image has been built or not
BUILD_UPTODATE=.build.uptodate
WEAVER_UPTODATE=.weaver$(ARCH_EXT).uptodate
WEAVEEXEC_UPTODATE=.weaveexec$(ARCH_EXT).uptodate
PLUGIN_UPTODATE=.plugin$(ARCH_EXT).uptodate
WEAVEKUBE_UPTODATE=.weavekube$(ARCH_EXT).uptodate
WEAVENPC_UPTODATE=.weavenpc$(ARCH_EXT).uptodate
WEAVEDB_UPTODATE=.weavedb.uptodate
IMAGES_UPTODATE=$(WEAVER_UPTODATE) $(WEAVEEXEC_UPTODATE) $(PLUGIN_UPTODATE) $(WEAVEKUBE_UPTODATE) $(WEAVENPC_UPTODATE)
# The names of the images. Note that the images for other architectures than amd64 have a suffix in the image name.
WEAVER_IMAGE=$(DOCKERHUB_USER)/weave$(ARCH_EXT)
WEAVEEXEC_IMAGE=$(DOCKERHUB_USER)/weaveexec$(ARCH_EXT)
PLUGIN_IMAGE=$(DOCKERHUB_USER)/plugin$(ARCH_EXT)
WEAVEKUBE_IMAGE=$(DOCKERHUB_USER)/weave-kube$(ARCH_EXT)
WEAVENPC_IMAGE=$(DOCKERHUB_USER)/weave-npc$(ARCH_EXT)
BUILD_IMAGE=weaveworks/weavebuild
WEAVEDB_IMAGE=$(DOCKERHUB_USER)/weavedb
IMAGES=$(WEAVER_IMAGE) $(WEAVEEXEC_IMAGE) $(PLUGIN_IMAGE) $(WEAVEKUBE_IMAGE) $(WEAVENPC_IMAGE) $(WEAVEDB_IMAGE)
PUBLISH=publish_weave publish_weaveexec publish_plugin publish_weave-kube publish_weave-npc
PUSH_ML=push_ml_weave push_ml_weaveexec push_ml_plugin push_ml_weave-kube push_ml_weave-npc
WEAVE_EXPORT=weave$(ARCH_EXT).tar.gz
DOCKER_VERSION=1.10.3
DOCKER_DISTRIB=prog/weaveexec/docker-$(DOCKER_VERSION).tgz
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/$(WEAVEEXEC_DOCKER_ARCH)/docker-$(DOCKER_VERSION).tgz
NETGO_CHECK=@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
rm $@; \
echo "\nYour go standard library was built without the 'netgo' build tag."; \
echo "To fix that, run"; \
echo " sudo go clean -i net"; \
echo " sudo go install -tags netgo std"; \
false; \
}
# The flags we are passing to go build. -extldflags -static for making a static binary,
# -linkmode external for linking external C libraries into the binary, -X main.version for telling the
# Go binary which version it is, -tags netgo for enforcing the native Go DNS resolver
BUILD_FLAGS=-i -ldflags "-linkmode external -extldflags -static -X main.version=$(WEAVE_VERSION)" -tags netgo
PACKAGE_BASE=$(shell go list -e ./)
all: $(WEAVE_EXPORT)
testrunner: $(RUNNER_EXE) $(TEST_TLS_EXE)
$(WEAVER_EXE) $(WEAVEPROXY_EXE) $(WEAVEUTIL_EXE): common/*.go common/*/*.go net/*.go net/*/*.go
$(WEAVER_EXE): router/*.go ipam/*.go ipam/*/*.go db/*.go nameserver/*.go prog/weaver/*.go
$(WEAVEPROXY_EXE): proxy/*.go prog/weaveproxy/*.go
$(WEAVEUTIL_EXE): prog/weaveutil/*.go net/*.go plugin/net/*.go plugin/ipam/*.go db/*.go
$(SIGPROXY_EXE): prog/sigproxy/*.go
$(KUBEPEERS_EXE): prog/kube-peers/*.go
$(WEAVENPC_EXE): prog/weave-npc/*.go npc/*.go npc/*/*.go
$(PLUGIN_EXE): prog/plugin/*.go plugin/*/*.go api/*.go common/*.go common/docker/*.go net/*.go
$(TEST_TLS_EXE): test/tls/*.go
$(RUNNER_EXE): tools/runner/*.go
$(MANIFEST_TOOL_EXE): $(MANIFEST_TOOL_DIR)/*.go
$(WEAVEWAIT_NOOP_EXE): prog/weavewait/*.go
$(WEAVEWAIT_EXE): prog/weavewait/*.go net/*.go
$(WEAVEWAIT_NOMCAST_EXE): prog/weavewait/*.go net/*.go
tests: tools/.git
lint: tools/.git
ifeq ($(BUILD_IN_CONTAINER),true)
# This make target compiles all binaries inside of the weaveworks/build container
# It bind-mounts the source into the container and passes all important variables
exes $(EXES) tests lint: $(BUILD_UPTODATE)
git submodule update --init
@mkdir -p $(shell pwd)/.pkg
$(SUDO) docker run $(RM) $(RUN_FLAGS) \
-v $(shell pwd):/go/src/github.com/weaveworks/weave \
-v $(shell pwd)/.pkg:/go/pkg \
-e GOARCH=$(ARCH) -e CGO_ENABLED=1 -e GOOS=linux -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e DEBUG \
$(BUILD_IMAGE) COVERAGE=$(COVERAGE) WEAVE_VERSION=$(WEAVE_VERSION) CC=$(CC) QEMUARCH=$(QEMUARCH) CGO_LDFLAGS=$(CGO_LDFLAGS) $@
else
exes: $(EXES)
$(WEAVER_EXE) $(WEAVEPROXY_EXE) $(PLUGIN_EXE):
ifeq ($(COVERAGE),true)
$(eval COVERAGE_MODULES := $(shell (go list ./$(@D); go list -f '{{join .Deps "\n"}}' ./$(@D) | grep "^$(PACKAGE_BASE)/") | grep -v "^$(PACKAGE_BASE)/vendor/" | paste -s -d,))
go test -c -o ./$@ $(BUILD_FLAGS) -v -covermode=atomic -coverpkg $(COVERAGE_MODULES) ./$(@D)/
else
go build $(BUILD_FLAGS) -o $@ ./$(@D)
endif
$(NETGO_CHECK)
$(WEAVEUTIL_EXE) $(KUBEPEERS_EXE) $(WEAVENPC_EXE):
go build $(BUILD_FLAGS) -o $@ ./$(@D)
$(NETGO_CHECK)
$(WEAVEWAIT_EXE):
go build $(BUILD_FLAGS) -tags "netgo iface mcast" -o $@ ./$(@D)
$(NETGO_CHECK)
$(WEAVEWAIT_NOMCAST_EXE):
go build $(BUILD_FLAGS) -tags "netgo iface" -o $@ ./$(@D)
$(NETGO_CHECK)
# These programs need a separate rule as they fail the netgo check in
# the main build stanza due to not importing net package
$(SIGPROXY_EXE) $(TEST_TLS_EXE) $(WEAVEWAIT_NOOP_EXE) $(RUNNER_EXE) $(MANIFEST_TOOL_EXE):
go build $(BUILD_FLAGS) -o $@ ./$(@D)
tests:
./tools/test -no-go-get -netgo -timeout 8m
lint:
./tools/lint -nocomment -notestpackage
endif
# This rule makes sure the build image is up-to-date.
# It also makes sure the multiarch hooks are reqistered in the kernel so the QEMU emulation works
$(BUILD_UPTODATE): build/*
$(SUDO) docker build -t $(BUILD_IMAGE) build/
$(SUDO) docker run --rm --privileged multiarch/qemu-user-static:register --reset
touch $@
# Creates the Dockerfile.your-user-here file from the template
# Also replaces all placeholders with real values
# If the architecture is amd64, it deletes all CROSS_BUILD lines
# but otherwise, it only removes the "CROSS_BUILD_" placeholder and downloads QEMU
%/Dockerfile.$(DOCKERHUB_USER): %/Dockerfile.template
echo "DOCKERHUB_USER|$(DOCKERHUB_USER)|g;s|ARCH_EXT|$(ARCH_EXT)|g;s|ALPINE_BASEIMAGE|$(ALPINE_BASEIMAGE)|g;s|QEMUARCH|$(QEMUARCH)"
sed -e "s|DOCKERHUB_USER|$(DOCKERHUB_USER)|g;s|ARCH_EXT|$(ARCH_EXT)|g;s|ALPINE_BASEIMAGE|$(ALPINE_BASEIMAGE)|g;s|QEMUARCH|$(QEMUARCH)|g" $^ > $@
ifeq ($(ARCH),amd64)
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
sed -i "/CROSS_BUILD_/d" $@
else
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
# Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMU_VERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(shell dirname $@)
cd $(shell dirname $@) && sha256sum -c $(shell pwd)/build/shasums/qemu-$(QEMUARCH)-static.sha256sum
sed -i "s/CROSS_BUILD_//g" $@
endif
# The targets below builds the weave images
$(WEAVER_UPTODATE): prog/weaver/Dockerfile.$(DOCKERHUB_USER) $(WEAVER_EXE) $(WEAVEEXEC_UPTODATE)
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker build -f prog/weaver/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVER_IMAGE) prog/weaver
touch $@
$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) prog/weaveexec/symlink $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE)
cp weave prog/weaveexec/weave
cp $(SIGPROXY_EXE) prog/weaveexec/sigproxy
cp $(WEAVEPROXY_EXE) prog/weaveexec/weaveproxy
cp $(WEAVEWAIT_EXE) prog/weaveexec/weavewait
cp $(WEAVEWAIT_NOOP_EXE) prog/weaveexec/weavewait_noop
cp $(WEAVEWAIT_NOMCAST_EXE) prog/weaveexec/weavewait_nomcast
cp $(WEAVEUTIL_EXE) prog/weaveexec/weaveutil
tar -xf $(DOCKER_DISTRIB) usr/local/bin/docker -O > prog/weaveexec/docker
chmod +x prog/weaveexec/docker
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker build -f prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVEEXEC_IMAGE) prog/weaveexec
touch $@
$(PLUGIN_UPTODATE): prog/plugin/Dockerfile.$(DOCKERHUB_USER) $(PLUGIN_EXE) $(WEAVER_UPTODATE)
$(SUDO) docker build -f prog/plugin/Dockerfile.$(DOCKERHUB_USER) -t $(PLUGIN_IMAGE) prog/plugin
touch $@
$(WEAVEKUBE_UPTODATE): prog/weave-kube/Dockerfile.$(DOCKERHUB_USER) prog/weave-kube/launch.sh $(KUBEPEERS_EXE) $(WEAVER_UPTODATE)
cp $(KUBEPEERS_EXE) prog/weave-kube/
$(SUDO) docker build -f prog/weave-kube/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVEKUBE_IMAGE) prog/weave-kube
touch $@
$(WEAVENPC_UPTODATE): prog/weave-npc/Dockerfile.$(DOCKERHUB_USER) $(WEAVENPC_EXE) prog/weave-npc/ulogd.conf
$(SUDO) docker build -f prog/weave-npc/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVENPC_IMAGE) prog/weave-npc
touch $@
$(WEAVEDB_UPTODATE): prog/weavedb/Dockerfile
$(SUDO) docker build -t $(WEAVEDB_IMAGE) prog/weavedb
touch $@
$(WEAVE_EXPORT): $(IMAGES_UPTODATE) $(WEAVEDB_UPTODATE)
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker save $(addsuffix :latest,$(IMAGES)) | gzip > $@
$(DOCKER_DISTRIB):
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)
cd $(shell dirname $@) && sha256sum -c $(shell pwd)/build/shasums/docker-tgz-$(WEAVEEXEC_DOCKER_ARCH).sha256sum
tests:
echo "mode: count" > profile.cov
fail=0 ; \
for dir in $$(find . -type f -name '*_test.go' | xargs -n1 dirname | sort -u); do \
output=$$(mktemp cover.XXXXXXXXXX) ; \
if ! go test -tags netgo -covermode=count -coverprofile=$$output $$dir ; then \
fail=1 ; \
fi ; \
if [ -f $$output ]; then \
tail -n +2 <$$output >>profile.cov; \
rm $$output; \
fi \
done ; \
exit $$fail
go tool cover -html=profile.cov -o=coverage.html
tools/.git $(MANIFEST_TOOL_DIR)/.git:
git submodule update --init
$(PUBLISH): publish_%:
$(SUDO) docker tag -f $(DOCKERHUB_USER)/$* $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
$(SUDO) docker push $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
$(SUDO) docker push $(DOCKERHUB_USER)/$*:latest
# CODE FOR PUBLISHING THE IMAGES
publish: $(PUBLISH)
# This target first runs "make publish" for each architecture
# Then it pushes the manifest lists
publish: $(addprefix sub-publish-,$(ALL_ARCHITECTURES)) $(WEAVEDB_UPTODATE)
$(MAKE) DOCKER_HOST=$(DOCKER_HOST) DOCKERHUB_USER=$(DOCKERHUB_USER) WEAVE_VERSION=$(WEAVE_VERSION) UPDATE_LATEST=$(UPDATE_LATEST) $(PUSH_ML)
ifeq ($(PUBLISH_WEAVEDB),true)
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker push $(DOCKERHUB_USER)/weavedb:latest
endif
clean:
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVEEXEC_IMAGE)
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)
sub-publish-%:
$(MAKE) ARCH=$* DOCKER_HOST=$(DOCKER_HOST) clean-bin
$(MAKE) ARCH=$* DOCKER_HOST=$(DOCKER_HOST) DOCKERHUB_USER=$(DOCKERHUB_USER) WEAVE_VERSION=$(WEAVE_VERSION) UPDATE_LATEST=$(UPDATE_LATEST) $(IMAGES_UPTODATE)
$(MAKE) ARCH=$* DOCKER_HOST=$(DOCKER_HOST) DOCKERHUB_USER=$(DOCKERHUB_USER) WEAVE_VERSION=$(WEAVE_VERSION) UPDATE_LATEST=$(UPDATE_LATEST) publish-one-arch
publish-one-arch: $(PUBLISH)
# This rule handles the pushing of the built images
$(PUBLISH): publish_%: $(IMAGES_UPTODATE)
# Tag :latest with the real version
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker tag $(DOCKERHUB_USER)/$*$(ARCH_EXT) $(DOCKERHUB_USER)/$*$(ARCH_EXT):$(WEAVE_VERSION)
# Push the image with the arch suffix for arm and arm64, and without suffix for amd64
$(MAKE) DOCKER_HOST=$(DOCKER_HOST) DOCKERHUB_USER=$(DOCKERHUB_USER) WEAVE_VERSION=$(WEAVE_VERSION) UPDATE_LATEST=$(UPDATE_LATEST) push_$*$(ARCH_EXT)
ifeq ($(ARCH),amd64)
# If the architecture is amd64, add the -amd64 suffix.
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker tag $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION) $(DOCKERHUB_USER)/$*-amd64:$(WEAVE_VERSION)
# If the version is latest, tag the -amd64 with latest as well
ifneq ($(UPDATE_LATEST),false)
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker tag $(DOCKERHUB_USER)/$*-amd64:$(WEAVE_VERSION) $(DOCKERHUB_USER)/$*-amd64:latest
endif
# Push the image with the -amd64-suffix so BINARY-ARCH-named images exist for all arches, so manifest lists may be made and ARCH is replaceable in scripts
$(MAKE) DOCKER_HOST=$(DOCKER_HOST) DOCKERHUB_USER=$(DOCKERHUB_USER) WEAVE_VERSION=$(WEAVE_VERSION) UPDATE_LATEST=$(UPDATE_LATEST) push_$*-amd64
endif
# This target pushes an image, and if UPDATE_LATEST is anything but false, also updates the latest tag
# It takes one parameter, the image name
push_%:
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker push $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
ifneq ($(UPDATE_LATEST),false)
$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker push $(DOCKERHUB_USER)/$*:latest
endif
# This target pushes a manifest list; it takes one parameter, the image name.
# The variable UPDATE_LATEST controls whether it updates the versioned tag and/or the latest tag
$(PUSH_ML): push_ml_%: $(MANIFEST_TOOL_EXE)
ifneq ($(UPDATE_LATEST),latest-only)
$(MANIFEST_TOOL_EXE) push from-args --platforms $(ML_PLATFORMS) --template $(DOCKERHUB_USER)/$*-ARCH:$(WEAVE_VERSION) --target $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
endif
ifneq ($(UPDATE_LATEST),false)
# Push the manifest list to :latest as well
$(MANIFEST_TOOL_EXE) push from-args --platforms $(ML_PLATFORMS) --template $(DOCKERHUB_USER)/$*-ARCH:latest --target $(DOCKERHUB_USER)/$*:latest
endif
clean-bin:
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(IMAGES)
find prog -type f -name "Dockerfile.*" -not -name "Dockerfile.template" -print | xargs rm -f
find prog -type f -name "*qemu-*" -print | xargs rm -f
rm -rf $(EXES) $(IMAGES_UPTODATE) $(WEAVEDB_UPTODATE) weave*.tar.gz $(DOCKER_DISTRIB) prog/weaveexec/docker .pkg
clean: clean-bin
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(BUILD_IMAGE)
rm -rf test/tls/*.pem test/coverage.* test/coverage $(BUILD_UPTODATE) $(MANIFEST_TOOL_EXE)
build:
$(SUDO) go clean -i net
$(SUDO) go install -tags netgo std
$(MAKE)
run-smoketests: all
run-smoketests: all testrunner
cd test && ./setup.sh && ./run_all.sh
integration-tests: all testrunner
# Usage:
# $ make \
# NAME="<prefix used to name VMs and other resources>" \
# PROVIDER="<provider among {vagrant|gcp|aws|do}>" \
# NUM_HOSTS="<# test machines>" \
# PLAYBOOK="<filename>" \
# RUNNER_ARGS="<...>" \
# TESTS="<...>" \ # Can be set to only run one or a few tests instead of the full test suite.
# DOCKER_VERSION=<...> \
# KUBERNETES_VERSION=<...> \
# KUBERNETES_CNI_VERSION=<...> \
# <...> # See also run-integration-test.sh for all variables and individual functions.
# integration-tests
#
RUNNER_ARGS="-parallel" ./test/run-integration-tests.sh
+1 -1
View File
@@ -1,3 +1,3 @@
Weave
Copyright 2014-2015 Weaveworks Ltd.
Copyright 2014-2016 Weaveworks Ltd.
This product includes software developed at Weaveworks Ltd.
+27 -140
View File
@@ -1,155 +1,42 @@
# Weave - the Docker network
# Weave Net - Weaving Containers into Applications
[![Build Status](https://travis-ci.org/weaveworks/weave.svg?branch=master)](https://travis-ci.org/weaveworks/weave) [![Integration Tests](https://circleci.com/gh/weaveworks/weave/tree/master.svg?style=shield&circle-token=4933c7dabb3d0383e62117565cb9d16df7b1a811)](https://circleci.com/gh/weaveworks/weave) [![Coverage Status](https://coveralls.io/repos/weaveworks/weave/badge.svg)](https://coveralls.io/r/weaveworks/weave)
[![Integration Tests](https://circleci.com/gh/weaveworks/weave/tree/master.svg?style=shield)](https://circleci.com/gh/weaveworks/weave)
[![Coverage Status](https://coveralls.io/repos/weaveworks/weave/badge.svg)](https://coveralls.io/r/weaveworks/weave)
[![Go Report Card](https://goreportcard.com/badge/github.com/weaveworks/weave)](https://goreportcard.com/report/github.com/weaveworks/weave)
[![Slack Status](https://slack.weave.works/badge.svg)](https://slack.weave.works)
[![Docker Pulls](https://img.shields.io/docker/pulls/weaveworks/weave.svg?maxAge=604800)](https://hub.docker.com/r/weaveworks/weave/)
Weave creates a virtual network that connects Docker containers
deployed across multiple hosts and enables their automatic discovery.
# About Weaveworks
![Weave Virtual Network](/docs/virtual-network.png?raw=true "Weave Virtual Network")
[Weaveworks](https://www.weave.works) is the company that delivers the most productive way for developers to connect, observe and control
Docker containers.
Applications use the network just as if the containers were all
plugged into the same network switch, with no need to configure port
mappings, links, etc. Services provided by application containers on
the weave network can be made accessible to the outside world,
regardless of where those containers are running. Similarly, existing
internal systems can be exposed to application containers irrespective
of their location.
This repository contains [Weave Net](https://www.weave.works/products/weave-net/), the first product developed by Weaveworks, and with over 8 million downloads to date, it enables you to get started with Docker clusters and portable apps in a fraction of the time compared with other solutions.
![Weave Deployment](/docs/deployment.png?raw=true "Weave Deployment")
Weaveworks' product [Weave Cloud](https://www.weave.works/solution/cloud/) takes the heavy lifting out of building, integrating and operating open source components, so you don’t have to manage databases, storage and availability.
Weave can traverse firewalls and operate in partially connected
networks. Traffic can be encrypted, allowing hosts to be connected
across an untrusted network.
Weave Cloud is built using these Open Source projects: [Weave Scope](https://www.weave.works/products/weave-scope/), a powerful container monitoring tool that automatically maps Docker containers and their interactions, [Weave Cortex](https://github.com/weaveworks/cortex), a horizontally-scalable version of Prometheus, and [Weave Flux](https://www.weave.works/products/weave-flux/), a continuous deployment tool that works with Kubernetes.
With weave you can easily construct applications consisting of
multiple containers, running anywhere.
# Weave Net
Weave works alongside Docker's existing (single host) networking
capabilities, so these can continue to be used by containers.
Weave Net creates a virtual network that connects Docker containers across multiple hosts and enables their automatic discovery. With Weave Net, portable microservices-based applications consisting of multiple containers can run anywhere: on one host, multiple hosts or even across cloud providers and data centers. Applications use the network just as if the containers were all plugged into the same network switch, without having to configure port mappings, ambassadors or links.
## Installation
Services provided by application containers on the Weave network can be exposed to the outside world, regardless of where they are running. Similarly, existing internal systems can be opened to accept connections from application containers irrespective of their location.
Ensure you are running Linux (kernel 3.8 or later) and have Docker
(version 1.3.1 or later) installed. Then install weave with
## <a name="help"></a>Getting help
sudo wget -O /usr/local/bin/weave \
https://github.com/weaveworks/weave/releases/download/latest_release/weave
sudo chmod a+x /usr/local/bin/weave
If you have any questions about, feedback for or a problem with Weave Net:
CoreOS users see [here](https://github.com/fintanr/weave-gs/blob/master/coreos-simple/user-data) for an example of installing weave using cloud-config.
- Read [the Weave Net docs](https://www.weave.works/docs/net/latest/introducing-weave/).
- Invite yourself to the <a href="https://weaveworks.github.io/community-slack/" target="_blank"> #weave-community </a> slack channel.
- Ask a question on the <a href="https://weave-community.slack.com/messages/general/"> #weave-community</a> slack channel.
- Join the <a href="https://www.meetup.com/pro/Weave/"> Weave User Group </a> and get invited to online talks, hands-on training and meetups in your area.
- Send an email to <a href="mailto:weave-users@weave.works">weave-users@weave.works</a>
- <a href="https://github.com/weaveworks/weave/issues/new">File an issue.</a>
Weave respects the environment variable `DOCKER_HOST`, so you can run
it locally to control a weave network on a remote host.
Your feedback is always welcome!
## Quick Start Screencast
##Further Information
<a href="http://youtu.be/k6r7yuSr0hE" alt="Click to watch the screencast" target="_blank">
<img src="/docs/hello-screencast.png" />
</a>
## Example
Say you have docker running on two hosts, accessible to each other as
`$HOST1` and `$HOST2`, and want to deploy an application consisting of
two containers, one on each host.
On `$HOST1` run
host1$ weave launch
host1$ C=$(weave run 10.2.1.1/24 -t -i ubuntu)
The first line starts the weave router, in a container. This needs to
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
address and network, in
[CIDR notation](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation).
`weave run` invokes `docker run -d` with all the parameters following
the IP address and network. So we could be launching any container
this way; here we just take a stock ubuntu container and launch a
shell in it. There's also a `weave start` command, which invokes
`docker start` for starting existing containers.
If our application consists of more than one container on this host we
simply launch them with a variation on that second line.
The IP addresses and netmasks can be anything you like, but make sure
they don't conflict with any IP ranges in use on the hosts or IP
addresses of external services the hosts or containers need to connect
to. The same IP range must be used everywhere, and the individual IP
addresses must, of course, be unique.
We repeat similar steps on `$HOST2`...
host2$ weave launch $HOST1
host2$ C=$(weave run 10.2.1.2/24 -t -i ubuntu)
The only difference, apart from the choice of IP address for the
application container, is that we tell our weave that it should peer
with the weave on `$HOST1` (specified as the IP address or hostname,
and optional `:port`, by which `$HOST2` can reach it). NB: if there is
a firewall between `$HOST1` and `$HOST2`, you must open the weave port
(6783 by default; this can be overriden by setting `WEAVE_PORT`) for
TCP and UDP.
Note that we could instead have told the weave on `$HOST1` to connect to
`$HOST2`, or told both about each other. Order does not matter here;
weave automatically (re)connects to peers when they become
available. Also, we can tell weave to connect to multiple peers by
supplying multiple addresses, separated by spaces. And we can
[add peers dynamically](http://docs.weave.works/weave/latest_release/features.html#dynamic-topologies).
Now that we've got everything set up, let's see whether our containers
can talk to each other...
On `$HOST1`...
host1$ docker attach $C
root@28841bd02eff:/# ping -c 1 -q 10.2.1.2
PING 10.2.1.2 (10.2.1.2): 48 data bytes
--- 10.2.1.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.048/1.048/1.048/0.000 ms
Similarly, on `$HOST2`...
host2$ docker attach $C
root@f76829496120:/# ping -c 1 -q 10.2.1.1
PING 10.2.1.1 (10.2.1.1): 48 data bytes
--- 10.2.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.034/1.034/1.034/0.000 ms
So there we have it, two containers on separate hosts happily talking
to each other.
## Find out more
* [Documentation homepage](http://docs.weave.works/weave/latest_release/)
* [Features](http://docs.weave.works/weave/latest_release/features.html)
* [Automatic Discovery with WeaveDNS](http://docs.weave.works/weave/latest_release/weavedns.html)
* [Troubleshooting](http://docs.weave.works/weave/latest_release/troubleshooting.html)
* [Building](http://docs.weave.works/weave/latest_release/building.html)
* [How it works](http://docs.weave.works/weave/latest_release/how-it-works.html)
## Contact Us
Found a bug, want to suggest a feature, or have a question?
[File an issue](https://github.com/weaveworks/weave/issues), or email
help@weave.works. When reporting a bug, please include which version of
weave you are running, as shown by `weave version`.
Follow weave on Twitter:
[@weaveworks](https://twitter.com/weaveworks).
Read the Weave blog:
[Weaveblog](http://weaveblog.com/).
IRC:
[#weavenetwork](https://botbot.me/freenode/weavenetwork/)
* [Installing Weave Net](https://www.weave.works/docs/net/latest/installing-weave/)
* [Weave Net Product Overview](https://www.weave.works/products/weave-net/)
Vendored
+18 -23
View File
@@ -1,41 +1,36 @@
VAGRANTFILE_API_VERSION = "2"
require './vagrant-common.rb'
require File.expand_path(File.join(File.dirname(__FILE__), 'vagrant-common.rb'))
vm_ip = "172.16.0.3" # arbitrary private IP
pkgs = %w(
lxc-docker
aufs-tools
build-essential
ethtool
iputils-arping
libpcap-dev
git
mercurial
bc
)
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/ubuntu-14.10-amd64"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/utopic/current/utopic-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.box = VAGRANT_IMAGE
config.vm.network "private_network", ip: vm_ip
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.memory = 2048
configure_nat_dns(vb)
end
# Disable default Vagrant shared folder, which we don't need:
config.vm.synced_folder ".", "/vagrant", disabled: true
# Keep Weave Net sources' in sync:
config.vm.synced_folder ".", "/home/vagrant/src/github.com/weaveworks/weave"
# Create a convenience symlink to $HOME/src/github.com/weaveworks/weave
config.vm.provision :shell, :inline => 'ln -sf ~vagrant/src/github.com/weaveworks/weave ~vagrant/'
install_build_deps config.vm, pkgs
install_go_toochain config.vm
tweak_user_env config.vm
tweak_docker_daemon config.vm
# Set SSH keys up to be able to run smoke tests straightaway:
config.vm.provision "file", source: "~/.vagrant.d/insecure_private_key", destination: "/home/vagrant/src/github.com/weaveworks/weave/test/insecure_private_key"
# Grant permissions on sources:
config.vm.provision :shell, :inline => 'sudo chown -R vagrant:vagrant ~vagrant/src', :privileged => false
cleanup config.vm
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'tools/config_management/setup_weave-net_dev.yml'
ansible.extra_vars = {
go_version: GO_VERSION
}.merge(ansibleize(get_dependencies_version_from_file_and_env()))
end
end
begin
+22
View File
@@ -0,0 +1,22 @@
package api
import (
"fmt"
"net/url"
)
func (client *Client) DNSDomain() (string, error) {
return client.httpVerb("GET", "/domain", nil)
}
func (client *Client) RegisterWithDNS(ID string, fqdn string, ip string) error {
data := url.Values{}
data.Add("fqdn", fqdn)
_, err := client.httpVerb("PUT", fmt.Sprintf("/name/%s/%s", ID, ip), data)
return err
}
func (client *Client) DeregisterWithDNS(ID string, ip string) error {
_, err := client.httpVerb("DELETE", fmt.Sprintf("/name/%s/%s", ID, ip), nil)
return err
}
+72
View File
@@ -0,0 +1,72 @@
package api
import (
"fmt"
"net"
)
// Special token used in place of a container identifier when:
// - the caller does not know the container ID, or
// - the caller is unsure whether IPAM was previously told the container ID.
//
// While addresses are typically stored under their container IDs, when this
// token is used, the address will be stored under its own string, something
// which should be kept in mind if the entry needs to be removed at any point.
const NoContainerID string = "_"
func (client *Client) ipamOp(ID string, op string) (*net.IPNet, error) {
ip, err := client.httpVerb(op, fmt.Sprintf("/ip/%s", ID), nil)
if err != nil {
return nil, err
}
return parseIP(ip)
}
// returns an IP for the ID given, allocating a fresh one if necessary
func (client *Client) AllocateIP(ID string) (*net.IPNet, error) {
return client.ipamOp(ID, "POST")
}
func (client *Client) AllocateIPInSubnet(ID string, subnet *net.IPNet) (*net.IPNet, error) {
ip, err := client.httpVerb("POST", fmt.Sprintf("/ip/%s/%s", ID, subnet), nil)
if err != nil {
return nil, err
}
return parseIP(ip)
}
// returns an IP for the ID given, or nil if one has not been
// allocated
func (client *Client) LookupIP(ID string) (*net.IPNet, error) {
return client.ipamOp(ID, "GET")
}
// Claim a specific IP on behalf of the ID
func (client *Client) ClaimIP(ID string, cidr *net.IPNet) error {
_, err := client.httpVerb("PUT", fmt.Sprintf("/ip/%s/%s", ID, cidr), nil)
return err
}
// release all IPs owned by an ID
func (client *Client) ReleaseIPsFor(ID string) error {
_, err := client.httpVerb("DELETE", fmt.Sprintf("/ip/%s", ID), nil)
return err
}
func (client *Client) DefaultSubnet() (*net.IPNet, error) {
cidr, err := client.httpVerb("GET", fmt.Sprintf("/ipinfo/defaultsubnet"), nil)
if err != nil {
return nil, err
}
_, ipnet, err := net.ParseCIDR(cidr)
return ipnet, err
}
func parseIP(body string) (*net.IPNet, error) {
ip, ipnet, err := net.ParseCIDR(string(body))
if err != nil {
return nil, err
}
ipnet.IP = ip
return ipnet, nil
}
+82
View File
@@ -0,0 +1,82 @@
package api
import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const (
WeaveHTTPHost = "127.0.0.1"
WeaveHTTPPort = 6784
)
type Client struct {
baseURL string
log Logger
}
func (client *Client) httpVerb(verb string, url string, values url.Values) (string, error) {
url = client.baseURL + url
client.log.Debugf("weave %s to %s with %v", verb, url, values)
var body io.Reader
if values != nil {
body = strings.NewReader(values.Encode())
}
req, err := http.NewRequest(verb, url, body)
if err != nil {
return "", err
}
if values != nil {
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
rbody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusNoContent {
return string(rbody), nil
}
return "", errors.New(resp.Status + ": " + string(rbody))
}
func NewClient(addr string, log Logger) *Client {
host := WeaveHTTPHost
port := fmt.Sprintf("%d", WeaveHTTPPort)
switch parts := strings.Split(addr, ":"); len(parts) {
case 0:
case 1:
if parts[0] != "" {
host = parts[0]
}
case 2:
if parts[0] != "" {
host = parts[0]
}
if parts[1] != "" {
port = parts[1]
}
default:
return &Client{baseURL: fmt.Sprintf("http://%s", addr), log: log}
}
return &Client{baseURL: fmt.Sprintf("http://%s:%s", host, port), log: log}
}
func (client *Client) Connect(remote string) error {
_, err := client.httpVerb("POST", "/connect", url.Values{"peer": {remote}})
return err
}
type Logger interface {
Infof(string, ...interface{})
Debugf(string, ...interface{})
}
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -e
source "$STATE"
if [ -n "$TEST_AND_PUBLISH" ]; then
cd "$SRCDIR"
git submodule update --init
cd "$SRCDIR/build"
../tools/rebuild-image weaveworks/weavebuild . Dockerfile build.sh
touch "$SRCDIR/.build.uptodate"
sudo chown -R ubuntu /usr/local/go
cd "$SRCDIR"
make testrunner
make COVERAGE=true RM= exes all
fi
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
set -e
echo "TEST_AND_PUBLISH=1" >"$STATE"
# Avoid doing a full build if we can. Note if the PR doesn't exist
# when the build is kicked off, we can't run this check so we do a
# full build. Subsequent pushes to the same branch will have the desired behaviour
if [ -n "$CI_PULL_REQUEST" -a "$CI_PULL_REQUEST" = "$CI_PULL_REQUESTS" ]; then
if PR=$(echo "$CI_PULL_REQUEST" | grep -oP '(?<=^https://github.com/weaveworks/weave/pull/)[0-9]+$'); then
echo "GH_PR=$PR" >>"$STATE"
if FILES=$(curl -s "https://api.github.com/repos/weaveworks/weave/pulls/$PR/files" | jq -r '.[]|.filename'); then
echo "PR touches [$FILES]"
if ! echo "$FILES" | grep -v ^site/; then
echo "PR contains site changes only - skipping tests"
echo "TEST_AND_PUBLISH=" >>"$STATE"
else
echo "PR contains non-site changes - running tests"
fi
else
echo "Unable to get files for PR $PR" >&2
fi
else
echo "Unable to extract PR number from $CI_PULL_REQUEST" >&2
fi
fi
source "$STATE"
mkdir -p "$(dirname "$SRCDIR")" && cp -r "$(pwd)/" "$SRCDIR"
if [ -n "$TEST_AND_PUBLISH" ]; then
cd "$SRCDIR"
git submodule update --init
fi
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
set -e
set -o pipefail
source "$STATE"
site_changes() {
curl -s https://api.github.com/repos/weaveworks/weave/pulls/$1/files |
jq -r '.[]|.status + " " + .filename' |
grep -oP '^(added|modified|removed) site/.*(?=\.md$)'
}
format_comment() {
if [ ! -d .git ] || ! BRANCH=$(git symbolic-ref --short HEAD) || [ -z "$BRANCH" ] ; then
echo "Could not determine branch" >&2
return 1
fi
echo "#### Documentation changes:"
while read ACTION PAGE; do
echo "$ACTION [${PAGE#site/}]($WP_DEV_URL/docs/net/${BRANCH#issues/}/${PAGE#site/}/)"
done | sort
}
post_comment() {
jq -s -R '. | tostring | { body: . }' |
curl -s -d @- \
-H "Authorization: Bearer $WP_GH_COMMENT_TOKEN" \
-H 'Content-Type: application/json' \
https://api.github.com/repos/weaveworks/weave/issues/$GH_PR/comments > /dev/null
}
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_DEV_URL" "$WP_DEV_USER" "$WP_DEV_PASSWORD"
if [ -n "$WP_GH_COMMENT_TOKEN" -a -n "$GH_PR" ] ; then
echo ">>> Adding doc changelog to GitHub PR $GH_PR"
if CHANGES=$(site_changes $GH_PR) && [ -n "$CHANGES" ] ; then
echo "$CHANGES" | format_comment | post_comment
fi
fi
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -e
source "$STATE"
if [ -n "$TEST_AND_PUBLISH" ] ; then
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
cd $SRCDIR
make clean-bin
# CircleCI doesn't let us install the qemu module to do ARM docker builds
make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only
fi
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_DEV_URL" "$WP_DEV_USER" "$WP_DEV_PASSWORD"
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_LIVE_URL" "$WP_LIVE_USER" "$WP_LIVE_PASSWORD"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
source "$STATE"
if [ -n "$TEST_AND_PUBLISH" ] ; then
if [ "$CIRCLE_NODE_INDEX" = "0" ] ; then
go get github.com/mattn/goveralls
goveralls -repotoken $COVERALLS_REPO_TOKEN -coverprofile=$SRCDIR/test/profile.cov -service=circleci
cd $SRCDIR/test; cp coverage.* $CIRCLE_ARTIFACTS
fi
fi
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
set -e
# Signal failures in lock file, in order to fail fast:
function signal_failure() {
echo "KO" >"$TEST_VMS_READY_LOCK_FILE"
exit 1
}
trap signal_failure ERR
source "$STATE"
source "$(dirname "$0")/wait_for.sh"
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
# Provisioning from image typically take 90 seconds,
# but if we are creating a GCP image, it can take more than 10 minutes:
wait_for 900 "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
# Upload built binaries to testing VMs:
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
./run-integration-tests.sh setup >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
echo "OK" >"$TEST_VMS_READY_LOCK_FILE"
echo "Test VMs now ready. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
fi
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
set -e
source "$STATE"
source "$(dirname "$0")/wait_for.sh"
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
# Provisioning from image typically take 90 seconds,
# but if we are creating a GCP image, it can take more than 10 minutes:
wait_for 900 "$TEST_VMS_READY_LOCK_FILE"
# Run integration tests:
export COVERAGE=true
export WEAVE_NET_SANITY_CHECKS_FILES="$CIRCLE_ARTIFACTS/weave_net_sanity_check_*.log"
cd "$SRCDIR/test" # Ensures we generate code coverage files in the right folder, and use the Terraform state of previously provisionned VMs.
./run-integration-tests.sh test
fi
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
source "$STATE"
if [ -n "$TEST_AND_PUBLISH" ] ; then
cd $SRCDIR/test
test "$CIRCLE_NODE_INDEX" != "0" || (cd $SRCDIR/test; ./gen_coverage_reports.sh)
fi
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
set -e
source "$STATE"
if [ -n "$TEST_AND_PUBLISH" ] ; then
cd $SRCDIR
make DEBUG=1 lint
COVERDIR=test/coverage make RM= tests
fi
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
if [ $# -ne 1 ] ; then
echo USAGE: install-wordepress [COMMIT-ISH] >&2
exit 1
fi
go get github.com/weaveworks/wordepress
cd /home/ubuntu/src/github.com/weaveworks/wordepress
git checkout $1
cd cmd/wordepress
go get
-81
View File
@@ -1,81 +0,0 @@
#!/bin/bash
# This scipt lints go files for common errors.
#
# Its runs gofmt and go vet, and optionally golint and
# gocyclo, if they are installed.
#
# With no arguments, it lints the current files staged
# for git commit. Or you can pass it explicit filenames
# (or directories) and it will lint them.
#
# To use this script automatically, run:
# ln -s ../../bin/lint .git/hooks/pre-commit
set -eu
function lint_go {
filename="$1"
result=0
if [ -n "$(gofmt -l "${filename}")" ]; then
result=1
echo "${filename}: run gofmt -w ${filename}!"
fi
go tool vet "${filename}" || result=$?
# golint is completely optional. If you don't like it
# don't have it installed.
if type golint >/dev/null 2>&1; then
# golint doesn't set an exit code it seems
lintoutput=$(golint "${filename}")
if [ "$lintoutput" != "" ]; then
result=1
echo "$lintoutput"
fi
fi
# gocyclo is completely optional. If you don't like it
# don't have it installed. Also never blocks a commit,
# it just warns.
if type gocyclo >/dev/null 2>&1; then
gocyclo -over 25 "${filename}" | while read line; do
echo "${filename}": higher than 25 cyclomatic complexity - "${line}"
done
fi
return $result
}
function lint {
filename="$1"
ext="${filename##*\.}"
# Don't lint this script
if [ "${filename}" = "bin/lint" ]; then
return
fi
case "$ext" in
go) lint_go "${filename}"
;;
esac
}
function lint_files {
lint_result=0
while read filename; do
lint "${filename}" || lint_result=1
done
exit $lint_result
}
function list_files {
if [ $# -gt 0 ]; then
find "$@" -type f
else
git diff --cached --name-only
fi
}
list_files "$@" | lint_files
+29 -15
View File
@@ -14,7 +14,8 @@ set -e
START=${FIRST_WEAVE:-1}
COUNT=${NUM_WEAVES:-28}
FINISH=$((START+COUNT-1))
PORT=6783
SUBNET=192.168.7
weavedir=$(dirname $0)/..
@@ -23,32 +24,45 @@ random_mac() {
# In the first byte of the MAC, the 'multicast' bit should be
# clear and 'locally administered' bit should be set. All other
# bits should be random.
od -txC -An -N6 /dev/urandom | sed 's|^ ||;s| |:|;s|[0-3]:|2:|;s|[4-7]:|6:|;s|[89ab]:|a:|;s|[c-f]:|e:|;s| |:|g'
od -txC -An -N6 /dev/urandom | ( read a b c d e f && printf "%02x:$b:$c:$d:$e:$f" $((0x$a & ~1 | 2)) )
}
weave() {
i=$1
shift
WEAVE_CONTAINER_NAME=weave$i WEAVE_HTTP_ADDR=$SUBNET.$i:6784 $weavedir/weave "$@"
}
case "$1" in
launch)
shift 1
echo $(date -R) launching
ip link show multiweave >/dev/null 2>&1 || sudo ip link add name multiweave type bridge
for i in $(seq $START $FINISH); do
WEAVE_CONTAINER_NAME=weave$i WEAVE_PORT=$((5000+i)) $weavedir/weave launch -iface '' -name $(random_mac) -nickname weave$i -port $PORT "$@"
IP=$SUBNET.$i
sudo ip addr add $IP/24 dev multiweave
weave $i launch-router --datapath '' --iface '' --no-dns --host $IP \
--name $(random_mac) --nickname weave$i "$@"
done
if [ $START -ne 1 ] ; then
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$((START-1)))
PREV="${status#true }"
fi
echo $(date -R) connecting
[ $START -gt 1 ] || START=2
for i in $(seq $START $FINISH); do
if [ -n "$PREV" ] ; then
echo connecting weave$i to $PREV
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave connect $PREV
fi
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$i)
PREV="${status#true }"
TO=$SUBNET.$((i-1))
echo connecting weave$i to $TO
weave $i connect $TO
done
echo $(date -R) done
;;
stop)
for i in $(seq $START $FINISH); do
for i in $(seq $FINISH -1 $START); do
IP=$SUBNET.$i
echo Stopping weave$i
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave stop
weave $i stop-router
sudo ip addr del $IP/24 dev multiweave || true
done
[ -z "$(ip -4 -o addr show multiweave)" ] && sudo ip link del multiweave
;;
*)
weave "$@"
;;
esac
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
set -e
# Signal failures in lock file, in order to fail fast:
function signal_failure() {
echo "KO" >"$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
exit 1
}
trap signal_failure ERR
source "$STATE"
function install_terraform() {
curl -fsS https://releases.hashicorp.com/terraform/0.8.5/terraform_0.8.5_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin
}
function install_ansible() {
sudo apt-get update || true
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev && pip install --user -U cffi && pip install --user ansible
export PATH="$PATH:$HOME/.local/bin"
}
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
install_terraform >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
install_ansible >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
# Only attempt to create GCP image in first container, wait for it to be created otherwise:
[ "$CIRCLE_NODE_INDEX" != "0" ] && export CREATE_IMAGE=0
# Provision and configure testing VMs:
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
./run-integration-tests.sh configure >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
echo "OK" >"$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
echo "Test VMs now provisioned and configured. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
fi
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
set -e
set -o pipefail
PRODUCT=net
fatal() {
echo "$@" >&2
exit 1
}
if [ ! -d .git ] ; then
fatal "Current directory is not a git clone"
fi
if ! BRANCH=$(git symbolic-ref --short HEAD) || [ -z "$BRANCH" ] ; then
fatal "Could not determine branch"
fi
case "$BRANCH" in
issues/*)
VERSION="${BRANCH#issues/}"
TAGS="$VERSION"
;;
*)
if echo "$BRANCH" | grep -qE '^[0-9]+\.[0-9]+' ; then
DESCRIBE=$(git describe --match 'v*')
if ! VERSION=$(echo "$DESCRIBE" | grep -oP '(?<=^v)[0-9]+\.[0-9]+\.[0-9]+') ; then
fatal "Could not infer latest $BRANCH version from $DESCRIBE"
fi
TAGS="latest"
else
VERSION="$BRANCH"
TAGS="$VERSION"
fi
;;
esac
for TAG in $TAGS ; do
echo ">>> Publishing $PRODUCT $VERSION to $1/docs/$PRODUCT/$TAG"
wordepress \
--url "$1" --user "$2" --password "$3" \
--product "$PRODUCT" --version "$VERSION" --tag "$TAG" \
publish site
done
+173 -67
View File
@@ -10,15 +10,53 @@ RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION:-"Weaving Containers into Applications
PWD=`pwd`
setup() {
## Get the new version number from the most recent tag
if ! LATEST_TAG=$(git describe --abbrev=0 --match='v*' 2>/dev/null) ; then
echo "Could not find an annotated 'v*' version tag." >&2
exit 1
infer_release_type() {
if echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.0+$' ; then
echo MAINLINE
elif echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$' ; then
echo BRANCH
else
echo PRERELEASE
fi
}
setup() {
# Ensure we have exactly one annotated tag pointing at HEAD
HEAD_TAGS=$(git tag --points-at HEAD)
case $(echo $HEAD_TAGS | wc -w) in
1)
if [ $HEAD_TAGS != "latest_release" ] ; then
LATEST_TAG=$HEAD_TAGS
else
echo "Cannot determine version - latest_release points at HEAD" >&2
exit 1
fi
;;
0)
echo "Cannot determine version - no tags point at HEAD" >&2
exit 1
;;
*)
echo "Cannot determine version - multiple tags point at HEAD:" >&2
for TAG in $HEAD_TAGS ; do
echo -e "\t$TAG" >&2
done
exit 1
;;
esac
RELEASE_TYPE=$(infer_release_type $LATEST_TAG)
echo "== Inferred release type $RELEASE_TYPE from tag $LATEST_TAG"
LATEST_TAG_SHA=$(git rev-parse $LATEST_TAG)
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG)
LATEST_RELEASE_SHA=$(git rev-parse latest_release)
VERSION=${LATEST_TAG#v}
LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release)
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
}
@@ -39,8 +77,8 @@ build() {
cd $RELEASE_DIR
## Check that the top changelog entry is this version
if ! latest_changelog=$(grep -o "## Release [0-9].*" -m1 ./CHANGELOG.md) || \
! [ `echo "$latest_changelog" | grep -o '[0-9][^ ]*'` == "$VERSION" ]; then
if ! latest_changelog=$(grep -oP '(?<=^## Release ).*' -m1 ./CHANGELOG.md) || \
! [ `echo "$latest_changelog" = "$VERSION"` ]; then
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
exit 1
fi
@@ -51,6 +89,7 @@ build() {
## Inject the version numbers and build the distributables
## (library versions?)
sed -i "/SCRIPT_VERSION=/ c\SCRIPT_VERSION=\"$VERSION\"" ./weave
sed -i -e "s/:latest/:$VERSION/" -e "/imagePullPolicy: Always/d" ./prog/weave-kube/weave-daemonset.yaml
make SUDO=$SUDO WEAVE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER
if make tests; then
@@ -61,7 +100,7 @@ build() {
fi
## Run tests with the distributables, including version check
v=$(./weaver/weaver --version | grep -o '[0-9].*')
v=$(./prog/weaver/weaver --version | grep -oP '(?<=^weave router ).*')
if ! [ "$v" == "$VERSION" ]; then
echo "Version of distributable "$v" does not match release version $VERSION" >&2
exit 1
@@ -71,24 +110,13 @@ build() {
echo '** Release artefacts in' $RELEASE_DIR
}
publish() {
draft() {
setup
cd $PWD/$RELEASE_DIR
echo "== Sanity checks"
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
exit 1
fi
if ! [ $(git rev-list -1 $LATEST_TAG) == $(git rev-list -1 latest_release) ]; then
echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG"
exit 1
fi
## Check that the tag exists by looking at github
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/weave/git/tags/$LATEST_TAG_SHA >/dev/null 2>&1; then
echo -e "\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2
@@ -98,19 +126,9 @@ publish() {
exit 1
fi
## Check that the 'latest_release' tag exists by looking at github
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/weave/git/tags/$LATEST_RELEASE_SHA >/dev/null 2>&1; then
echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2
echo -e "\thttps://github.com/$GITHUB_USER/weave/tags" >&2
echo "You may need to" >&2
echo -e "\tgit tag -af latest_release"
echo -e "\tgit push -f git@github.com:$GITHUB_USER/weave latest_release"
exit 1
fi
echo -e "\u2713 Tag $LATEST_TAG exists in GitHub repo $GITHUB_USER/weave"
## Check that the version doesn't already exist by looking at github
## Check that the version does not already exist by looking at github
## releases
if github-release info --user $GITHUB_USER --repo weave --tag $LATEST_TAG >/dev/null 2>&1; then
echo -e "\u2757 Release $LATEST_TAG already exists on GitHub" >&2
@@ -120,13 +138,13 @@ publish() {
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/weave:$VERSION
echo "== Tagging and publishing images on docker hub as user $DOCKERHUB_USER"
make SUDO=$SUDO WEAVE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER publish
RELEASE_ARGS="--draft"
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then
RELEASE_ARGS="$RELEASE_ARGS --pre-release"
fi
echo "== Creating GitHub release $RELEASE_NAME $VERSION"
# This cannot be done as a draft because of a bug in
# github-release: https://github.com/aktau/github-release/issues/7
github-release release \
echo "== Creating GitHub release $RELEASE_ARGS $RELEASE_NAME $VERSION"
github-release release $RELEASE_ARGS \
--user $GITHUB_USER \
--repo weave \
--tag $LATEST_TAG \
@@ -140,52 +158,140 @@ publish() {
--name "weave" \
--file "./weave"
echo "** Published release $RELEASE_NAME $VERSION"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
if github-release info --user $GITHUB_USER --repo weave \
--tag latest_release >/dev/null 2>&1; then
github-release delete \
--user $GITHUB_USER \
--repo weave \
--tag latest_release
fi
github-release release \
--user $GITHUB_USER \
--repo weave \
--tag latest_release \
--name "$RELEASE_NAME latest ($VERSION)" \
--description "$RELEASE_DESCRIPTION"
github-release upload \
--user $GITHUB_USER \
--repo weave \
--tag latest_release \
--name "weave" \
--file "./weave"
--tag $LATEST_TAG \
--name "weave-daemonset.yaml" \
--file "./prog/weave-kube/weave-daemonset.yaml"
echo "** Published $RELEASE_NAME as latest_release at"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/latest_release"
echo "** Draft $TYPE $RELEASE_NAME $VERSION created at"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
}
publish() {
setup
cd $PWD/$RELEASE_DIR
IS_MAINLINE=false
if [ "$RELEASE_TYPE" = 'MAINLINE' ] ; then
IS_MAINLINE=true
fi
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER"
make UPDATE_LATEST=$IS_MAINLINE SUDO=$SUDO WEAVE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER publish
echo "** Docker images tagged and pushed"
echo "== Publishing pre-release on GitHub"
github-release publish \
--user $GITHUB_USER \
--repo weave \
--tag $LATEST_TAG
echo "** Pre-release $RELEASE_NAME $VERSION published at"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
else
echo "== Sanity checks"
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ] ; then
echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2
echo "You may need to" >&2
echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2
exit 1
fi
## Check that the 'latest_release' tag exists by looking at github
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/weave/git/tags/$LATEST_RELEASE_SHA >/dev/null 2>&1; then
echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2
echo -e "\thttps://github.com/$GITHUB_USER/weave/tags" >&2
echo "You may need to" >&2
echo -e "\tgit push -f git@github.com:$GITHUB_USER/weave latest_release" >&2
exit 1
fi
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/weave:$VERSION
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER"
make PUBLISH_WEAVEDB=$IS_MAINLINE UPDATE_LATEST=$IS_MAINLINE SUDO=$SUDO WEAVE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER publish
echo "** Docker images tagged and pushed"
echo "== Publishing release on GitHub"
github-release publish \
--user $GITHUB_USER \
--repo weave \
--tag $LATEST_TAG
if github-release info --user $GITHUB_USER --repo weave \
--tag latest_release >/dev/null 2>&1; then
github-release delete \
--user $GITHUB_USER \
--repo weave \
--tag latest_release
fi
github-release release \
--user $GITHUB_USER \
--repo weave \
--tag latest_release \
--name "$RELEASE_NAME latest ($VERSION)" \
--description "[Release Notes](https://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG)"
github-release upload \
--user $GITHUB_USER \
--repo weave \
--tag latest_release \
--name "weave" \
--file "./weave"
github-release upload \
--user $GITHUB_USER \
--repo weave \
--tag latest_release \
--name "weave-daemonset.yaml" \
--file "./prog/weave-kube/weave-daemonset.yaml"
echo "** Release $RELEASE_NAME $VERSION published at"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/latest_release"
fi
}
usage() {
echo "Usage:"
echo -e "\t./bin/release build"
echo "-- Build artefacts for the latest version tag"
echo -e "\t./bin/release draft"
echo "-- Create draft release with artefacts in GitHub"
echo -e "\t./bin/release publish"
echo "-- Publish the artefacts for the latest tag to GitHub and DockerHub"
echo "-- Publish the GitHub release and update DockerHub"
exit 1
}
case "$1" in
# Ensure required tooling is installed
if ! which github-release >/dev/null; then
echo "Please install git-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
[ $# -eq 0 ] && usage
COMMAND=$1
shift
case "$COMMAND" in
build)
build
build "$@"
;;
draft)
draft "$@"
;;
publish)
publish
publish "$@"
;;
*)
echo "Unknown command \"$1\""
echo "Unknown command \"$COMMAND\""
usage
;;
esac
-57
View File
@@ -1,57 +0,0 @@
#!/bin/sh
## This is the shape of unencrypted `do-setup-ci-secrets`
##
## cat > /tmp/boto_gsutil_cert.pem << EOF
## -----BEGIN PRIVATE KEY-----
## <...>
## -----END PRIVATE KEY-----
## EOF
##
## cat > ~/.boto << EOF
## [Credentials]
## gs_service_client_id = <...>
## gs_service_key_file = /tmp/boto_gsutil_cert.pem
##
## [Boto]
## https_validate_certificates = True
##
## [GSUtil]
## content_language = en
## default_api_version = 2
## default_project_id = <...>
## EOF
openssl base64 -d << EOF \
| openssl aes-256-cbc -d -K $1 -iv $2 \
-out bin/do-setup-ci-secrets
mOYNzNsAdwva0LbB2YFMY9VgL0SITFu1bPrbOujyLtOrBNjmOYbzR5d/sG+ARMFr
7NZ5OKcvMbItllz0n7TtNkzkCOMztMC870Wcx3nGJzbBephdcYwos4tBlp5bihTU
AXgxLUiDT1broYAFKnbE1aZC/XyNxuLTN+nXJWIWeijaXTgvhkEEm3tab+z7ioCb
tlg71W1BrUuocctAJAuVwH/uTZAaXaJGJj1s2S7F2DrFnG6sFlrp8rnCucPLWKnC
4IwJFC5saR5gxK6wECffwmwbpeXVOoQ58OgzxoZTEyAr9nhVbaBt5UZz3tfHlx8W
Rn5jHehACw5kg5eMtGPqMEksJ63LX4h3mfSTLJXJHEmOrzCRpFrigVrsbA408U2u
8jJTHJmKrGfwBh5ZFzBg6NuV4VplOp+ZquJLgegv2WH/iu/ciopXqB2YDCdx5ZBi
nHV2Puth7kjS4EMCKUGfeqpesjL9Djb8cygzv/J3ZBmLjNH9dqlSXWy2DcFZA1Iy
pFTTHkVU3w5sNz3nYOuT2UPQvULBW0FUndDKX6olyVa0mlxPwGBP9N3yGg918/rw
7rNV/r54lA334F5QMhDrVxar6sl9wfLA+Z+8qemBbNFlLog1uQGhuwWK2nFu1tRM
9uyvQIq0oq5NHKpogWc7NEuk7CPe1JyfRIcbMVj8+ilmKjUPB2HPC43IDmKt9/56
rY3IXAcxZ/ClGfGpeNHXqop9T/WhfaowponOZFcdGSUddG0OswqkTE4KIv71mgTF
jXooMkTQBOG+gBnCe+8bCRdRCG3anxHX74za4dGD58cOJtl6DYWnjWuR91NWnxdT
1Zr3iUe41txg9hCNY9LHo2QHGLPxe6pmNnSClQ1mcFhuY6NF8RmCX3HAGKJQkxJb
vpLGbXTXjAIFgIYgLNgKP2RLvCif/LmSWgkvE3ZU9GXtCUbm6xgJodwOqXiI9uuO
4H4+/vpGHnSFENiclkgMFrLG4yiMu8ArgmnCBzg9E2AoOX5zCrh/2ZRTU8Dk4mt7
jUd5SKQLsjB9QtB+y3tRO7zY9RDvR6iBOPRsjx6t8EJMCfPb06KchfMJw+VGxvMM
48jtmepREFnhd/8XDRGnw5bznjRuwohGik8BToltjIviMkkpifKWaLwlaOiDXaHh
VBFNXnUKvOBwRMU+PZqv4+DP2qff1gSXnGKqA5GIURYrK9P7TqHHNTnmjBdfJLzc
0x+W1DTiYhLT2vrLrkEpZ99o6qrg+lwvjat6IsJF8xoQEo4pLD/ZRPJ0WzoDyctT
oWZ5rMsN1TzTvJrBrTAWIJyhIzZcuNwChMrU6qogMr0fd6TSxWhWn0sOJ5y8AaTR
ej4JHx0qroS/9JPmgFYU61pX3c0ypdef/sSHWG23mcFzLTgwe2d4ty9VakypZy3T
sXCl6EHVVXlUFWhY4zQCjdZpYJv/rtoKL1BL4fPE2NV5WTjCL2GNvaO5SfHR7pA0
yQJR/iU+cS2n8UXsWNjyV+/qEn6+QXuyVHGLbxyH8EeqlliAbyHsc2rzVI8Xctzo
W5DuIqxwHAkNNurhmx27ktIIQ6HhaCp028SWwvLttkbBBgF4v1mmd4u/2bKbKjUd
dOaetaIUx1hU9OAeaePvVkeTDcc3mlFtPARCS9Fqj16hgJQ43onZyC0H1K2WAxmU
GsmzjCHlTNquzFTuuQihYGZKfsWIh9z6HEOkvNJ3VEQ=
EOF
exec sh bin/do-setup-ci-secrets
-115
View File
@@ -1,115 +0,0 @@
#!/bin/bash
set -eu
# openssl enc -in do-setup-circleci-secrets.orig -out setup-circleci-secrets.orig -e -aes256 -pass stdin
# openssl base64 < setup-circleci-secrets.orig
openssl base64 -d << EOF \
| openssl enc \
-out bin/do-setup-circleci-secrets \
-d -aes256 -pass pass:$1
U2FsdGVkX1/3QHnDgpZn0srp+GiEQBTlag0CBdsw6Bp6iaIKy6Jy8gFshrsmvl3+
c+7hn1nqsBVpzVH0S5QA3Ex5nx9rl7/dcGoogsySFcwMmBFcauT0UTMK1bvX0Hqx
QrshYSndUkww72KA7EsSnjR1BBJWm3AhCDOTIcnO6nQhig1Fc+SBEj5FGS5xTQ5Z
/8hDsKf54Ms49vOO6QeE5w5ndZ+k7IvVJfq9Evhb7htD20RntDhR86foAwMnLV7R
Wh9qAqI3gnRq0GmbeRKaHmB7pcLq9f0OdScqM/Tn1D+q0556fqJjBziXpZiGbxVs
DxEp8zDJ8yNDAi0Wb2NXjoA79SXJ8Q7iTieaST4y2OmXQpY+Vw8RVDXxi6ERyVnH
41OeMzyLm0qvCoMl32pe1sSG5DRCUiAm7wOtDTVvNDRqmGJYUgwwexyayecJI1wQ
LlhYLJavUvw3UGDZOld8BaMQhfOKBVCdFrjmA4HuVxmOf3029qkgzOCSZiQVNqs+
fvM6J05zBuk+GPy8YInvRkzfxum/x00vmUyGjMs/lHDFfrmYDFK3ux41EoVqvWLG
S5uYxdZJFdR3Xsrs+sMr51XNBQGMmz6KoEEzFYyHs5fZgtdpRdPAuQS1m6FqgZyi
wSz6+EKsALtmGorEp+CF8JN5YzKJCrKzNkg0fILBqsqmJZGP64lmX69950lRLNGM
/l3KVR2zH31b4AnnzTcvldVSCKDXjaMw3JA2Ce/MK6XhOWOcpEv4oDt/62lbhUKP
QUQTPbfpQRvVfBcoIrfAm3ghi/CZc2TDVEuD7DhasLTZD3r7LoK261BWC9O5Wubi
vlXuFIF+uyrpTDf6EJKE/+XywtArppffMP6RkHu1Iqnd8JtsqPaIZsmMmZbjgb6j
BX4ZLb5U9R7jYoSgIke4+u6geFcrMQ+Lny4r7MxXaS0Y1UJ6Jo1bwpYw1TBIobZc
eQ30+xhbSeRC9vEw1NXI6qM2Ai2gIHtAZvEiBkBBXTG5Ld7N/mBAmDIJEzVRxh6F
jRkB3dzESF6eeTBm61OQepwV3aW6lslMaf26drPGv2W2q+K/WOpQOejfggtHUgVs
9SWqtn7hHYSpIASe1Ihi14HAWv3kPhQien0zY1DLKJWf4ilbRaICn1QSJjNuKwtl
A2ZwEw7FFddFcsF4okHPkxEoCre3shq0DEw9UA1gnwEaEF1Q+i9cvLtQg56zK3+R
MfTzFUv2K1z3j1s5tC6Z6LzL8j682EFOll7MkihqiIWh+po1zcNs6Ln0SkjB3v9T
OFRYVJis9GqXYO9PUW1mI69udR4nXbKlBl5tWNyAxn9hufJHLSAmbGMwActKLRM5
kROapKrN1Ra/sHUmhoSSDUK9AXeYKkqPXVMbhly9xC1Kya4hFaFokjRQIMLPmXdQ
lP46RL3HOq0v1BkXg05poSwDm+BtitZkcIhOzcmeucUqn1whsz39y3VoOhJqQu2j
0dUcj19Fue1CDZfwzACb9mLZr643h0yCIHQaVT7is/yiN2vEt0S0zynvOA1D+Xgy
4bFdjqed9DgBShLwF/lh4/hur5iZPpVr9A8rt3Vq0k5A1tdjsZpXP3qv5jLc7lJv
cAQxdVLEuv8WPwwTV/EQsoH7lpoEdjktw/gu0v5PkUgR/WBxEqJq4liTekViQ+8X
BAmdm/FGWeIxSSEm0a8I+muiBpIuKjuQoJit1f0k+lLUohoVDqpDDfeYHh1TxXHE
xSKAKNmFSc2XOr5Zg2mOInxeH7WoxH6iylXKADBgEgAQ4C55DoAPRjFNtGGz2iJl
WkzhQOfgsDss1VxpPZ4SWDQO+xxuuEnYcCYdJ6Tyi5hAwZ0+RZmXx0g9BCK+5qzc
Ffei066kCItBcayekwCs0i86r8JvDtsMUUkzEKDQTSWHpP8ypIZoz3P+Skdqcs6p
IcZHy2fODIsClctRAsHOjZ9BnWSY2rqf1lysqvRfOkNTViTOUVx2hf+LuL+8rT6g
K4GvS39Q+c9FYSMjCNxv1m37NfHJv2W7AlqVV95gMBEFB97M3388T7PfvmSLsyPv
qAKDE7genTOycQvEX9oeEACxPo08ai2Mgs/YXCig0g0btZoScoKPelQKtD0HLpZ+
j7ruaKFy4/vySDMostB3AKSkCE/SkGu/W9oI37n1guSYC/9yJjtTcwZULXAClfwt
LyHvLAw4+7BdGJqDe9Tf8z4zqVLax+BcBHkW7pbP+pvxC6fhIA4PO8k5HwwAVlRw
68lG6e3z9+Vst4zrFLewHJvkDRSOTSecs9h9SPOjReTK0ovlDzMHVakfUvqpk9mv
nCj8SWaMPF70z138AuRuKN7X4exNXPBFnOcseKp/NpT1DyvgoHm/oIO65mq9vvo+
42uSbyyegYiTdVK4SaXBc2hixkhaTteqdEy6GxfWqKCvHtYuRD2LyUSjZn/0Y6CG
3wZapylKL1sxfH+b1gogv2wAA8KtZAfiTlMISuymwQr5RbOFma7UVMVecCa7XrNG
fZwO8R+6++ru0efDzeC/gtLOItjn+yVfsbk2gfu0FikHIV1sogOjnsv3dl6IpH/s
w6WbuK/yZhyrrmhIIueHF30ES512Peogf/Gxp8U/ZAmqBa7p4qsv93XWDR52IPYz
yU1MtboLD02J39daBNrYZuO4Yfo/xAvU7Ijg2KIR9HS0bSWNuSFAZaZXlJ2bSag3
8l0dZMx2fZa0FALxWvY2+nd1tWcH+Wo99RSxX+4TH3guCpe1x/58yKOKL4d1xRpu
02nGaqerV9bHU6WjCUYTrrZurTp6yqivpSFCALDMhAU5Ihd/Qjz69zg4uZ7iqbNd
WqIYJ3SAOei2tSfoOJbdh8mohotnMFFbupck3Fv+lXAXYDp0V/sSuK32MSeJxan1
q3t0eenAh6zoBP0Tj53N8B9YmrgZ1i1AljQqYsAdb8N5Z3vecuzQa946U8H4axEc
BL5fgmqSfsbj1EjJVUrw3cE9hgqeqAYBBvZsyW5zSAsLq/RJKYtBxDGADqr0TOOu
TjVqfPObb1u9EAQj15ALBhhPORa2gBAK5gnhJWW5deNgA0UOYoWARFYfATuQvr1T
9xTVbqzZ0VJR4n7X5JyxJo2tZ44QYVzA0fqX0lt+uRkarrkbZMgplKp4MJTFCp2N
tLciWS0YSHPbKTm7svw5mROazUvEoj1N3SYrJT+Ai9UgSL1cA4FmQ5Jsi+GOeQbH
7E4pzjeST4b1aATY9ZZSy4TzK+UNYBcCVqY1dN5Xnk0e5yPMnrkkcYI41s/6oOaW
lQkp/yrHkvpzQWZa7vF2yWg54j3eX8YWx/TsLvmuJmSQqiIHfu9TXcAIPDispCpF
gp4ZbYPZ8RDQLw3ROc+bZ9E0J8e+FHwgXEELsMLW9n4d3PTj9pLFej1vmBKa03o3
g+JViNxb1gUPNmC6ADk4o7TQzBrjV2pmmuCza16kOmq6oAbJPOeCLtVWA5HJTX8d
AuOzBLO37tWP457dNqoNDaCMik3LCy8cslZjAz02D6VG/QGOAXP9x8bJ3zg9N7vW
EOn1BMtIeMI4yIxpC6HgotNWDNbUBWremAFWYQRgYQqo9L1SdW4hz6X8FqdlBFvK
ml7sdUwjEy2tNW+aiZI4cgAlI/VvMWYr5kPfhvaUu1wGYeS1TD1B+DPcjcXpOGWo
vB1f/uvGc61zZWD0ph9f3S9OnvEko5qV3VhxOnxYUZTrqlM7LVgy/sHrSaPdR7Eo
nb4QGdi5wEGMxVgQlDGwOmEmS5nCaA0RcfHbkQV4SebRleocLB9qcSwj5JzPICAB
sn1qeSv45LnGdTzUnCQErw1EzgrK1FXOknujjZ3GX5dM7a6Gag0E6cAxoQeC8Mh0
aUWolyBo9aSXltn7Vnywoe4X3v96eVH6tUQtN3wt51LBlfSDTWOQDeXLFyW57oYL
/ErbmJLaSHpANBcC9InI+rxNYePTTba7K8rdPDppmMEmdOXjaL+5aPay2Bay9K8T
FUyZdoyrbzxFZYT9/YyVJV/ukVcT9ru3HpzLTg9Vgc/CyRfIvCZY/Gzh+pPUbRsR
pHYDT09BFS+mjszTkcdbceweYXJvknXpajMiISrPUUkb9rwCTmLS4QR4y7I9zAgJ
9U72mCZB9yhhzS17kyKAANihXvOFrMXCO7QTWZbtSkobMBS2SybDxYP3rM5b6824
HQaY4MZW5qCndydfz4fa908XbPTDka9Nu3CZfI3fhGiiGDFWViotGEYE4i9BuGZJ
vmtzII7zeIoHwM4t5fb5mYDd9H+Rkct1yATGEIFEx7cu1fj4Ht2177EzhdkF3Q6I
Fccn43yGDW06nFvEjnjb+Lz4EvtGp6dDefUhNBohdzd4Rm2o+etKobm0lZ1xOX74
2gOGBLfXS6PF+msNkWP76mqKE6hG0+R1iPrN06Arti+ZRBhNGJDp1pnOERl7IyB0
hiLUqae7xVSMVRDeq4O04EUpMXh5ixs3RJXjthYILt7vX+6qskJC3rMuyThrsvMi
Kk0wErDpzR5U7KFnM2fk4jY5by/0b/jHZ/PWFGnaFrXNOiwK/mV1RIJtg5FCrvMv
xJN5Qo7o2ZYzUL+IBf5mP5O49FCnz3e++9r4ySY/K57ybhQft1l+cQPWS7xuvVAg
wZGM9DPl9AhBus0I3V3XzfkcWWHkMynMRcfTnkBHrmKjMopIOggsq05JPalM9b0V
NfwZngVvTFbQejbGjgQQQ+G7spav/icCIA8Iu8JPHaKZt2IX77L1xMcQOouqMrx8
JCXnJ7zsuU+8W3GQGm70H2kcen4bf4beA8TSkFmbVsaqDNtGaG+ZopWO8ctZX3CP
jFgIYgEGi137IWvs1KD5QNFHZI6l0JMzglmvcfnViRPDHLi+EQXAoL/98j/YzA9t
a9L4xMO0oucovKkqYOS2cdFaQKVIUM9L5ibcbW7Tol4ugMo5ibIsTgjZoyFohG6t
acg+h2wTTyxtrIapvOOBeAo9V/iQowTAPQf38LKQZ5tApksiCG1qvJerKALTMp1J
yUHjTCPCPsaiXVVO0mfa9OPtzVvi/icLmlz7umk82mew13djedgMS3/ghq5aEHbg
e7rtI5snFlm/GQnV6IaCDytb+jYxqQ0DZ9Mb0CHcMpnLyiBO6nzHfadpZYlrxrpx
dPx9MVqfLavj1UVjKuVj4Mgec9J38IBBRGMJZ4MGhde2hrw/s2jVzG1BzaIzcvFa
bWiJOkKKRC4BY9DBDYfae5c/obwzkxLmvkbWAVzoFXc+46K1IK6bbC2a4EerOAxc
C7B3X8BucD8OtiPORwXgjctd9AJ7cXq0EEVGoZZ8jkILnklsK6RXsxrT4gSOGFpx
cBU7TF4kHpH+o4KGQmjlFA2VYP1tXirjEep57LOHfL+zy+HiSXdsbexf6odkqLYA
1RR0TzSkmqJYvP0GfHPMvp2xredx1kP934fhTIUcWvErrG3NPd/Dod4BzQye1nNK
8Y8aFYF6fACcD4SFZ11ecK9DJmB+WXGlsxtO3w1LeEysny2lVkkH6HuMRIzPyXAM
/sEpwh3hwPJosAh6vGM6JxuL7CXP8hC1oUvK91VR0hxeDcO/LgdcHtDnlNMqt1wC
jvYt9Hg+3aY5GehBnQPRppnIMaGhiBrRC6HjBg8Umt6UTUr5PXNY2aia5wRcx4M6
Tj0O0dAt8WWZ9ySgzOoq4SRoaAp6m4E7CpRNMgXH031OWEeHqtt8rsYqAcvcQLuW
vIwts5hiXZOfgXyR6SBY3ANE1SjDY46na2G4oiG8FI7eAqYgehjHrXqCnGrzjefE
V1eVcIr7DBYuM8wq7C9x+qdMir6RNV4MrVD+7rO/drivnd3MaqDHlG0LfMZo6GIK
QZGIy0z1W5lOXm9x3RAz7/Ea11ynkZyPDDxBE5NRcV6JfukdjDrvsaQA/Qk2Wo7h
PdUZjv17H4syMdap6tUDTc8Cohut6n1UxnDnhaAYEDGR3TgPqI5vEaJ+yoaM9itv
b2I/K+0uK6GfWwca7PeTtYn92/5etO4czG99xEBFzw7tiEmBTA8KfseZIUe/i3fr
9LO+rKEGalFB4mVTYyCKPYYx4hOIvjdCox/jEBTFyYUEhgGnZvArgw9XabvII7eM
c1FmwnN2CM/MHUzM0Kw7cS/oaoRFcG/PqioO/krL2Bd+xThwSH4Zn+Y1UVO7aXNy
90MOehHSc2nhN984Y2re3ffVsjPhC3KdWxr8jbho/Az65rUkYg64roiO2ZqdqRvf
aYtX9fCe8N8SzgLTlWZt+l8sjY8HP2k9NoajphV1nG4iC/pX0ZJiVQ+VBRNaGhSl
6IhM9gM1ZsI86cULJpOTAhNu1fZBv+Mq8IXYD8SqlNVwVtjvshtlzBN4InSGEKiO
HM7coo7aDuu+Go5AEiIVMbR09jAa0VINsCVScfSbTFhlGRTrZr2DSO/s8WxbV+Mb
EQAfZmyrLF71Z3MfIukg+ps5iuqFhZ+gJSXXSFwumpg=
EOF
exec sh bin/do-setup-circleci-secrets
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC2155
wait_for() {
local timeout=$1
local lock_file=$2
for i in $(seq 1 "$timeout"); do
if [ -f "$lock_file" ]; then
local status="$(cat "$lock_file")"
if [ "$status" == "OK" ]; then
echo "[$i seconds]: $lock_file found and status: $status." && return
else
echo "[$i seconds]: $lock_file found and status: $status." && return 1
fi
fi
if ! ((i % 10)); then echo "[$i seconds]: Waiting for $lock_file to be created..."; fi
sleep 1
done
echo "Timed out waiting for test VMs to be ready. See details in: $TEST_VMS_SETUP_OUTPUT_FILE" >&2
return 1
}
+77 -14
View File
@@ -1,21 +1,84 @@
FROM ubuntu
FROM golang:1.7.4
RUN apt-get -y update && apt-get -y install --no-install-recommends build-essential git ca-certificates docker.io mercurial libpcap-dev curl make pkg-config gcc bison flex
# Support Raspberry Pi 2 and newer
ENV GOARM 7
# When doing a build in a container, "apt-get update" happens twice,
# which can be a very significant overhead for incremental builds.
# And it's unnecessary, because if any of the prerequisites do change,
# the right thing to do is to rebuild the container image. Rather
# than suppressing the "apt-get update" commands explicitly, we clear
# out sources.list so that 'apt-get update' doesn't do anything.
RUN echo >/etc/apt/sources.list
# The names of the architectures that we're fetching cross-compilers for from the Ubuntu packages
ENV DEB_CROSSPLATFORMS \
armhf \
arm64
ENV GO_VERSION 1.4.2
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xz
ENV PATH /usr/local/go/bin:$PATH
# The go platforms we are supporting to cross-compile
ENV GO_CROSSPLATFORMS \
linux/arm \
linux/arm64
# So that sudo does not trample on PATH
RUN sed -ie '/secure_path/d' /etc/sudoers
# The names of the gcc cross-compilers we have installed
ENV GCC_CROSSCOMPILERS \
arm-linux-gnueabihf \
aarch64-linux-gnu
# Temporarily add the Ubuntu repositories, because we're going to install gcc cross-compilers from there
# Install the build-essential and crossbuild-essential-ARCH packages
RUN echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list.d/cgocrosscompiling.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32 \
&& apt-get update \
&& apt-get install -y build-essential \
&& for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
&& rm /etc/apt/sources.list.d/cgocrosscompiling.list \
&& apt-get update \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install some required packages
# libpcap is required because we're linking against its C libraries from the prog/weaver binary
# flex and bison are required packages for compiling libpcap manually later
RUN apt-get update \
&& apt-get install -y \
libpcap-dev \
python-requests \
time \
file \
flex \
bison
# Install common Go tools
RUN go get \
github.com/golang/lint/golint \
github.com/fzipp/gocyclo \
gopkg.in/mvdan/sh.v1/cmd/shfmt \
github.com/fatih/hclfmt \
github.com/client9/misspell/cmd/misspell
# First clean, because we're gonna rebuild the std both with -race enabled and disabled
# Running go install std twice is intentional and required, as content is written in two different directories
# (/usr/local/go/pkg/linux_amd64 vs /usr/local/go/pkg/linux_amd64_race)
# The other architectures do not have support for -race
RUN go clean -i net \
&& go install -tags netgo std \
&& go install -race -tags netgo std
# Prebuild std for the other architectures
RUN for platform in ${GO_CROSSPLATFORMS}; do \
GOOS=${platform%/*} GOARCH=${platform##*/} \
go install -tags netgo std; done
# Allow full write access to the Go folders for anyone
RUN chmod -R a+w /usr/local/go
# The libpcap version from Debian packages is 1.6.2, matching that version here although newer versions of libpcap have been released
# We have to cross-compile the libpcap library for the new architectures, that's what we're doing here
ENV LIBPCAP_CROSS_VERSION=1.6.2
RUN curl -sSL http://www.tcpdump.org/release/libpcap-${LIBPCAP_CROSS_VERSION}.tar.gz | tar -xz \
&& cd libpcap-${LIBPCAP_CROSS_VERSION} \
&& for crosscompiler in ${GCC_CROSSCOMPILERS}; do \
CC=${crosscompiler}-gcc ac_cv_linux_vers=2 ./configure --host=${crosscompiler} --with-pcap=linux \
&& make \
&& export LIB_DIR="/usr/local/lib/${crosscompiler}-gcc" VER="$(cat ./VERSION)" MAJOR_VER="$(sed 's/\([0-9][0-9]*\)\..*/\1/' ./VERSION)" \
&& mkdir -p ${LIB_DIR} \
&& cp -f libpcap.a libpcap.so.${VER} ${LIB_DIR} \
&& ln -sf libpcap.so.${VER} /usr/local/lib/libpcap.so.${MAJOR_VER} \
&& ln -sf libpcap.so.${MAJOR_VER} /usr/local/lib/libpcap.so \
&& make clean; done
COPY build.sh /
ENTRYPOINT ["sh", "/build.sh"]
+19 -35
View File
@@ -1,44 +1,28 @@
#!/bin/sh
set -e
GOPATH=/home/go
export GOPATH
set -eu
WEAVE_SRC=$GOPATH/src/github.com/weaveworks/weave
if [ $# -eq 0 ] ; then
# No arguments. Expect that the weave repo will be bind-mounted
# into $GOPATH
if ! [ -e $WEAVE_SRC ] ; then
cat 2>&1 <<EOF
No container arguments supplied, and nothing at ${WEAVE_SRC}. Please
either bind-mount the golang workspace containing weave with the
if ! [ -e $WEAVE_SRC ] ; then
cat 2>&1 <<EOF
Nothing at ${WEAVE_SRC}. Please bind-mount the weave repo with the
docker run -v option, e.g.:
$ docker run -v <host gopath>:${GOPATH} \\
-v /var/run/docker.sock:/var/run/docker.sock weaveworks/weave-build
Or supply git clone arguments to retrieve it, e.g.:
$ docker run -v /var/run/docker.sock:/var/run/docker.sock \\
weaveworks/weave-build https://github.com/weaveworks/weave.git
$ cd weave
$ docker run -v $(pwd):/go/src/github.com/weaveworks/weave \\
weaveworks/weave-build
EOF
exit 1
fi
# If we run make directly, any files created on the bind mount
# will have awkward ownership. So we switch to a user with the
# same user and group IDs as source directory. We have to set a
# few things up so that sudo works without complaining later on.
uid=$(stat --format="%u" $WEAVE_SRC)
gid=$(stat --format="%g" $WEAVE_SRC)
echo "weave:x:$uid:$gid::$WEAVE_SRC:/bin/sh" >>/etc/passwd
echo "weave:*:::::::" >>/etc/shadow
echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
su weave -c "PATH=$PATH make -C $WEAVE_SRC build"
else
# There are arguments to pass to git-clone
mkdir -p ${WEAVE_SRC%/*}
git clone "$@" $WEAVE_SRC
make -C $WEAVE_SRC build
fi
# If we run make directly, any files created on the bind mount
# will have awkward ownership. So we switch to a user with the
# same user and group IDs as source directory. We have to set a
# few things up so that sudo works without complaining later on.
uid=$(stat --format="%u" $WEAVE_SRC)
gid=$(stat --format="%g" $WEAVE_SRC)
echo "weave:x:$uid:$gid::$WEAVE_SRC:/bin/sh" >>/etc/passwd
echo "weave:*:::::::" >>/etc/shadow
echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
su weave -c "PATH=$PATH make -C $WEAVE_SRC BUILD_IN_CONTAINER=false $*"
+1
View File
@@ -0,0 +1 @@
8f313a9df867c207ae9ceac6e0935d1d2a0360aafce780dd5d1e0687ee98e0c3 docker-1.10.3.tgz
@@ -0,0 +1 @@
7541b5490cee1183d911f909c0e91d3d9d57b2b775e40f14a1a7a6de216ca4a8 docker-1.10.3.tgz
@@ -0,0 +1 @@
c02d861383d035ba020b361ef93bf14beb3964a42a6ae645b505b6148493e7ec qemu-aarch64-static
+1
View File
@@ -0,0 +1 @@
0ff63682b8868620d771aa812d3053dc3c579dc8633ce62d3d7ae7eee83beb06 qemu-arm-static
+52 -22
View File
@@ -2,45 +2,75 @@ general:
branches:
ignore:
- gh\-pages
- /pull\/.*/
machine:
pre:
- curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
services:
- docker
environment:
GOPATH: /home/ubuntu:$GOPATH
SRCDIR: /home/ubuntu/src/github.com/weaveworks/weave
PATH: $PATH:$HOME/.local/bin:$HOME/google-cloud-sdk/bin/
PATH: $PATH:$HOME/.local/bin
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
WEAVE_BUILD: $HOME/docker/weave-build.tar
STATE: /home/ubuntu/state.env
# Base name of VMs for integration tests:
NAME: test-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX
TEST_VMS_SETUP_OUTPUT_FILE: $CIRCLE_ARTIFACTS/test_vms_setup_output.txt
TEST_VMS_PROV_AND_CONF_LOCK_FILE: $CIRCLE_ARTIFACTS/test_vms_provisioned_and_configured.txt
TEST_VMS_READY_LOCK_FILE: $CIRCLE_ARTIFACTS/test_vms_ready.txt
# Google Cloud Platorm images for integration tests:
USE_IMAGE: 1
DISK_NAME_PREFIX: test-$CIRCLE_BUILD_NUM-0
dependencies:
cache_directories:
- "~/docker"
override:
- if [[ -e "$WEAVE_BUILD" ]]; then
docker load -i $WEAVE_BUILD;
else
docker pull weaveworks/weave-build;
mkdir -p $(dirname "$WEAVE_BUILD");
docker save weaveworks/weave-build >$WEAVE_BUILD;
fi
post:
- curl https://sdk.cloud.google.com | bash
- bin/setup-circleci-secrets "$SECRET_PASSWORD"
- mkdir -p $(dirname $SRCDIR)
- cp -r $(pwd)/ $SRCDIR
- bin/circle-dependencies-post-sources
# Provision & configure testing VMs:
- "while [ ! -d $SRCDIR ]; do sleep 1; done; $SRCDIR/bin/provision_test_vms.sh":
parallel: true
background: true
- bin/circle-dependencies-post
test:
pre:
- "$SRCDIR/bin/circle-test-pre":
parallel: true
background: true
override:
- docker run -v /var/run/docker.sock:/run/docker.sock -v /home/ubuntu:/home/go weaveworks/weave-build:
- "$SRCDIR/bin/circle-test-unit":
parallel: true
- cd $SRCDIR/test; ./gce.sh setup:
parallel: true
- cd $SRCDIR/test; . ./gce.sh hosts; ./setup.sh:
parallel: true
- cd $SRCDIR/test; . ./gce.sh hosts; ./run_all.sh:
- "$SRCDIR/bin/circle-test-smoke":
parallel: true
timeout: 300
post:
- cd $SRCDIR/test; ./gce.sh destroy:
- "$SRCDIR/bin/circle-test-teardown":
parallel: true
teardown:
pre:
# Destroy testing VMs:
- "cd $SRCDIR/test && ./run-integration-tests.sh destroy":
parallel: true
background: true
- "$SRCDIR/bin/circle-teardown-pre":
parallel: true
deployment:
release:
branch: /[0-9]+\.[0-9]+/
owner: weaveworks
commands:
- "$SRCDIR/bin/circle-deploy-release"
master:
branch: master
owner: weaveworks
commands:
- "$SRCDIR/bin/circle-deploy-master"
issues:
branch: /.*/
owner: weaveworks
commands:
- "$SRCDIR/bin/circle-deploy-issues"
+220
View File
@@ -0,0 +1,220 @@
package docker
import (
"errors"
"fmt"
"strings"
"time"
docker "github.com/fsouza/go-dockerclient"
"github.com/weaveworks/weave/common"
)
const (
InitialInterval = 1 * time.Second
MaxInterval = 20 * time.Second
)
// An observer for container events
type ContainerObserver interface {
ContainerStarted(ident string)
ContainerDied(ident string)
ContainerDestroyed(ident string)
}
type Client struct {
*docker.Client
}
type syncPair struct {
stop chan struct{}
done chan struct{}
}
type pendingStarts map[string]*syncPair
// NewClient creates a new Docker client and checks we can talk to Docker
func NewClient(apiPath string) (*Client, error) {
if apiPath != "" && !strings.Contains(apiPath, "://") {
apiPath = "tcp://" + apiPath
}
dc, err := docker.NewClient(apiPath)
if err != nil {
return nil, err
}
client := &Client{dc}
return client, client.checkWorking()
}
func NewVersionedClient(apiPath string, apiVersionString string) (*Client, error) {
if !strings.Contains(apiPath, "://") {
apiPath = "tcp://" + apiPath
}
dc, err := docker.NewVersionedClient(apiPath, apiVersionString)
if err != nil {
return nil, err
}
client := &Client{dc}
return client, client.checkWorking()
}
func NewVersionedClientFromEnv(apiVersionString string) (*Client, error) {
dc, err := docker.NewVersionedClientFromEnv(apiVersionString)
if err != nil {
return nil, err
}
client := &Client{dc}
return client, client.checkWorking()
}
func (c *Client) checkWorking() error {
_, err := c.Version()
return err
}
func (c *Client) Info() string {
env, err := c.Version()
if err != nil {
return fmt.Sprintf("Docker API error: %s", err)
}
return fmt.Sprintf("Docker API on %s: %v", c.Endpoint(), env)
}
func (c *Client) DockerVersion() string {
if env, err := c.Version(); err == nil {
if v, found := env.Map()["Version"]; found {
return v
}
}
return "unknown"
}
// AddObserver adds an observer for docker events
func (c *Client) AddObserver(ob ContainerObserver) error {
go func() {
pending := make(pendingStarts)
retryInterval := InitialInterval
for {
events := make(chan *docker.APIEvents)
if err := c.AddEventListener(events); err != nil {
c.errorf("Unable to add listener to Docker API: %s - retrying in %ds", err, retryInterval/time.Second)
} else {
start := time.Now()
for event := range events {
switch event.Status {
case "start":
pending.finish(event.ID)
pending.start(event.ID, c, ob)
case "die":
pending.finish(event.ID)
ob.ContainerDied(event.ID)
case "destroy":
pending.finish(event.ID)
ob.ContainerDestroyed(event.ID)
}
}
if time.Since(start) > retryInterval {
retryInterval = InitialInterval
}
c.errorf("Event listener channel closed - retrying subscription in %ds", retryInterval/time.Second)
}
time.Sleep(retryInterval)
retryInterval = retryInterval * 3 / 2
if retryInterval > MaxInterval {
retryInterval = MaxInterval
}
}
}()
return nil
}
// Docker sends a 'start' event before it has attempted to start the
// container. Delay notifying the observer until the container has a
// pid, or we are told to stop when a 'die' event arrives.
//
// Note we always deliver the event, even if the container seems to
// have gone away.
func (pending pendingStarts) start(id string, c *Client, ob ContainerObserver) {
sync := syncPair{make(chan struct{}), make(chan struct{})}
pending[id] = &sync
go func() {
defer close(sync.done)
defer ob.ContainerStarted(id)
for {
if container, err := c.InspectContainer(id); err != nil || container.State.Pid != 0 {
return
}
select {
case <-sync.stop:
return
case <-time.After(200 * time.Millisecond):
}
}
}()
}
func (pending pendingStarts) finish(id string) {
if sync, found := pending[id]; found {
close(sync.stop)
<-sync.done
delete(pending, id)
}
}
func (c *Client) AllContainerIDs() ([]string, error) {
all, err := c.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
return nil, err
}
var ids []string
for _, c := range all {
ids = append(ids, c.ID)
}
return ids, nil
}
// IsContainerNotRunning returns true if we have checked with Docker that the ID is not running
func (c *Client) IsContainerNotRunning(idStr string) bool {
container, err := c.InspectContainer(idStr)
if err == nil {
return !container.State.Running || container.State.Restarting
}
if _, notThere := err.(*docker.NoSuchContainer); notThere {
return true
}
c.errorf("Could not check container status: %s", err)
return false
}
// This is intended to find an IP address that we can reach the container on;
// if it is on the Docker bridge network then that address; if on the host network
// then localhost
func (c *Client) GetContainerIP(nameOrID string) (string, error) {
info, err := c.InspectContainer(nameOrID)
if err != nil {
return "", err
}
if info.NetworkSettings.Networks != nil {
if bridgeNetwork, ok := info.NetworkSettings.Networks["bridge"]; ok {
return bridgeNetwork.IPAddress, nil
} else if _, ok := info.NetworkSettings.Networks["host"]; ok {
return "127.0.0.1", nil
}
} else if info.HostConfig.NetworkMode == "host" {
return "127.0.0.1", nil
}
if info.NetworkSettings.IPAddress == "" {
return "", errors.New("No IP address found for container " + nameOrID)
}
return info.NetworkSettings.IPAddress, nil
}
// logging
func (c *Client) errorf(fmt string, args ...interface{}) {
common.Log.Errorf("[docker] "+fmt, args...)
}
-20
View File
@@ -1,20 +0,0 @@
package common
func CheckFatal(e error) {
if e != nil {
Error.Fatal(e)
}
}
func CheckWarn(e error) {
if e != nil {
Warning.Println(e)
}
}
// Assert test is true, panic otherwise
func Assert(test bool) {
if !test {
panic("Assertion failure")
}
}
+18
View File
@@ -0,0 +1,18 @@
package common
import (
"net/http"
)
type loggingHandler struct {
next http.Handler
}
func (l *loggingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Log.Debugf("[http] %s %s", r.Method, r.URL.RequestURI())
l.next.ServeHTTP(w, r)
}
func LoggingHTTPHandler(h http.Handler) http.Handler {
return &loggingHandler{next: h}
}
-10
View File
@@ -1,10 +0,0 @@
package common
import (
"io/ioutil"
"os"
)
func init() {
InitLogging(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
}
+71 -25
View File
@@ -1,41 +1,87 @@
package common
import (
"io"
"io/ioutil"
"bytes"
"fmt"
"log"
"os"
"strings"
"github.com/Sirupsen/logrus"
)
const (
standardLogFlags = log.Ldate | log.Ltime | log.Lmicroseconds
)
type textFormatter struct {
}
// Largely taken from
// http://www.goinggo.net/2013/11/using-log-package-in-go.html
// Based off logrus.TextFormatter, which behaves completely
// differently when you don't want colored output
func (f *textFormatter) Format(entry *logrus.Entry) ([]byte, error) {
b := &bytes.Buffer{}
levelText := strings.ToUpper(entry.Level.String())[0:4]
timeStamp := entry.Time.Format("2006/01/02 15:04:05.000000")
if len(entry.Data) > 0 {
fmt.Fprintf(b, "%s: %s %-44s ", levelText, timeStamp, entry.Message)
for k, v := range entry.Data {
fmt.Fprintf(b, " %s=%v", k, v)
}
} else {
// No padding when there's no fields
fmt.Fprintf(b, "%s: %s %s", levelText, timeStamp, entry.Message)
}
b.WriteByte('\n')
return b.Bytes(), nil
}
var (
Debug *log.Logger
Info *log.Logger
Warning *log.Logger
Error *log.Logger
standardTextFormatter = &textFormatter{}
)
func InitLogging(debugHandle io.Writer,
infoHandle io.Writer,
warningHandle io.Writer,
errorHandle io.Writer) {
var (
Log *logrus.Logger
)
Debug = log.New(debugHandle, "DEBUG: ", standardLogFlags)
Info = log.New(infoHandle, "INFO: ", standardLogFlags)
Warning = log.New(warningHandle, "WARNING: ", standardLogFlags)
Error = log.New(errorHandle, "ERROR: ", standardLogFlags)
func init() {
Log = logrus.New()
Log.Formatter = standardTextFormatter
}
func InitDefaultLogging(debug bool) {
debugOut := ioutil.Discard
if debug {
debugOut = os.Stderr
func SetLogLevel(levelname string) {
level, err := logrus.ParseLevel(levelname)
if err != nil {
Log.Fatal(err)
}
InitLogging(debugOut, os.Stdout, os.Stdout, os.Stderr)
Log.Level = level
}
func CheckFatal(e error) {
if e != nil {
Log.Fatal(e)
}
}
func CheckWarn(e error) {
if e != nil {
Log.Warnln(e)
}
}
// Adaptor type to go from Logrus to something expecting a standard library log.Logger
type logLogger struct {
logger *logrus.Logger
}
// io.Writer interface
func (l logLogger) Write(p []byte) (n int, err error) {
ln := len(p)
// Strip a trailing newline, because logrus formatter adds one
if ln > 0 && p[ln-1] == '\n' {
p = p[:ln-1]
}
l.logger.Info(string(p))
return ln, nil
}
func LogLogger() *log.Logger {
return log.New(logLogger{Log}, "", 0)
}
+91
View File
@@ -0,0 +1,91 @@
package odp
import (
"fmt"
"net"
"syscall"
"github.com/weaveworks/go-odp/odp"
)
// ODP admin functionality
func CreateDatapath(dpname string) (supported bool, err error) {
dpif, err := odp.NewDpif()
if err != nil {
if odp.IsKernelLacksODPError(err) {
return false, nil
}
return true, err
}
defer dpif.Close()
dp, err := dpif.CreateDatapath(dpname)
if err != nil {
if !odp.IsDatapathNameAlreadyExistsError(err) {
return true, err
}
if dp, err = dpif.LookupDatapath(dpname); err != nil {
return true, err
}
}
// Pick an ephemeral port number to use in probing for vxlan
// support.
udpconn, err := net.ListenUDP("udp4", nil)
if err != nil {
return true, err
}
defer udpconn.Close()
// we leave the UDP socket open, so creating a vxlan vport on
// the same port number should fail. But that's fine: It's
// still sufficient to probe for support.
portno := uint16(udpconn.LocalAddr().(*net.UDPAddr).Port)
vpid, err := dp.CreateVport(odp.NewVxlanVportSpec(fmt.Sprintf("vxlan-%d", portno), portno))
if nlerr, ok := err.(odp.NetlinkError); ok {
if syscall.Errno(nlerr) == syscall.EAFNOSUPPORT {
dp.Delete()
return false, fmt.Errorf("kernel does not have Open vSwitch VXLAN support")
}
}
if err == nil {
dp.DeleteVport(vpid)
}
return true, nil
}
func DeleteDatapath(dpname string) error {
dpif, err := odp.NewDpif()
if err != nil {
return err
}
defer dpif.Close()
dp, err := dpif.LookupDatapath(dpname)
if err != nil {
if odp.IsNoSuchDatapathError(err) {
return nil
}
return err
}
return dp.Delete()
}
func AddDatapathInterface(dpname string, ifname string) error {
dpif, err := odp.NewDpif()
if err != nil {
return err
}
defer dpif.Close()
dp, err := dpif.LookupDatapath(dpname)
if err != nil {
return err
}
_, err = dp.CreateVport(odp.NewNetdevVportSpec(ifname))
return err
}
+27
View File
@@ -0,0 +1,27 @@
package common
import (
"os"
"strconv"
)
func AllPids(procRoot string) ([]int, error) {
fh, err := os.Open(procRoot)
if err != nil {
return nil, err
}
defer fh.Close()
dirNames, err := fh.Readdirnames(-1)
if err != nil {
return nil, err
}
pids := make([]int, len(dirNames))
for _, dirName := range dirNames {
pid, err := strconv.Atoi(dirName)
if err != nil { // Only interested in numeric entries - skip /proc/stat, etc.
continue
}
pids = append(pids, pid)
}
return pids, err
}
-37
View File
@@ -1,37 +0,0 @@
package common
import (
"os"
"os/signal"
"runtime"
"syscall"
)
// A subsystem/server/... that can be stopped or queried about the status with a signal
type SignalReceiver interface {
Stop() error
Status() string
}
func SignalHandlerLoop(ss ...SignalReceiver) {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGUSR1)
buf := make([]byte, 1<<20)
for {
switch <-sigs {
case syscall.SIGINT:
Info.Printf("=== received SIGINT ===\n*** exiting\n")
for _, subsystem := range ss {
subsystem.Stop()
}
return
case syscall.SIGQUIT:
stacklen := runtime.Stack(buf, true)
Info.Printf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
case syscall.SIGUSR1:
for _, subsystem := range ss {
Info.Printf("=== received SIGUSR1 ===\n*** status...\n%s\n*** end\n", subsystem.Status())
}
}
}
}
-47
View File
@@ -1,47 +0,0 @@
package updater
import (
"github.com/fsouza/go-dockerclient"
. "github.com/weaveworks/weave/common"
)
type ContainerObserver interface {
ContainerDied(ident string) error
}
func checkError(err error, apiPath string) {
if err != nil {
Error.Fatalf("[updater] Unable to connect to Docker API on %s: %s",
apiPath, err)
}
}
func Start(apiPath string, ob ContainerObserver) error {
client, err := docker.NewClient(apiPath)
checkError(err, apiPath)
env, err := client.Version()
checkError(err, apiPath)
events := make(chan *docker.APIEvents)
err = client.AddEventListener(events)
checkError(err, apiPath)
Info.Printf("[updater] Using Docker API on %s: %v", apiPath, env)
go func() {
for event := range events {
handleEvent(ob, event, client)
}
}()
return nil
}
func handleEvent(ob ContainerObserver, event *docker.APIEvents, client *docker.Client) error {
switch event.Status {
case "die":
id := event.ID
ob.ContainerDied(id)
}
return nil
}
+18
View File
@@ -0,0 +1,18 @@
package common
import "strings"
// Assert test is true, panic otherwise
func Assert(test bool) {
if !test {
panic("Assertion failure")
}
}
func ErrorMessages(errors []error) string {
var result []string
for _, err := range errors {
result = append(result, err.Error())
}
return strings.Join(result, "\n")
}
+109
View File
@@ -0,0 +1,109 @@
package db
import (
"bytes"
"encoding/gob"
"fmt"
"time"
"github.com/boltdb/bolt"
)
type DB interface {
Load(string, interface{}) (bool, error)
Save(string, interface{}) error
}
type BoltDB struct {
db *bolt.DB
}
var (
versionIdent = []byte("version")
persistenceVersion = []byte{1, 0} // major.minor
topBucket = []byte("top")
)
const (
NameIdent = "peername"
FileName = "data.db"
)
func NewBoltDB(dbPathname string) (*BoltDB, error) {
db, err := bolt.Open(dbPathname, 0660, nil)
if err != nil {
return nil, fmt.Errorf("[boltDB] Unable to open %s: %s", dbPathname, err)
}
err = db.Update(checkVersion(false))
return &BoltDB{db: db}, err
}
func NewBoltDBReadOnly(dbPathname string) (*BoltDB, error) {
options := bolt.Options{Timeout: time.Millisecond * 50, ReadOnly: true}
db, err := bolt.Open(dbPathname, 0660, &options)
if err != nil {
return nil, fmt.Errorf("[boltDB] Unable to open %s: %s", dbPathname, err)
}
err = db.View(checkVersion(true))
if err != nil {
return nil, fmt.Errorf("[boltDB] Cannot use persistence file %s: %s", dbPathname, err)
}
return &BoltDB{db: db}, nil
}
func checkVersion(readOnly bool) func(tx *bolt.Tx) error {
return func(tx *bolt.Tx) error {
if top := tx.Bucket(topBucket); top == nil {
if readOnly {
return fmt.Errorf("no top bucket")
}
top, err := tx.CreateBucket(topBucket)
if err != nil {
return err
}
if err := top.Put(versionIdent, persistenceVersion); err != nil {
return err
}
} else {
if checkVersion := top.Get(versionIdent); checkVersion != nil {
if checkVersion[0] != persistenceVersion[0] {
return fmt.Errorf("mismatched version %x", checkVersion)
}
}
}
return nil
}
}
func (d *BoltDB) Load(ident string, data interface{}) (bool, error) {
found := true
err := d.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket(topBucket)
v := b.Get([]byte(ident))
if v == nil {
found = false
return nil
}
reader := bytes.NewReader(v)
decoder := gob.NewDecoder(reader)
err := decoder.Decode(data)
return err
})
return found, err
}
func (d *BoltDB) Save(ident string, data interface{}) error {
return d.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(topBucket)
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
if err := enc.Encode(data); err != nil {
return err
}
return b.Put([]byte(ident), buf.Bytes())
})
}
func (d *BoltDB) Close() error {
return d.db.Close()
}
+14 -14
View File
@@ -34,7 +34,7 @@ Router:
the known locations of peers as they're discovered and is informed
when connections we have made die. It proactively tries to create
connections to remote peers we're not connected to using a random
binary exponential backoff to regulate the period between connection
exponential backoff to regulate the period between connection
attempts.
- Local Peer
@@ -66,23 +66,23 @@ Router:
simply responds to traffic received from the remote peer via TCP
5. We register this connection with the local peer
6a. If we initiated this connection then we now start sending fast
heartbeats to the remote peer so that the remote peer can determine what
address/port it should use to send UDP back to us. To do this, we
spawn off two further threads which are the forwarder
loops. These receive frames which are to be sent to the remote
peer. One of them sends frames without the DF flag set. To do this
it just sends the packets out of the UDP Listener socket. The
other needs to send frames with the DF flag set and needs its own
socket so that it can do PMTU discovery easily. To do this, it
uses a Raw IP socket (IP has no ports, so there's no collision
issue with the UDP Listener socket) and so it must add UDP headers
itself.
6b. If we did not initiate this connection then the UDP Listener
heartbeats to the remote peer so that the remote peer can
determine what address/port it should use to send UDP back to
us. To do this, we spawn off a "forwarder" thread to send
heartbeats, monitor incoming heartbeats, and some other auxiliary
duties. It also consumes frames to be encapsulated and send via
UDP from two channels, for DF and non-DF cases. In the non-DF
case, it can just send the packets out of the UDP Listener
socket. In the DF case, it needs its own socket so that it can do
PMTU discovery easily. To do this, it uses a Raw IP socket (IP has
no ports, so there's no collision issue with the UDP Listener
socket) and so it must add UDP headers itself.
6b. If we did not initiate this connection then the UDP Listener
should start receiving fast heartbeats from the remote peer. From
those it should be able to identify the local connection via the
local peer. It will tell the local connection (communicating to
the actor thread) about the UDP address of the remote peer. The
local connection will then start its forwarder threads as
local connection will then start its forwarder thread as
described in 6a, and start sending fast heartbeats. We send to the
remote peer via TCP a ConnectionEstablished message. The remote
peer receives this (on the TCP receiver process), tells the
+2 -2
View File
@@ -125,8 +125,8 @@ VM2> nc 192.168.122.2 6783
If all is well, you should now be able to launch weave on VM1
then on VM2:
VM1> weaver -iface veth6 -name vm1
VM2> weaver -iface veth6 -name vm2 192.168.122.2
VM1> weaver --iface veth6 --name vm1
VM2> weaver --iface veth6 --name vm2 192.168.122.2
Once the connection is up and running, you should be able to connect
from VM1/ns2 to VM2/ns2 and vice versa:
+155
View File
@@ -0,0 +1,155 @@
This document describes implementation details of the fast datapath encryption.
# Overview
At the high level, we use the ESP protocol ([RFC 2406][esp]) in the Transport
mode. Each packet is encrypted with AES in GCM mode ([RFC 4106][aesgcm]), with
32 byte key and 4 byte salt. This combo provides the following security
properties:
* Data confidentiality.
* Data origin authentication.
* Integrity.
* Anti-replay.
* Limited traffic flow confidentiality as fast datapath VXLAN packets are fully
encrypted.
## Notation
* `SAin`: IPsec security association for inbound connections.
* `SAout`: IPsec security association for outbound connections.
* `SPout`: IPsec security policy for outbound connections. Used to match
outbound flows to SAout.
## SA Key Derivation
For each connection direction, a different AES-GCM key and salt is used.
The pairs are derived with HKDF ([RFC 5869][hkdf]):
```
SAin[KeyAndSalt] = HKDF(sha256, ikm=sessionKey, salt=nonceIn, info=localPeerName)
SAout[KeyAndSalt] = HKDF(sha256, ikm=sessionKey, salt=nonceOut, info=remotePeerName)
```
Where:
* the mutual `sessionKey` is derived by the [Mesh][mesh] library during
the control plane connection establishment between the local peer and
the remote peer.
* `nonceIn` and `nonceOut` are randomly generated 32byte nonces which
are exchanged over the encrypted control plane channel.
## SPI
A directional secure connection between two peers is identified with SPI.
The kernel requires the pair of SPI and dst IP to be unique among security
associations. Thus, to avoid collisions, we generate outbound SPI on a remote
peer.
## Connection Establishment
```
Peer A Peer B
-----------------------------------------------------------------------------------------------------------------
fastdp.fwd.Confirm():
install iptables blocking rules, fastdp.fwd.Confirm():
nonce_BA = rand(), install iptables blocking rules,
{key,salt}_BA = hkdf(sessionKey, nonce_BA, A), nonce_AB = rand(),
spi_BA = allocspi(), {key,salt}_AB = hkdf(sessionKey, nonce_AB, B),
create SA_BA(B<-A, spi_BA, key_BA, salt_BA), spi_AB = allocspi(),
send InitSARemote(spi_BA, nonce_BA). --> create SA_AB(A<-B, spi_AB, key_AB, salt_AB),
<-- send InitSARemote(spi_AB, nonce_AB).
--> recv InitSARemote(spi_BA, nonce_BA):
recv InitSARemote(spi_AB, nonce_AB): <-- {key,salt}_BA = hkdf(sessionKey, nonce_BA, A),
{key,salt}_AB = hkdf(sessionKey, nonce_AB, B), create SA_BA(B<-A, spi_BA, key_BA, salt_BA),
create SA_AB(A<-B, spi_AB, key_AB, salt_AB), create SP_BA(B<-A, spi_BA),
create SP_AB(A<-B, spi_AB), install marking rule.
install marking rule.
```
# Implementation Details
## XFRM
The implementation is based on the kernel IP packet transformation framework
called XFRM. Unfortunately, docs are barely existing and the complexity of
the framework is high. The best resource I found is Chapter 10 in
"Linux Kernel Networking: Implementation and Theory" by Rami Rosen.
## iptables Rules
The kernel VXLAN driver does not set a dst port of a tunnel in the ip flow
descriptor, thus XFRM policy lookup cannot match a policy (SPout) which includes
the port. This makes impossible to encrypt only tunneled traffic between
peers. To work around, we mark such outgoing packets with iptables and set
the same mark in the policy selector (funnily enough, `iptables_mangle` module
eventually sets the missing dst port in the flow descriptor). The challenge
here is to pick a mark that it would not interfere with other networking
applications before OUTPUT'ing a packet. For example, Kubernetes by default
uses 1<<14 and 1<<15 marks and we choose 1<<17 (0x20000). Additionally,
such workaround brings the requirement for at least the 4.2 kernel.
The marking rules are the following:
```
iptables -t mangle -A OUTPUT -j WEAVE-IPSEC-OUT
iptables -t mangle -A WEAVE-IPSEC-OUT -s ${LOCAL_PEER_IP} -d ${REMOTE_PEER_IP} \
-p udp --dport ${TUNNEL_PORT} -j WEAVE-IPSEC-OUT-MARK
iptables -t mangle -A WEAVE-IPSEC-OUT-MARK --set-xmark ${MARK} -j MARK
```
As Linux does not implement [IP Security Levels][ipseclevel], we install
additional iptables rules to prevent from accidentally sending unencrypted
traffic between peers which have previously established the secure connection.
For inbound traffic, we mark each ESP packet with the mark and drop non-marked
tunnel traffic:
```
iptables -t mangle -A INPUT -j WEAVE-IPSEC-IN
iptables -t mangle -A WEAVE-IPSEC-IN -s ${REMOTE_PEER_IP} -d ${LOCAL_PEER_IP} \
-m esp --espspi ${SPIin} -j WEAVE-IPSEC-IN-MARK
iptables -t mangle -A WEAVE-IPSEC-IN-MARK --set-xmark ${MARK} -j MARK
iptables -t filter -A INPUT -j WEAVE-IPSEC-IN
iptables -t filter -A WEAVE-IPSEC-IN -s ${REMOTE_PEER_IP} -d ${LOCAL_PEER_IP} \
-p udp --dport ${TUNNEL_PORT} -m mark ! --mark ${MARK} -j DROP
```
For outbound traffic, we drop marked traffic which does not match any SPout:
```
iptables -t filter -A OUTPUT ! -p esp -m policy --dir out --pol none \
-m mark --mark ${MARK} -j DROP
```
## ESN
To prevent from cycling SeqNo which makes replay attacks possible, we use
64-bit extended sequence numbers known as [ESN](esn).
## MTU
In addition to the VXLAN overhead, the MTU calculation should take into account
the ESP overhead which is 34-37 bytes (encrypted Payload is 4 bytes aligned) and
consists of:
* 4 bytes (SPI).
* 4 bytes (Sequence Number).
* 8 bytes (ESP IV).
* 1 byte (Pad Length).
* 1 byte (NextHeader).
* 16 bytes (ICV).
* 0-3 bytes (Padding).
[esp]: https://tools.ietf.org/html/rfc2406
[aesgcm]: https://tools.ietf.org/html/rfc4106
[hkdf]: https://tools.ietf.org/html/rfc5869
[esn]: https://tools.ietf.org/html/rfc4304
[ipseclevel]: https://tools.ietf.org/html/draft-mcdonald-simple-ipsec-api-01)
[mesh]: https://github.com/weaveworks/mesh
+170
View File
@@ -0,0 +1,170 @@
# Overlay Method Selection
Weave automatically selects the best working overlay implementation
when connecting to a new peer. It does this by initiating both
forwarders in parallel, eventually settling on the most preferred
established forwarder at which point the other forwarder is shut down,
assuming it had not failed already. In the event that the remaining
forwarder fails at a later time (e.g. because of a heartbeat timeout)
the control plane TCP connection will recycle allowing the selection
algorithm to run again. By default fast datapath is preferred over
Sleeve.
# Local Bridging
Unlike the weave bridge netdev used by Sleeve, the OVS datapath has no
inherent bridging capability. Consequently fastdp implements an
ethernet bridge in addition to the vxlan overlay, maintaining its own
forwarding database by learning MAC addresses and dispatching
broadcast, unicast & multicast traffic accordingly.
# Short Peer IDs
The router relies on having access to the source and destination peer
when deciding how to forward packets. When the Sleeve overlay is in
use this information is conveyed directly within the encapsulation by
including the names of the peers in question, a solution not
accommodated directly by the vxlan wire format. Fortunately vxlan does
have a twenty four bit segment ID field in the header we can use to
encode this data - the challenge is to identify peers uniquely with a
twelve bit identifier instead of the seventeen bytes used by Sleeve.
In practice this is achieved by peers adopting a random 'short ID' and
resolving ownership collisions of same via the existing gossip
mechanism.
# Heartbeats via vxlan
Heartbeats are implemented by sending an encapsulated ethernet frame
with source and destination MAC addresses of `00:00:00:00:00:00` and a
payload consisting of the connection UID and total ethernet frame
length. The vxlan vport miss handler on the receiving side detects the
all-zero addresses and acknowledges the heartbeat via the TCP control
channel after validating the connection UID and frame length against
their expected values.
# PMTU Discovery
The length of the heartbeat ethernet frame is set to the MTU of the
datapath interface. In the event the vxlan packet is dropped or
truncated, the heartbeat will not be acknowledged; this lack of
acknowledgement will cause the peers to fall back to the Sleeve
overlay, which has a more sophisticated dynamic mechanism for coping
with low path MTUs.
To avoid triggering this fallback in typical deployments, the datapath
interface is statically configured with an MTU of 1376 bytes allowing
it to work with most underlay network provider MTUs, including GCE at
1460 bytes (the eighty four byte difference accommodates the encrypted vxlan overhead).
This value can be overridden by setting `WEAVE_MTU` at launch if
necessary.
# Virtual Ports
There are three kinds of virtual port associated with the weave
datapath:
* `internal` - one of these is created automatically, named after the
datapath. It corresponds to the network interface of the same name
that appears on the host when the datapath is created; it is the
ingress/egress port for `weave expose`
* `netdev` - one for each application container, corresponding to the
host end of the veth pair
* `vxlan` - one for each UDP port on which we are listening for vxlan
encapsulated packets. Typically there is only one of these, but
there may be more in a network in which peers do not all use the same
port configuration
# Misses and Flow Creation
As mentioned above, the datapath has no inherent behaviour - any
ingressing packet which does not match a flow is passed to a userspace
miss handler. The miss handler is then responsible for a) instructing
the datapath to take actions for the packet that caused the miss (for
example by copying it to one or more ports) and optionally b)
installing flow rules which will allow the datapath to act on similar
packets in future without invoking the miss handler.
At a high level the fast datapath implementation can be viewed as a
set of miss handlers that determine what actions the OVS datapath
should take based on router topology information, together with some
additional machinery that manages the expiry of resulting flows when
that state changes.
When a miss handler is invoked, it has two pieces of context: a byte
array containing the packet that triggered the miss, and a set of
'flow keys' that have been extracted from the packet by the kernel
module. The following flow keys are of interest to weave:
* `InPort` - the identifier of the ingress virtual port
* `Ethernet` - the source and destination MAC addresses of the
ethernet frame
* `Tunnel` - tunnel identifier (see section on short peer IDs above),
and source/dest IPv4 addresses. Only present for ingress via a vxlan
vport
Crucially, the router must use this information alone to determine
which actions to take - this allows the specification of a flow which
matches these keys and instructs the kernel to take action
automatically in future without further userspace involvement.
Two actions are of interest:
* `Output` - output the packet to the specified vport
* `SetTunnel` - update the effective vxlan tunnel parameters. Only
required prior to output from a vxlan vport
It is possible to have multiple actions in a flow, so the router can
for example create a single rule that copies broadcast traffic to all
'local' vports (save the ingress vport obviously) as well as to vxlan
vports for onward peers as dictated by the routing topology.
Every flow specified by the router has the following characteristics:
* An `InPort` key matching the ingress vport
* A `Tunnel` key if the ingress vport is of type vxlan
* An `Ethernet` key matching the source and destination MAC
* A list of `Output` (for internal and netdev vports) and
`SetTunnel`+`Output` (for vxlan vports) actions
Under certain circumstances the miss handler will instruct the
datapath to execute a set of actions for a packet without creating a
corresponding flow:
* When broadcasting packets to discover the path to unknown
destination MACs. This condition is transient in the overwhelming
majority of cases and so the benefit of creating a flow is
outweighed by the need to invalidate it once the MAC is learned
* When the packet also needs to be forwarded to one or more peers via
Sleeve. In this case the router needs to handle all subsequent
matching packets as there is no OVS flow action to do it without
userspace involvement
# Flow Invalidation
Once a flow has been created for a particular combination of keys, the
miss handler will never again be invoked for matching packets. It is
therefore extremely important that we detect events which invalidate
existing flow actions:
* Addition of netdev vports to the datapath
* Route invalidation (topology change)
* Short peer ID collision
The response in each case is the same - delete all flows from the
datapath, allowing them to be recreated taking into account the
updated state.
In addition to these event based invalidations there is an expiry
process that executes every five minutes. This process enumerates all
flows in the datapath, removing any which have not been used since the
last check; this cleans up:
* Flows referring to netdev vports which have been removed
* Flows created by forwarders which have been stopped
* Flows related to MAC addresses which have not communicated recently
Flows keyed on tunnel IPv4 address do not need to be cleared when a
peer appears to change IP address due to NAT; this will cause a miss
resulting in a new flow, and the old flow will expire naturally via
the timer mechanism.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 43 KiB

+32 -18
View File
@@ -20,11 +20,16 @@ plugin) uses to request IP addresses.
The commands supported by the allocator via the http interface are:
- Allocate: request one IP address for a container
- Allocate: request one IP address for a container in a subnet
- Lookup: fetch the previously-allocated IP address for a container in a subnet
- Free: return an IP address that is currently allocated
- Claim: request a specific IP address for a container (e.g. because
it is already using that address)
Each http request either specifies a subnet, or if no subnet is
specified this is taken as a request to allocate in a pre-defined
default subnet.
The allocator also watches via the Docker event mechanism: if a
container dies then all IP addresses allocated to that container are
freed.
@@ -48,25 +53,42 @@ freed.
When a peer owns some range(s), it can allocate freely from within
those ranges to containers on the same machine. If it runs out of
space (all owned ranges are full), it will ask another peer for space:
space in a subnet (all owned ranges are full), it will ask another
peer for space:
- it picks a peer to ask at random, weighted by the amount of space
owned by each peer
owned by each peer in the subnet
- if the target peer decides to give up space, it unicasts a message
back to the asker with the newly-updated ring.
- if the target peer has no space, it unicasts a message back to the
asker with its current copy of the ring, on the basis that the
requestor must have acted on out-of-date information.
- it will continue to ask for space until it receives some, or its
copy of the ring tells it all peers are full.
copy of the ring tells it all peers are full in that subnet.
### Data persistence
Key IPAM data is saved to disk, in a [BoltDB](https://github.com/boltdb/bolt)
file, stored within a [data volume container](https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container)
named `weavedb`.
This file is used to persist data for various Weave Net components; for IPAM it contains:
* the division of the IP allocation range amongst peers, and
* allocation of addresses to containers on the local peer,
so that it is immediately available when the peer restarts.
### Claiming an address
If a Weave process is restarted, in most cases it will hear from
another peer which ranges it used to own, but it needs to know which
individual IP addresses are assigned to containers in order to avoid
giving the same address out in subsequent allocation requests. The
weave script invokes the `claim` command in `populate_ipam` to do
this.
If a Weave process is restarted,
- if `weavedb` is present, then it loads persisted IPAM data from there, as
described, in the previous section;
- else, it learns from other peers which ranges it used to own.
Weave Net then consults the allocator to know which individual IP addresses
are assigned to containers, and therefore avoid giving the same address out in
subsequent allocation requests.
When the Allocator is told to claim an address, there are four
possibilities:
@@ -204,11 +226,3 @@ reached the peer that does the `rmpeer`, then we get an inconsistent
ring. We could make it safe, up to partitions, by inquiring of every
live peer what its view of the dead peer is, and making sure we use
the latest info.)
## Limitations
Nothing is persisted. If one peer restarts it should receive gossip
from other peers showing what it used to own, and in that case it can
recover quite well. If, however, there are no peers left alive, or
this peer cannot establish network communication with those that are,
then it cannot recover.
+157
View File
@@ -0,0 +1,157 @@
# Release Process
## Prerequisites
* Up-to-date versions of `git`, `go` etc
* Install GitHub release tool `go get github.com/weaveworks/github-release`
* Create a [github token for
github-release](https://help.github.com/articles/creating-an-access-token-for-command-line-use/);
set and export `$GITHUB_TOKEN` with this value
## Release Types
The release script behaves differently depending on the kind of
release you are doing. There are three types:
* **Mainline** - a release (typically from master) with version tag
`vX.Y.Z` where Z is zero (e.g. `v2.1.0`)
* **Branch** - a bugfix release (typically from a branch) with version tag
`vX.Y.Z` where Z is non-zero (e.g `v2.1.1`)
* **Prerelease** - a release from an arbitrary branch with an arbitrary
version tag (e.g. `feature-preview-20150904`)
N.B. the release script _infers the release type from the format of the
version tag_. Ensure your tag is in the correct format and the desired
behaviours for that type of release will be obtained from the script.
## Build Phase
### Update CHANGELOG.md
* Checkout the branch from which you wish to release
* 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` for **Prerelease** builds, `## Release ${TAG#v}` otherwise.
Commit the changelog update:
git commit -m "Add release $TAG" CHANGELOG.md
### Create Version Tag
Next you must tag the changelog commit with `$TAG`
git tag -a -m "Release $TAG" $TAG
### Execute Build
You are now ready to perform the build. If you have skipped the
previous steps (e.g. because you're doing a rebuild), you must ensure
that `HEAD` points to the tagged commit. You may then execute
bin/release build
This has the following effects:
* `git tag --points-at HEAD` is used to determine `$TAG` (hence the
`HEAD` requirement)
* Your *local* repository is cloned into `releases/$TAG`
* `CHANGELOG.md` is checked to ensure it has an entry for `$TAG`
* Distributables injected with `$TAG` are built
* Tests are executed
## Draft Phase
### Push Version Tag Upstream
First you must push your branch and version tag upstream, so that an
associated GitHub release may be created:
git push git@github.com:weaveworks/weave
git push git@github.com:weaveworks/weave $TAG
N.B. if you're testing the release process, push to your fork
instead!
### Create Draft Release
You're now ready to draft your release notes:
bin/release draft
This has the following effects:
* A [release](https://help.github.com/articles/about-releases) is
created in GitHub for `$TAG`. This release is in the draft state, so
it is only visible to contributors; for **Prerelease** builds the
pre-release attribute will also be set
* The `weave` script is uploaded as an attachment to the release
Navigate to https://github.com/weaveworks/weave/releases, 'Edit' the
draft and input the release notes. When you are done make sure you
'Save draft' (and not 'Publish release'!).
Once the release notes have passed review, proceed to the publish
phase.
## Publish Phase
### Move/Force Push `latest_release` Tag
This step must only be performed for **Mainline** and **Branch**
releases:
git tag -af -m "Release $TAG" latest_release $TAG
git push -f git@github.com:weaveworks/weave latest_release
The `latest_release` tag *must* point at `$TAG`, *not* at `HEAD` -
the build script will complain otherwise.
N.B. if you're testing the release process, push to your fork
instead!
### Publish Release & Distributable Artefacts
You can now publish the release and upload the remaining
distributables to DockerHub:
bin/release publish
The effects of this step depend on the inferred release type. The
following occurs for all types:
* Docker images are tagged `$TAG` and pushed to DockerHub
* GitHub release moves from draft to published state
Additionally, for **Mainline** and **Branch** types:
* Release named `latest_release` is updated on GitHub
Finally, for **Mainline** releases only:
* Images tagged `latest` are updated on DockerHub
### Finish up
* If not on master, merge branch into master and push to GitHub.
* Close the [milestone](https://github.com/weaveworks/weave/milestones) in GitHub and create the next milestone
* Update the `#weavenetwork` topic heading on freenode (requires 'chanops' permission)
* For a mainline release vX.Y.0, create a release branch X.Y from the
tag and push to GitHub - this will result in X.Y.0 site docs being
published to https://www.weave.works
* Add the new version of `weave-net` to the checkpoint system at
https://checkpoint-api.weave.works/admin
* File a PR to update the version of the daemonset at
https://github.com/kubernetes/kops/tree/master/upup/models/cloudup/resources/addons/networking.weave
## Troubleshooting
There's a few things that can go wrong.
* If the build is wonky, e.g., the tests don't pass, you can delete
the directory in `./releases/`, fix whatever it is, move the
version tag (which should still be only local) and have another go.
* If the DockerHub pushes fail (which sadly seems to happen a lot),
you can just run `./bin/release publish` again.
* If you need to overwrite a release you can do so by manually
deleting the GitHub version release and re-running the process.
Please note that the DockerHub `latest` images, GitHub
`latest_release` and download links may be in an inconsistent state
until the overwrite is completed.
+83
View File
@@ -0,0 +1,83 @@
---
title: WeaveDNS (service discovery) Design Notes
layout: default
---
# WeaveDNS (service discovery) Design Notes
The model is that each host has a service that is notified of
hostnames and weave addresses for containers on the host. Like IPAM,
this service is embedded within the router. It binds to
the host bridge to answer DNS queries from local containers; for
anything it can't answer, it uses the information in the host's
/etc/resolv.conf to query an 'fallback' server.
The service is comprised of a DNS server, which answers all DNS queries
from containers, and a in-memory database of hostnames and IPs. The
database on each node contains a complete copy of the hostnames and IPs
for every containers in the cluster.
For hostname queries in the local domain (default weave.local), the DNS
server will consult the in-memory database. For reverse queries, we
first consult the local database, and if not found we query the
upstream server. For all other queries, we consult the upstream
server.
Updates to the in-memory database are broadcast to other DNS servers
within the cluster. The in-memory database only contains entries from
connected DNS servers; if a DNS server becomes partitioned from the
cluster, entries belonging to that server are removed from each node in
the cluster. When the partitioned DNS server reconnects, the entries
are re-broadcast around the cluster.
The DNS server also listens to the Docker event stream, and removes
entries for containers when they die. Entries removed in this way are
tombstoned, and the tombstone lazily broadcast around the cluster.
After a short timeout the tombstones are independently removed from
each host.
## DNS server API
The DNS server accepts HTTP requests on the following URL (patterns)
and methods:
`PUT /name/<identifier>/<ip-address>`
Put a record for an IP, bound to a host-scoped identifier (e.g., a
container ID), in the DNS database. The request body must contain
a `fqdn=foo.weave.local` key pair.
`DELETE /name/<identifier>/<ip-address>`
Remove a specific record for an IP and host-scoped identifier. The request
body can optionally contain a `fqdn=foo.weave.local` key pair.
`DELETE /name/<identifier>`
Remove all records for the host-scoped identifier.
`GET /name/<fqdn>`
List of all IPs (in JSON format) for givne FQDN.
## DNS updater
The updater component uses the Docker remote API to monitor containers
coming and going, and tells the DNS server to update its records via
its HTTP interface. It does not need to be attached to the weave
network.
The updater starts by subscribing to the events, and getting a list of
the current containers. Any containers given a domain ending with
".weave" are considered for inclusion in the name database.
When it sees a container start or stop, the updater checks the weave
network attachment of the container, and updates the DNS server.
> How does it check the network attachment from within a container?
> Will it need to delay slightly so that `attach` has a chance to run?
> Perhaps it could put containers on a watch list when it's noticed
> them.
+106
View File
@@ -0,0 +1,106 @@
# Overview
# ipsets
The policy controller maintains a number of ipsets which are
subsequently referred to by the iptables rules used to effect network
policy specifications. These ipsets are created, modified and
destroyed automatically in response to Pod, Namespace and
NetworkPolicy object updates from the k8s API server:
* A `hash:ip` set per namespace, containing the IP addresses of all
pods in that namespace
* A `list:set` per distinct (across all network policies in all
namespaces) namespace selector mentioned in a network policy,
containing the names of any of the above hash:ip sets whose
corresponding namespace labels match the selector
* A `hash:ip` set for each distinct (within the scope of the
containing network policy's namespace) pod selector mentioned in a
network policy, containing the IP addresses of all pods in the
namespace whose labels match that selector
IPsets are implemented by the kernel module `xt_set`, without which
weave-npc will not work.
ipset names are generated deterministically from a string
representation of the corresponding label selector. Because ipset
names are limited to 31 characters in length, this is done by taking a
SHA hash of the selector string and then printing that out as a base
85 string with a "weave-" prefix e.g.:
weave-k?Z;25^M}|1s7P3|H9i;*;MhG
Because pod selectors are scoped to a namespace, we need to make sure
that if the same selector definition is used in different namespaces
that we maintain distinct ipsets. Consequently, for such selectors the
namespace name is prepended to the label selector string before
hashing to avoid clashes.
# iptables chains
The policy controller maintains two iptables chains in response to
changes to pods, namespaces and network policies. One chain contains
the ingress rules that implement the network policy specifications,
and the other is used to bypass the ingress rules for namespaces which
have an ingress isolation policy of `DefaultAllow`.
## Dynamically maintained `WEAVE-NPC-DEFAULT` chain
The policy controller maintains a rule in this chain for every
namespace whose ingress isolation policy is `DefaultAllow`. The
purpose of this rule is simply to ACCEPT any traffic destined for such
namespaces before it reaches the ingress chain.
```
iptables -A WEAVE-NPC-DEFAULT -m set --match-set $NSIPSET dst -j ACCEPT
```
## Dynamically maintained `WEAVE-NPC-INGRESS` chain
For each namespace network policy ingress rule peer/port combination:
```
iptables -A WEAVE-NPC-INGRESS -p $PROTO [-m set --match-set $SRCSET] -m set --match-set $DSTSET --dport $DPORT -j ACCEPT
```
## Static `WEAVE-NPC` chain
Static configuration:
```
iptables -A WEAVE-NPC -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A WEAVE-NPC -m state --state NEW -j WEAVE-NPC-DEFAULT
iptables -A WEAVE-NPC -m state --state NEW -j WEAVE-NPC-INGRESS
```
# Steering traffic into the policy engine
To direct traffic into the policy engine:
iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j WEAVE-NPC
iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j DROP
Note this only affects traffic which egresses the bridge on a physical
port which is not the Weave Net router - in other words, it is
destined for an application container veth. The following traffic is
affected:
* Traffic bridged between local application containers
* Traffic bridged from the router to a local application container
* Traffic originating from the internet destined for nodeports - this
is routed via the FORWARD chain to a container pod IP after DNAT
The following traffic is NOT affected:
* Traffic bridged from a local application container to the router
* Traffic originating from processes in the host network namespace
(e.g. kubelet health checks)
* Traffic routed from an application container to the internet
The above mechanism relies on the kernel module `br_netfilter` being
loaded and enabled via `/proc/sys/net/bridge/bridge-nf-call-iptables`.
See these resources for helpful context:
* http://ebtables.netfilter.org/br_fw_ia/br_fw_ia.html
* https://commons.wikimedia.org/wiki/File:Netfilter-packet-flow.svg
-61
View File
@@ -1,61 +0,0 @@
package address
import (
"github.com/weaveworks/weave/common"
"net"
)
// Using 32-bit integer to represent IPv4 address
type Address uint32
type Offset uint32
type Range struct {
Start, End Address // [Start, End); Start <= End
}
func ParseIP(s string) (Address, error) {
if ip := net.ParseIP(s); ip == nil {
return 0, &net.ParseError{Type: "IP Address", Text: s}
} else {
return FromIP4(ip), nil
}
}
// FromIP4 converts an ipv4 address to our integer address type
func FromIP4(ip4 net.IP) (r Address) {
for _, b := range ip4.To4() {
r <<= 8
r |= Address(b)
}
return
}
// IP4 converts our integer address type to an ipv4 address
func (addr Address) IP4() (r net.IP) {
r = make([]byte, net.IPv4len)
for i := 3; i >= 0; i-- {
r[i] = byte(addr)
addr >>= 8
}
return
}
func (addr Address) String() string {
return addr.IP4().String()
}
func Add(addr Address, i Offset) Address {
return addr + Address(i)
}
func Subtract(a, b Address) Offset {
common.Assert(a >= b)
return Offset(a - b)
}
func Min(a, b Offset) Offset {
if a > b {
return b
}
return a
}
+34 -16
View File
@@ -2,7 +2,9 @@ package ipam
import (
"fmt"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/api"
"github.com/weaveworks/weave/net/address"
)
type allocateResult struct {
@@ -12,8 +14,10 @@ type allocateResult struct {
type allocate struct {
resultChan chan<- allocateResult
ident string // a container ID, something like "weave:expose", or api.NoContainerID
r address.CIDR // Subnet we are trying to allocate within
isContainer bool // true if ident is a container ID
hasBeenCancelled func() bool
ident string
}
// Try returns true if the request is completed, false if pending
@@ -23,34 +27,48 @@ func (g *allocate) Try(alloc *Allocator) bool {
return true
}
// If we have previously stored an address for this container, return it.
if addr, found := alloc.owned[g.ident]; found {
g.resultChan <- allocateResult{addr, nil}
if addrs := alloc.ownedInRange(g.ident, g.r.Range()); len(addrs) > 0 {
// If we had heard that this container died, resurrect it
delete(alloc.dead, g.ident) // delete is no-op if key not in map
g.resultChan <- allocateResult{addrs[0].Addr, nil}
return true
}
if ok, addr := alloc.space.Allocate(); ok {
alloc.debugln("Allocated", addr, "for", g.ident)
alloc.addOwned(g.ident, addr)
if !alloc.universe.Range().Overlaps(g.r.Range()) {
g.resultChan <- allocateResult{err: fmt.Errorf("range %s out of bounds: %s", g.r, alloc.universe)}
return true
}
alloc.establishRing()
if ok, addr := alloc.space.Allocate(g.r.HostRange()); ok {
// If caller hasn't supplied a unique ID, file it under the IP address
// which lets the caller then release the address using DELETE /ip/address
if g.ident == api.NoContainerID {
g.ident = addr.String()
}
alloc.debugln("Allocated", addr, "for", g.ident, "in", g.r)
alloc.addOwned(g.ident, address.MakeCIDR(g.r, addr), g.isContainer)
g.resultChan <- allocateResult{addr, nil}
return true
}
// out of space
if donor, err := alloc.ring.ChoosePeerToAskForSpace(); err == nil {
alloc.debugln("Decided to ask peer", donor, "for space")
alloc.sendRequest(donor, msgSpaceRequest)
donors := alloc.ring.ChoosePeersToAskForSpace(g.r.Addr, g.r.Range().End)
for _, donor := range donors {
if err := alloc.sendSpaceRequest(donor, g.r.Range()); err != nil {
alloc.debugln("Problem asking peer", donor, "for space:", err)
} else {
alloc.debugln("Decided to ask peer", donor, "for space in range", g.r)
break
}
}
return false
}
func (g *allocate) Cancel() {
g.resultChan <- allocateResult{0, fmt.Errorf("Allocate request for %s cancelled", g.ident)}
}
func (g *allocate) String() string {
return fmt.Sprintf("Allocate for %s", g.ident)
g.resultChan <- allocateResult{err: &errorCancelled{"Allocate", g.ident}}
}
func (g *allocate) ForContainer(ident string) bool {
+679 -258
View File
File diff suppressed because it is too large. Load diff
+346 -144
View File
@@ -7,10 +7,11 @@ import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/router"
wt "github.com/weaveworks/weave/testing"
"github.com/weaveworks/weave/net/address"
"github.com/weaveworks/weave/testing/gossip"
)
const (
@@ -19,46 +20,82 @@ const (
testStart3 = "10.0.3.0"
)
func returnFalse() bool { return false }
func (alloc *Allocator) SimplyAllocate(ident string, cidr address.CIDR) (address.Address, error) {
return alloc.Allocate(ident, cidr, true, returnFalse)
}
func (alloc *Allocator) SimplyClaim(ident string, cidr address.CIDR) error {
return alloc.Claim(ident, cidr, true, true, returnFalse)
}
func TestAllocFree(t *testing.T) {
const (
container1 = "abcdef"
container2 = "baddf00d"
container3 = "b01df00d"
universe = "10.0.3.0/28"
testAddr1 = "10.0.3.1" // first address allocated should be .1 because .0 is network addr
spaceSize = 14 // 16 IP addresses in /28, minus .0 and .15
universe = "10.0.3.0/26"
subnet1 = "10.0.3.0/28"
subnet2 = "10.0.3.32/28"
testAddr1 = "10.0.3.1"
testAddr2 = "10.0.3.33"
spaceSize = 62 // 64 IP addresses in /26, minus .0 and .63
)
alloc := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", universe, 1)
alloc, subnet := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", universe, 1)
defer alloc.Stop()
cidr1, _ := address.ParseCIDR(subnet1)
cidr2, _ := address.ParseCIDR(subnet2)
alloc.claimRingForTesting()
addr1, _ := alloc.Allocate(container1, nil)
wt.AssertEqualString(t, addr1.String(), testAddr1, "address")
addr1, err := alloc.SimplyAllocate(container1, cidr1)
require.NoError(t, err)
require.Equal(t, testAddr1, addr1.String(), "address")
addr2, err := alloc.SimplyAllocate(container1, cidr2)
require.NoError(t, err)
require.Equal(t, testAddr2, addr2.String(), "address")
addrs, err := alloc.Lookup(container1, subnet.Range())
require.NoError(t, err)
require.Equal(t, []address.CIDR{address.MakeCIDR(cidr1, addr1), address.MakeCIDR(cidr2, addr2)}, addrs)
// Ask for another address for a different container and check it's different
addr2, _ := alloc.Allocate(container2, nil)
if addr2.String() == testAddr1 {
t.Fatalf("Expected different address but got %s", addr2.String())
addr1b, _ := alloc.SimplyAllocate(container2, cidr1)
if addr1b.String() == testAddr1 {
t.Fatalf("Expected different address but got %s", addr1b.String())
}
// Ask for the first container again and we should get the same address again
addr1a, _ := alloc.Allocate(container1, nil)
wt.AssertEqualString(t, addr1a.String(), testAddr1, "address")
// Ask for the first container again and we should get the same addresses again
addr1a, _ := alloc.SimplyAllocate(container1, cidr1)
require.Equal(t, testAddr1, addr1a.String(), "address")
addr2a, _ := alloc.SimplyAllocate(container1, cidr2)
require.Equal(t, testAddr2, addr2a.String(), "address")
// Now free the first one, and we should get it back when we ask
wt.AssertSuccess(t, alloc.Free(container1))
addr3, _ := alloc.Allocate(container3, nil)
wt.AssertEqualString(t, addr3.String(), testAddr1, "address")
// Now delete the first container, and we should get its addresses back
require.NoError(t, alloc.Delete(container1))
addr3, _ := alloc.SimplyAllocate(container3, cidr1)
require.Equal(t, testAddr1, addr3.String(), "address")
addr4, _ := alloc.SimplyAllocate(container3, cidr2)
require.Equal(t, testAddr2, addr4.String(), "address")
alloc.ContainerDied(container2)
// Resurrect
addr1c, err := alloc.SimplyAllocate(container2, cidr1)
require.NoError(t, err)
require.Equal(t, addr1b, addr1c, "address")
alloc.ContainerDied(container3)
alloc.String() // force sync-up after async call
wt.AssertEquals(t, alloc.space.NumFreeAddresses(), address.Offset(spaceSize))
alloc.Encode() // sync up
// Move the clock forward and clear out the dead container
alloc.actionChan <- func() { alloc.now = func() time.Time { return time.Now().Add(containerDiedTimeout * 2) } }
alloc.actionChan <- func() { alloc.removeDeadContainers() }
require.Equal(t, address.Count(spaceSize+1), alloc.NumFreeAddresses(subnet.Range()))
}
func TestBootstrap(t *testing.T) {
common.InitDefaultLogging(false)
const (
donateSize = 5
donateStart = "10.0.1.7"
@@ -66,21 +103,21 @@ func TestBootstrap(t *testing.T) {
peerNameString = "02:00:00:02:00:00"
)
alloc1 := makeAllocatorWithMockGossip(t, ourNameString, testStart1+"/22", 2)
alloc1, subnet := makeAllocatorWithMockGossip(t, ourNameString, testStart1+"/22", 2)
defer alloc1.Stop()
// Simulate another peer on the gossip network
alloc2 := makeAllocatorWithMockGossip(t, peerNameString, testStart1+"/22", 2)
alloc2, _ := makeAllocatorWithMockGossip(t, peerNameString, testStart1+"/22", 2)
defer alloc2.Stop()
alloc1.OnGossipBroadcast(alloc2.encode())
alloc1.OnGossipBroadcast(alloc2.ourName, alloc2.Encode())
alloc1.tryPendingOps()
alloc1.actionChan <- func() { alloc1.tryPendingOps() }
ExpectBroadcastMessage(alloc1, nil) // alloc1 will try to form consensus
done := make(chan bool)
go func() {
alloc1.Allocate("somecontainer", nil)
alloc1.Allocate("somecontainer", subnet, true, returnFalse)
done <- true
}()
time.Sleep(100 * time.Millisecond)
@@ -88,26 +125,37 @@ func TestBootstrap(t *testing.T) {
CheckAllExpectedMessagesSent(alloc1, alloc2)
alloc1.tryPendingOps()
// Check that tryPendingOps doesn't cause anything to happen here
alloc1.actionChan <- func() { alloc1.tryPendingOps() }
AssertNothingSent(t, done)
CheckAllExpectedMessagesSent(alloc1, alloc2)
// alloc2 receives paxos update and broadcasts its reply
ExpectBroadcastMessage(alloc2, nil)
alloc2.OnGossipBroadcast(alloc1.encode())
alloc2.OnGossipBroadcast(alloc1.ourName, alloc1.Encode())
ExpectBroadcastMessage(alloc1, nil)
alloc1.OnGossipBroadcast(alloc2.encode())
alloc1.OnGossipBroadcast(alloc2.ourName, alloc2.Encode())
// both nodes will get consensus now so initialize the ring
CheckAllExpectedMessagesSent(alloc1, alloc2)
// at this point, both nodes have seen each other, but don't have a valid proposal
// so there is another exchange of messages
ExpectBroadcastMessage(alloc2, nil)
ExpectBroadcastMessage(alloc2, nil)
alloc2.OnGossipBroadcast(alloc1.encode())
alloc2.OnGossipBroadcast(alloc1.ourName, alloc1.Encode())
// we have consensus now so alloc1 will initialize the ring
ExpectBroadcastMessage(alloc1, nil)
alloc1.OnGossipBroadcast(alloc2.ourName, alloc2.Encode())
CheckAllExpectedMessagesSent(alloc1, alloc2)
// alloc2 receives the ring and does not reply
alloc2.OnGossipBroadcast(alloc1.ourName, alloc1.Encode())
CheckAllExpectedMessagesSent(alloc1, alloc2)
alloc1.OnGossipBroadcast(alloc2.encode())
// now alloc1 should have space
AssertSent(t, done)
@@ -118,26 +166,54 @@ func TestBootstrap(t *testing.T) {
func TestAllocatorClaim(t *testing.T) {
const (
container1 = "abcdef"
container2 = "baddf00d"
container3 = "b01df00d"
universe = "10.0.3.0/30"
testAddr1 = "10.0.3.1" // first address allocated should be .1 because .0 is network addr
universe = "10.0.3.0/24"
testAddr1 = "10.0.3.5/24"
testAddr2 = "10.0.4.2/24"
testPre = "10.0.3.1/24"
)
alloc := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", universe, 1)
defer alloc.Stop()
preAddr, _ := address.ParseCIDR(testPre)
allocs, router, subnet := makeNetworkOfAllocators(2, universe, []PreClaim{{container1, true, preAddr}})
defer stopNetworkOfAllocators(allocs, router)
alloc := allocs[1]
addr1, _ := address.ParseCIDR(testAddr1)
alloc.claimRingForTesting()
addr1, _ := alloc.Allocate(container1, nil)
alloc.Allocate(container2, nil)
// First claim should trigger "dunno, I'm going to wait"
err := alloc.SimplyClaim(container3, addr1)
require.NoError(t, err)
// Now free the first one, and try to claim it
wt.AssertSuccess(t, alloc.Free(container1))
t.Log(alloc)
err := alloc.Claim(container3, addr1, nil)
wt.AssertNoErr(t, err)
addr3, _ := alloc.Allocate(container3, nil)
wt.AssertEqualString(t, addr3.String(), testAddr1, "address")
alloc.Prime()
// Do an allocate on the other peer, which we will try to claim later
addrx, err := allocs[0].Allocate(container1, subnet, true, returnFalse)
// Should not get the address we pre-claimed
require.NotEqual(t, addrx, preAddr)
router.Flush()
// Now try the claim again
err = alloc.SimplyClaim(container3, addr1)
require.NoError(t, err)
// Check we get this address back if we try an allocate
addr3, _ := alloc.SimplyAllocate(container3, subnet)
require.Equal(t, testAddr1, address.MakeCIDR(subnet, addr3).String(), "address")
// one more claim should still work
err = alloc.SimplyClaim(container3, addr1)
require.NoError(t, err)
// claim for a different container should fail
err = alloc.SimplyClaim(container1, addr1)
require.Error(t, err)
// claiming the address allocated on the other peer should fail
err = alloc.SimplyClaim(container1, address.MakeCIDR(subnet, addrx))
require.Error(t, err, "claiming address allocated on other peer should fail")
// claiming the pre-claimed address should fail on both peers
err = alloc.SimplyClaim(container3, preAddr)
require.Error(t, err, "claiming address allocated on other peer should fail")
err = allocs[0].SimplyClaim(container3, preAddr)
require.Error(t, err, "claiming address allocated on other peer should fail")
// Check an address outside of our universe
addr2, _ := address.ParseCIDR(testAddr2)
err = alloc.SimplyClaim(container1, addr2)
require.NoError(t, err)
}
func (alloc *Allocator) pause() func() {
@@ -153,18 +229,14 @@ func (alloc *Allocator) pause() func() {
}
func TestCancel(t *testing.T) {
common.InitDefaultLogging(false)
const (
CIDR = "10.0.1.7/26"
)
const cidr = "10.0.4.0/26"
router := gossip.NewTestRouter(0.0)
router := TestGossipRouter{make(map[router.PeerName]chan gossipMessage), 0.0}
alloc1, subnet := makeAllocator("01:00:00:02:00:00", cidr, 2)
alloc1.SetInterfaces(router.Connect(alloc1.ourName, alloc1))
alloc1 := makeAllocator("01:00:00:02:00:00", CIDR, 2)
alloc1.SetInterfaces(router.connect(alloc1.ourName, alloc1))
alloc2 := makeAllocator("02:00:00:02:00:00", CIDR, 2)
alloc2.SetInterfaces(router.connect(alloc2.ourName, alloc2))
alloc2, _ := makeAllocator("02:00:00:02:00:00", cidr, 2)
alloc2.SetInterfaces(router.Connect(alloc2.ourName, alloc2))
alloc1.claimRingForTesting(alloc1, alloc2)
alloc2.claimRingForTesting(alloc1, alloc2)
@@ -172,15 +244,15 @@ func TestCancel(t *testing.T) {
alloc2.Start()
// tell peers about each other
alloc1.OnGossipBroadcast(alloc2.encode())
alloc1.OnGossipBroadcast(alloc2.ourName, alloc2.Encode())
// Get some IPs, so each allocator has some space
res1, _ := alloc1.Allocate("foo", nil)
common.Debug.Printf("res1 = %s", res1.String())
res2, _ := alloc2.Allocate("bar", nil)
common.Debug.Printf("res2 = %s", res2.String())
res1, _ := alloc1.Allocate("foo", subnet, true, returnFalse)
common.Log.Debugf("res1 = %s", res1.String())
res2, _ := alloc2.Allocate("bar", subnet, true, returnFalse)
common.Log.Debugf("res2 = %s", res2.String())
if res1 == res2 {
wt.Fatalf(t, "Error: got same ips!")
require.FailNow(t, "Error: got same ips!")
}
// Now we're going to pause alloc2 and ask alloc1
@@ -188,24 +260,64 @@ func TestCancel(t *testing.T) {
unpause := alloc2.pause()
// Use up all the IPs that alloc1 owns, so the allocation after this will prompt a request to alloc2
for i := 0; alloc1.space.NumFreeAddresses() > 0; i++ {
alloc1.Allocate(fmt.Sprintf("tmp%d", i), nil)
for i := 0; alloc1.NumFreeAddresses(subnet.HostRange()) > 0; i++ {
alloc1.Allocate(fmt.Sprintf("tmp%d", i), subnet, true, returnFalse)
}
cancelChan := make(chan bool, 1)
doneChan := make(chan bool)
go func() {
_, ok := alloc1.Allocate("baz", cancelChan)
_, ok := alloc1.Allocate("baz", subnet, true,
func() bool {
select {
case <-cancelChan:
return true
default:
return false
}
})
doneChan <- ok == nil
}()
AssertNothingSent(t, doneChan)
time.Sleep(100 * time.Millisecond)
AssertNothingSent(t, doneChan)
cancelChan <- true
unpause()
if <-doneChan {
wt.Fatalf(t, "Error: got result from Allocate")
require.FailNow(t, "Error: got result from Allocate")
}
}
func TestCancelOnDied(t *testing.T) {
const (
cidr = "10.0.4.0/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, true, returnFalse)
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")
}
}
@@ -214,82 +326,100 @@ func TestGossipShutdown(t *testing.T) {
container1 = "abcdef"
container2 = "baddf00d"
universe = "10.0.3.0/30"
testAddr1 = "10.0.3.1" // first address allocated should be .1 because .0 is network addr
)
alloc := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", universe, 1)
alloc, subnet := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", universe, 1)
defer alloc.Stop()
alloc.claimRingForTesting()
addr1, _ := alloc.Allocate(container1, nil)
wt.AssertEqualString(t, addr1.String(), testAddr1, "address")
alloc.SimplyAllocate(container1, subnet)
alloc.Shutdown()
_, err := alloc.Allocate(container2, nil) // trying to allocate after shutdown should fail
wt.AssertFalse(t, err == nil, "no address")
_, err := alloc.SimplyAllocate(container2, subnet) // trying to allocate after shutdown should fail
require.False(t, err == nil, "no address")
CheckAllExpectedMessagesSent(alloc)
}
func TestNoFrag(t *testing.T) {
const cidr = "10.0.4.0/22"
resultChan := make(chan int)
for i := 0; i < 100; i++ {
allocs, router, subnet := makeNetworkOfAllocators(3, cidr)
allocs[1].Allocate("foo", subnet, true, returnFalse)
allocs[2].Allocate("bar", subnet, true, returnFalse)
allocs[2].actionChan <- func() {
resultChan <- len(allocs[2].ring.Entries)
}
require.True(t, <-resultChan < 6, "excessive ring fragmentation")
stopNetworkOfAllocators(allocs, router)
}
}
func TestTransfer(t *testing.T) {
const (
cidr = "10.0.1.7/22"
)
allocs, router := makeNetworkOfAllocators(3, cidr)
alloc1 := allocs[0]
alloc2 := allocs[1]
alloc3 := allocs[2] // This will be 'master' and get the first range
const cidr = "10.0.4.0/22"
allocs, router, subnet := makeNetworkOfAllocators(3, cidr)
defer stopNetworkOfAllocators(allocs, router)
alloc0 := allocs[0]
alloc1 := allocs[1]
alloc2 := allocs[2]
_, err := alloc2.Allocate("foo", nil)
wt.AssertTrue(t, err == nil, "Failed to get address")
_, err := alloc1.Allocate("foo", subnet, true, returnFalse)
require.True(t, err == nil, "Failed to get address")
_, err = alloc3.Allocate("bar", nil)
wt.AssertTrue(t, err == nil, "Failed to get address")
_, err = alloc2.Allocate("bar", subnet, true, returnFalse)
require.True(t, err == nil, "Failed to get address")
router.GossipBroadcast(alloc2.Gossip())
router.GossipBroadcast(alloc3.Gossip())
router.removePeer(alloc2.ourName)
router.removePeer(alloc3.ourName)
alloc2.Stop()
alloc3.Stop()
wt.AssertSuccess(t, alloc1.AdminTakeoverRanges(alloc2.ourName.String()))
wt.AssertSuccess(t, alloc1.AdminTakeoverRanges(alloc3.ourName.String()))
// simulation of periodic gossip
alloc2.gossip.GossipBroadcast(alloc2.Gossip())
router.Flush()
alloc1.gossip.GossipBroadcast(alloc1.Gossip())
router.Flush()
wt.AssertEquals(t, alloc1.space.NumFreeAddresses(), address.Offset(1022))
free1 := alloc1.NumFreeAddresses(subnet.Range())
free2 := alloc2.NumFreeAddresses(subnet.Range())
_, err = alloc1.Allocate("foo", nil)
wt.AssertTrue(t, err == nil, "Failed to get address")
router.RemovePeer(alloc1.ourName)
router.RemovePeer(alloc2.ourName)
alloc1.Stop()
alloc2.Stop()
router.Flush()
require.Equal(t, free1+1, alloc0.AdminTakeoverRanges(alloc1.ourName.String()))
require.Equal(t, free2+1, alloc0.AdminTakeoverRanges(alloc2.ourName.String()))
router.Flush()
require.Equal(t, address.Count(1024), alloc0.NumFreeAddresses(subnet.Range()))
_, err = alloc0.Allocate("foo", subnet, true, returnFalse)
require.True(t, err == nil, "Failed to get address")
alloc0.Stop()
}
func TestFakeRouterSimple(t *testing.T) {
common.InitDefaultLogging(false)
const (
cidr = "10.0.1.7/22"
)
allocs, _ := makeNetworkOfAllocators(2, cidr)
defer stopNetworkOfAllocators(allocs)
const cidr = "10.0.4.0/22"
allocs, router, subnet := makeNetworkOfAllocators(2, cidr)
defer stopNetworkOfAllocators(allocs, router)
alloc1 := allocs[0]
//alloc2 := allocs[1]
addr, _ := alloc1.Allocate("foo", nil)
println("Got addr", addr)
_, err := alloc1.Allocate("foo", subnet, true, returnFalse)
require.NoError(t, err, "Failed to get address")
}
func TestAllocatorFuzz(t *testing.T) {
common.InitDefaultLogging(false)
const (
firstpass = 1000
secondpass = 5000
nodes = 10
secondpass = 10000
nodes = 5
maxAddresses = 1000
concurrency = 10
cidr = "10.0.1.7/22"
concurrency = 5
cidr = "10.0.4.0/22"
)
allocs, _ := makeNetworkOfAllocators(nodes, cidr)
defer stopNetworkOfAllocators(allocs)
allocs, router, subnet := makeNetworkOfAllocators(nodes, cidr)
defer stopNetworkOfAllocators(allocs, router)
// Test state
// For each IP issued we store the allocator
@@ -298,6 +428,7 @@ func TestAllocatorFuzz(t *testing.T) {
type result struct {
name string
alloc int32
block bool
}
stateLock := sync.Mutex{}
state := make(map[string]result)
@@ -316,28 +447,19 @@ func TestAllocatorFuzz(t *testing.T) {
return xs[:ls]
}
// Do a Allocate and check the address
// is unique. Needs a unique container
// name.
allocate := func(name string) {
bumpPending := func() bool {
stateLock.Lock()
if len(addrs)+numPending >= maxAddresses {
stateLock.Unlock()
return
return false
}
numPending++
stateLock.Unlock()
return true
}
allocIndex := rand.Int31n(nodes)
alloc := allocs[allocIndex]
//common.Info.Printf("Allocate: asking allocator %d", allocIndex)
addr, err := alloc.Allocate(name, nil)
if err != nil {
panic(fmt.Sprintf("Could not allocate addr"))
}
//common.Info.Printf("Allocate: got address %s for name %s", addr, name)
noteAllocation := func(allocIndex int32, name string, addr address.Address) {
//common.Log.Infof("Allocate: got address %s for name %s", addr, name)
addrStr := addr.String()
stateLock.Lock()
@@ -348,11 +470,31 @@ func TestAllocatorFuzz(t *testing.T) {
name, res.name))
}
state[addrStr] = result{name, allocIndex}
state[addrStr] = result{name, allocIndex, false}
addrs = append(addrs, addrStr)
numPending--
}
// Do a Allocate and check the address
// is unique. Needs a unique container
// name.
allocate := func(name string) {
if !bumpPending() {
return
}
allocIndex := rand.Int31n(nodes)
alloc := allocs[allocIndex]
//common.Log.Infof("Allocate: asking allocator %d", allocIndex)
addr, err := alloc.SimplyAllocate(name, subnet)
if err != nil {
panic(fmt.Sprintf("Could not allocate addr"))
}
noteAllocation(allocIndex, name, addr)
}
// Free a random address.
free := func() {
stateLock.Lock()
@@ -365,14 +507,22 @@ func TestAllocatorFuzz(t *testing.T) {
addrIndex := rand.Int31n(int32(len(addrs)))
addr := addrs[addrIndex]
res := state[addr]
if res.block {
stateLock.Unlock()
return
}
addrs = rm(addrs, addrIndex)
delete(state, addr)
stateLock.Unlock()
alloc := allocs[res.alloc]
//common.Info.Printf("Freeing %s on allocator %d", addr, res.alloc)
//common.Log.Infof("Freeing %s (%s) on allocator %d", res.name, addr, res.alloc)
wt.AssertSuccess(t, alloc.Free(res.name))
oldAddr, err := address.ParseIP(addr)
if err != nil {
panic(err)
}
require.NoError(t, alloc.Free(res.name, oldAddr))
}
// Do a Allocate on an existing container & allocator
@@ -382,15 +532,41 @@ func TestAllocatorFuzz(t *testing.T) {
addrIndex := rand.Int31n(int32(len(addrs)))
addr := addrs[addrIndex]
res := state[addr]
if res.block {
stateLock.Unlock()
return
}
res.block = true
state[addr] = res
stateLock.Unlock()
alloc := allocs[res.alloc]
//common.Info.Printf("Asking for %s on allocator %d again", addr, res.alloc)
//common.Log.Infof("Asking for %s (%s) on allocator %d again", res.name, addr, res.alloc)
newAddr, _ := alloc.Allocate(res.name, nil)
newAddr, _ := alloc.SimplyAllocate(res.name, subnet)
oldAddr, _ := address.ParseIP(addr)
if newAddr != oldAddr {
panic(fmt.Sprintf("Got different address for repeat request"))
panic(fmt.Sprintf("Got different address for repeat request for %s: %s != %s", res.name, newAddr, oldAddr))
}
stateLock.Lock()
res.block = false
state[addr] = res
stateLock.Unlock()
}
// Claim a random address for a unique container name - may not succeed
claim := func(name string) {
if !bumpPending() {
return
}
allocIndex := rand.Int31n(nodes)
addressIndex := rand.Int31n(int32(subnet.Size()))
alloc := allocs[allocIndex]
addr := address.Add(subnet.Addr, address.Offset(addressIndex))
err := alloc.SimplyClaim(name, address.MakeCIDR(subnet, addr))
if err == nil {
noteAllocation(allocIndex, name, addr)
}
}
@@ -433,21 +609,47 @@ func TestAllocatorFuzz(t *testing.T) {
// free a random addr
free()
case 0.8 <= r && r < 1.0:
case 0.8 <= r && r < 0.95:
// ask for an existing name again, check we get same ip
allocateAgain()
case 0.95 <= r && r < 1.0:
name := fmt.Sprintf("second%d", iteration)
claim(name)
}
})
}
func TestGossipSkew(t *testing.T) {
alloc1 := makeAllocatorWithMockGossip(t, "01:00:00:01:00:00", "10.0.1.0/22", 2)
defer alloc1.Stop()
alloc2 := makeAllocatorWithMockGossip(t, "02:00:00:02:00:00", "10.0.1.0/22", 2)
alloc2.now = func() time.Time { return time.Now().Add(time.Hour * 2) }
defer alloc2.Stop()
func TestSpaceRequest(t *testing.T) {
const (
container1 = "cont-1"
container2 = "cont-2"
universe = "10.32.0.0/12"
)
allocs, router, subnet := makeNetworkOfAllocators(1, universe)
defer stopNetworkOfAllocators(allocs, router)
alloc1 := allocs[0]
if _, err := alloc1.OnGossipBroadcast(alloc2.encode()); err == nil {
t.Fail()
}
addr, err := alloc1.Allocate(container1, subnet, true, returnFalse)
require.Nil(t, err, "")
// free it again so the donation splits the range neatly
err = alloc1.Free(container1, addr)
require.Nil(t, err, "")
require.Equal(t, cidrRanges(universe), alloc1.OwnedRanges(), "")
// Start a new peer
alloc2, _ := makeAllocator("02:00:00:02:00:00", universe, 2)
alloc2.SetInterfaces(router.Connect(alloc2.ourName, alloc2))
alloc2.Start()
defer alloc2.Stop()
alloc2.Allocate(container2, subnet, true, returnFalse)
// Test whether the universe has been split into two equal halves (GH #2009)
require.Equal(t, cidrRanges("10.32.0.0/13"), alloc1.OwnedRanges(), "")
require.Equal(t, cidrRanges("10.40.0.0/13"), alloc2.OwnedRanges(), "")
}
func cidrRanges(s string) []address.Range {
c, _ := address.ParseCIDR(s)
return []address.Range{c.Range()}
}
+93 -42
View File
@@ -3,75 +3,126 @@ package ipam
import (
"fmt"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/router"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/api"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/net/address"
)
type claim struct {
resultChan chan<- error
ident string // a container ID, something like "weave:expose", or api.NoContainerID
cidr address.CIDR // single address being claimed
isContainer bool // true if ident is a container ID
noErrorOnUnknown bool // if false, error or block if we don't know; if true return ok but keep trying
hasBeenCancelled func() bool
ident string
addr address.Address
}
// Send an error (or nil for success) back to caller listening on resultChan
func (c *claim) sendResult(result error) {
// Make sure we only send a result once, since listener stops listening after that
if c.resultChan != nil {
c.resultChan <- result
close(c.resultChan)
c.resultChan = nil
return
}
if result != nil {
common.Log.Errorln("[allocator] " + result.Error())
}
}
// Try returns true for success (or failure), false if we need to try again later
func (c *claim) Try(alloc *Allocator) bool {
if (c.hasBeenCancelled)() {
if c.hasBeenCancelled != nil && c.hasBeenCancelled() {
c.Cancel()
return true
}
if !alloc.ring.Contains(c.addr) {
if !alloc.ring.Contains(c.cidr.Addr) {
// Address not within our universe; assume user knows what they are doing
alloc.infof("Ignored address %s claimed by %s - not in our universe\n", c.addr, c.ident)
c.resultChan <- nil
alloc.infof("Address %s claimed by %s - not in our range", c.cidr, c.ident)
alloc.addOwned(c.ident, c.cidr, c.isContainer)
c.sendResult(nil)
return true
}
// If our ring doesn't know, it must be empty. We will have initiated the
// bootstrap of the ring, so wait until we find some owner for this
// range (might be us).
owner := alloc.ring.Owner(c.addr)
if owner == router.UnknownPeerName {
alloc.infof("Ring is empty; will try later.\n", c.addr, owner)
alloc.establishRing()
// If we had heard that this container died, resurrect it
delete(alloc.dead, c.ident) // (delete is no-op if key not in map)
switch owner := alloc.ring.Owner(c.cidr.Addr); owner {
case alloc.ourName:
// success
case mesh.UnknownPeerName:
// If our ring doesn't know, it must be empty.
alloc.infof("Claim %s for %s: is in the range %s, but the allocator is not initialized yet; will try later.",
c.cidr, c.ident, alloc.universe)
if c.noErrorOnUnknown {
c.sendResult(nil)
}
return false
default:
alloc.debugf("requesting address %s from other peer %s", c.cidr, owner)
err := alloc.sendSpaceRequest(owner, address.NewRange(c.cidr.Addr, 1))
if err != nil { // can't speak to owner right now
if c.noErrorOnUnknown {
alloc.infof("Claim %s for %s: %s; will try later.", c.cidr, c.ident, err)
c.sendResult(nil)
} else { // just tell the user they can't do this.
c.deniedBy(alloc, owner)
}
}
return false
}
if owner != alloc.ourName {
name, found := alloc.nicknames[owner]
if found {
name = " (" + name + ")"
}
c.resultChan <- fmt.Errorf("address %s is owned by other peer %s%s", c.addr.String(), owner, name)
return true
}
// We are the owner, check we haven't given it to another container
existingIdent := alloc.findOwner(c.addr)
if existingIdent == c.ident {
// same identifier is claiming same address; that's OK
c.resultChan <- nil
return true
}
if existingIdent == "" {
err := alloc.space.Claim(c.addr)
if err != nil {
c.resultChan <- err
return true
existingIdent := alloc.findOwner(c.cidr.Addr)
switch {
case existingIdent == "":
// Unused address, we try to claim it:
if err := alloc.space.Claim(c.cidr.Addr); err == nil {
alloc.debugln("Claimed", c.cidr, "for", c.ident)
if c.ident == api.NoContainerID {
alloc.addOwned(c.cidr.Addr.String(), c.cidr, c.isContainer)
} else {
alloc.addOwned(c.ident, c.cidr, c.isContainer)
}
c.sendResult(nil)
} else {
c.sendResult(err)
}
alloc.addOwned(c.ident, c.addr)
c.resultChan <- nil
return true
case (existingIdent == c.ident) || (c.ident == api.NoContainerID && existingIdent == c.cidr.Addr.String()):
// same identifier is claiming same address; that's OK
alloc.debugln("Re-Claimed", c.cidr, "for", c.ident)
c.sendResult(nil)
case existingIdent == c.cidr.Addr.String():
// Address already allocated via api.NoContainerID name and current ID is a real container ID:
c.sendResult(fmt.Errorf("address %s already in use", c.cidr))
case c.ident == api.NoContainerID:
// We do not know whether this is the same container or another one,
// but we also cannot prove otherwise, so we let it reclaim the address:
alloc.debugln("Re-Claimed", c.cidr, "for ID", c.ident, "having existing ID as", existingIdent)
c.sendResult(nil)
default:
// Addr already owned by container on this machine
c.sendResult(fmt.Errorf("address %s is already owned by %s", c.cidr.String(), existingIdent))
}
// Addr already owned by container on this machine
c.resultChan <- fmt.Errorf("address %s is already owned by %s", c.addr.String(), existingIdent)
return true
}
func (c *claim) Cancel() {
c.resultChan <- fmt.Errorf("Operation cancelled.")
func (c *claim) deniedBy(alloc *Allocator, owner mesh.PeerName) {
name, found := alloc.nicknames[owner]
if found {
name = " (" + name + ")"
}
c.sendResult(fmt.Errorf("address %s is owned by other peer %s%s", c.cidr.String(), owner, name))
}
func (c *claim) String() string {
return fmt.Sprintf("Claim %s -> %s", c.ident, c.addr.String())
func (c *claim) Cancel() {
c.sendResult(&errorCancelled{"Claim", c.ident})
}
func (c *claim) ForContainer(ident string) bool {
-36
View File
@@ -1,36 +0,0 @@
package ipam
import (
"errors"
"github.com/weaveworks/weave/router"
)
// Exists solely for the purpose of detecting a network in which some
// peers are configured with IPAM on and some with IPAM off.
type DummyAllocator struct {
}
var (
ErrMixedConfig = errors.New("Mixed IPAM/non-IPAM configuration not supported")
)
func (alloc *DummyAllocator) OnGossipUnicast(sender router.PeerName, msg []byte) error {
return ErrMixedConfig
}
func (alloc *DummyAllocator) OnGossipBroadcast(msg []byte) (router.GossipData, error) {
return nil, ErrMixedConfig
}
func (alloc *DummyAllocator) OnGossip(msg []byte) (router.GossipData, error) {
return nil, ErrMixedConfig
}
func (alloc *DummyAllocator) Gossip() router.GossipData {
return nil
}
func (alloc *DummyAllocator) Encode() []byte {
return nil
}
+134 -25
View File
@@ -7,47 +7,156 @@ import (
"github.com/gorilla/mux"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/common/docker"
"github.com/weaveworks/weave/net/address"
)
func badRequest(w http.ResponseWriter, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
common.Warning.Println("[allocator]:", err.Error())
common.Log.Warningln("[allocator]:", err.Error())
}
func parseCIDR(w http.ResponseWriter, cidrStr string, net bool) (address.CIDR, bool) {
var cidr address.CIDR
var err error
if net {
cidr, err = ParseCIDRSubnet(cidrStr)
} else {
cidr, err = address.ParseCIDR(cidrStr)
}
if err != nil {
badRequest(w, err)
return address.CIDR{}, false
}
return cidr, true
}
func writeAddresses(w http.ResponseWriter, cidrs []address.CIDR) {
for i, cidr := range cidrs {
fmt.Fprint(w, cidr)
if i < len(cidrs)-1 {
w.Write([]byte{' '})
}
}
}
func hasBeenCancelled(dockerCli *docker.Client, closedChan <-chan bool, ident string, checkAlive bool) func() bool {
return func() bool {
select {
case <-closedChan:
return true
default:
res := checkAlive && dockerCli != nil && dockerCli.IsContainerNotRunning(ident)
checkAlive = false // we check only once; if the container dies later we learn about that through events
return res
}
}
}
func cancellationErr(w http.ResponseWriter, err error) bool {
if _, ok := err.(*errorCancelled); ok {
common.Log.Infoln("[allocator]:", err.Error())
fmt.Fprint(w, "cancelled")
return true
}
return false
}
func (alloc *Allocator) handleHTTPAllocate(dockerCli *docker.Client, w http.ResponseWriter, ident string, checkAlive bool, subnet address.CIDR) {
addr, err := alloc.Allocate(ident, subnet, checkAlive,
hasBeenCancelled(dockerCli, w.(http.CloseNotifier).CloseNotify(), ident, checkAlive))
if err != nil {
if !cancellationErr(w, err) {
badRequest(w, err)
}
return
}
fmt.Fprintf(w, "%s/%d", addr, subnet.PrefixLen)
}
func (alloc *Allocator) handleHTTPClaim(dockerCli *docker.Client, w http.ResponseWriter, ident string, cidr address.CIDR, checkAlive, noErrorOnUnknown bool) {
err := alloc.Claim(ident, cidr, checkAlive, noErrorOnUnknown,
hasBeenCancelled(dockerCli, w.(http.CloseNotifier).CloseNotify(), ident, checkAlive))
if err != nil {
if !cancellationErr(w, err) {
badRequest(w, fmt.Errorf("Unable to claim: %s", err))
}
return
}
w.WriteHeader(204)
}
// HandleHTTP wires up ipams HTTP endpoints to the provided mux.
func (alloc *Allocator) HandleHTTP(router *mux.Router) {
router.Methods("PUT").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
closedChan := w.(http.CloseNotifier).CloseNotify()
func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CIDR, tracker string, dockerCli *docker.Client) {
router.Methods("GET").Path("/ipinfo/defaultsubnet").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", defaultSubnet)
})
router.Methods("PUT").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
if cidr, ok := parseCIDR(w, vars["ip"]+"/"+vars["prefixlen"], false); ok {
ident := vars["id"]
checkAlive := r.FormValue("check-alive") == "true"
noErrorOnUnknown := r.FormValue("noErrorOnUnknown") == "true"
alloc.handleHTTPClaim(dockerCli, w, ident, cidr, checkAlive, noErrorOnUnknown)
}
})
router.Methods("GET").Path("/ring").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
alloc.Prime()
})
router.Methods("GET").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
if subnet, ok := parseCIDR(w, vars["ip"]+"/"+vars["prefixlen"], true); ok {
cidrs, err := alloc.Lookup(vars["id"], subnet.HostRange())
if err != nil {
http.NotFound(w, r)
return
}
writeAddresses(w, cidrs)
}
})
router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
addrs, err := alloc.Lookup(mux.Vars(r)["id"], defaultSubnet.HostRange())
if err != nil {
http.NotFound(w, r)
return
}
writeAddresses(w, addrs)
})
router.Methods("POST").Path("/ip/{id}/{ip}/{prefixlen}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
if subnet, ok := parseCIDR(w, vars["ip"]+"/"+vars["prefixlen"], true); ok {
alloc.handleHTTPAllocate(dockerCli, w, vars["id"], r.FormValue("check-alive") == "true", subnet)
}
})
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
alloc.handleHTTPAllocate(dockerCli, w, vars["id"], r.FormValue("check-alive") == "true", defaultSubnet)
})
router.Methods("DELETE").Path("/ip/{id}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
ident := vars["id"]
ipStr := vars["ip"]
if ip, err := address.ParseIP(ipStr); err != nil {
badRequest(w, err)
return
} else if err := alloc.Claim(ident, ip, closedChan); err != nil {
badRequest(w, fmt.Errorf("Unable to claim: %s", err))
} else if err := alloc.Free(ident, ip); err != nil {
badRequest(w, fmt.Errorf("Unable to free: %s", err))
return
}
w.WriteHeader(204)
})
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
closedChan := w.(http.CloseNotifier).CloseNotify()
ident := mux.Vars(r)["id"]
newAddr, err := alloc.Allocate(ident, closedChan)
if err != nil {
badRequest(w, err)
return
}
fmt.Fprintf(w, "%s/%d", newAddr.String(), alloc.prefixLen)
})
router.Methods("DELETE").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ident := mux.Vars(r)["id"]
if err := alloc.Free(ident); err != nil {
if err := alloc.Delete(ident); err != nil {
badRequest(w, err)
return
}
@@ -62,11 +171,11 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
router.Methods("DELETE").Path("/peer/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ident := mux.Vars(r)["id"]
if err := alloc.AdminTakeoverRanges(ident); err != nil {
badRequest(w, err)
return
}
transferred := alloc.AdminTakeoverRanges(ident)
fmt.Fprintf(w, "%d IPs taken over from %s\n", transferred, ident)
})
w.WriteHeader(204)
router.Methods("GET").Path("/ipinfo/tracker").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, tracker)
})
}
+85 -76
View File
@@ -4,22 +4,30 @@ import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"net/http"
"strings"
"testing"
"time"
"github.com/gorilla/mux"
"github.com/stretchr/testify/require"
"github.com/weaveworks/weave/common"
wt "github.com/weaveworks/weave/testing"
"github.com/weaveworks/weave/net/address"
)
func HTTPPost(t *testing.T, url string) string {
resp, err := http.Post(url, "", nil)
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode, "http response")
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return string(body)
}
func HTTPGet(t *testing.T, url string) string {
resp, err := http.Get(url)
require.NoError(t, err)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return string(body)
@@ -30,60 +38,76 @@ func doHTTP(method string, url string) (resp *http.Response, err error) {
return http.DefaultClient.Do(req)
}
func listenHTTP(port int, alloc *Allocator) {
func listenHTTP(alloc *Allocator, subnet address.CIDR) int {
router := mux.NewRouter()
router.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, fmt.Sprintln(alloc))
})
alloc.HandleHTTP(router)
alloc.HandleHTTP(router, subnet, "", nil)
srv := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: router,
}
if err := srv.ListenAndServe(); err != nil {
common.Error.Fatal("Unable to create http listener: ", err)
httpListener, err := net.Listen("tcp", ":0")
if err != nil {
common.Log.Fatal("Unable to create http listener: ", err)
}
go func() {
srv := &http.Server{Handler: router}
if err := srv.Serve(httpListener); err != nil {
common.Log.Fatal("Unable to serve http: ", err)
}
}()
return httpListener.Addr().(*net.TCPAddr).Port
}
func allocURL(port int, containerID string) string {
func identURL(port int, containerID string) string {
return fmt.Sprintf("http://localhost:%d/ip/%s", port, containerID)
}
func allocURL(port int, cidr string, containerID string) string {
return fmt.Sprintf("http://localhost:%d/ip/%s/%s", port, containerID, cidr)
}
func TestHttp(t *testing.T) {
var (
containerID = "deadbeef"
container2 = "baddf00d"
container3 = "b01df00d"
testAddr1 = "10.0.3.9"
netSuffix = "/29"
testCIDR1 = "10.0.3.8" + netSuffix
universe = "10.0.0.0/8"
testCIDR1 = "10.0.3.8/29"
testCIDR2 = "10.2.0.0/16"
testAddr1 = "10.0.3.9/29"
testAddr2 = "10.2.0.1/16"
)
alloc := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", testCIDR1, 1)
port := rand.Intn(10000) + 32768
fmt.Println("Http test on port", port)
go listenHTTP(port, alloc)
time.Sleep(100 * time.Millisecond) // Allow for http server to get going
alloc, _ := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", universe, 1)
cidr, _ := address.ParseCIDR(universe)
port := listenHTTP(alloc, cidr)
alloc.claimRingForTesting()
// Ask the http server for a new address
cidr1 := HTTPPost(t, allocURL(port, containerID))
wt.AssertEqualString(t, cidr1, testAddr1+netSuffix, "address")
// Ask the http server for another address and check it's different
cidr2 := HTTPPost(t, allocURL(port, container2))
wt.AssertFalse(t, cidr2 == testAddr1+netSuffix, "address")
// Allocate an address in each subnet, and check we got what we expected
cidr1a := HTTPPost(t, allocURL(port, testCIDR1, containerID))
require.Equal(t, testAddr1, cidr1a, "address")
cidr2a := HTTPPost(t, allocURL(port, testCIDR2, containerID))
require.Equal(t, testAddr2, cidr2a, "address")
// Now, make the same requests again to check the operation is idempotent
check := HTTPGet(t, allocURL(port, testCIDR1, containerID))
require.Equal(t, cidr1a, check, "address")
check = HTTPGet(t, allocURL(port, testCIDR2, containerID))
require.Equal(t, cidr2a, check, "address")
// Ask for the first container again and we should get the same address again
cidr1a := HTTPPost(t, allocURL(port, containerID))
wt.AssertEqualString(t, cidr1a, testAddr1+netSuffix, "address")
// Ask the http server for a pair of addresses for another container and check they're different
cidr1b := HTTPPost(t, allocURL(port, testCIDR1, container2))
require.False(t, cidr1b == testAddr1, "address")
cidr2b := HTTPPost(t, allocURL(port, testCIDR2, container2))
require.False(t, cidr2b == testAddr2, "address")
// Now free the first one, and we should get it back when we ask
doHTTP("DELETE", allocURL(port, containerID))
cidr3 := HTTPPost(t, allocURL(port, container3))
wt.AssertEqualString(t, cidr3, testAddr1+netSuffix, "address")
// Now free the first container, and we should get its addresses back when we ask
doHTTP("DELETE", identURL(port, containerID))
cidr1c := HTTPPost(t, allocURL(port, testCIDR1, container3))
require.Equal(t, testAddr1, cidr1c, "address")
cidr2c := HTTPPost(t, allocURL(port, testCIDR2, container3))
require.Equal(t, testAddr2, cidr2c, "address")
// Would like to shut down the http server at the end of this test
// but it's complicated.
@@ -96,69 +120,54 @@ func TestBadHttp(t *testing.T) {
testCIDR1 = "10.0.0.0/8"
)
alloc := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", testCIDR1, 1)
alloc, _ := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", testCIDR1, 1)
defer alloc.Stop()
port := rand.Intn(10000) + 32768
fmt.Println("BadHttp test on port", port)
go listenHTTP(port, alloc)
cidr, _ := address.ParseCIDR(testCIDR1)
port := listenHTTP(alloc, cidr)
alloc.claimRingForTesting()
cidr1 := HTTPPost(t, allocURL(port, containerID))
cidr1 := HTTPPost(t, allocURL(port, testCIDR1, containerID))
parts := strings.Split(cidr1, "/")
testAddr1 := parts[0]
// Verb that's not handled
resp, err := doHTTP("HEAD", fmt.Sprintf("http://localhost:%d/ip/%s/%s", port, containerID, testAddr1))
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusNotFound, "http response")
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, resp.StatusCode, "http response")
// Mis-spelled URL
resp, err = doHTTP("POST", fmt.Sprintf("http://localhost:%d/xip/%s/", port, containerID))
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusNotFound, "http response")
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, resp.StatusCode, "http response")
// Malformed URL
resp, err = doHTTP("POST", fmt.Sprintf("http://localhost:%d/ip/%s/foo/bar/baz", port, containerID))
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusNotFound, "http response")
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, resp.StatusCode, "http response")
}
func TestHTTPCancel(t *testing.T) {
wt.RunWithTimeout(t, 2*time.Second, func() {
impTestHTTPCancel(t)
})
}
func impTestHTTPCancel(t *testing.T) {
common.InitDefaultLogging(true)
var (
containerID = "deadbeef"
testCIDR1 = "10.0.3.5/29"
testCIDR1 = "10.0.3.0/29"
)
alloc := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", testCIDR1, 1)
// Say quorum=2, so the allocate won't go ahead
alloc, _ := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", testCIDR1, 2)
defer alloc.Stop()
alloc.claimRingForTesting()
port := rand.Intn(10000) + 32768
fmt.Println("Http test on port", port)
go listenHTTP(port, alloc)
time.Sleep(100 * time.Millisecond) // Allow for http server to get going
// Stop the alloc so nothing actually works
unpause := alloc.pause()
ExpectBroadcastMessage(alloc, nil) // trying to form consensus
cidr, _ := address.ParseCIDR(testCIDR1)
port := listenHTTP(alloc, cidr)
// Ask the http server for a new address
done := make(chan *http.Response)
req, _ := http.NewRequest("POST", allocURL(port, containerID), nil)
req, _ := http.NewRequest("POST", allocURL(port, testCIDR1, containerID), nil)
// On another goroutine, wait for a bit then cancel the request
go func() {
res, _ := http.DefaultClient.Do(req)
done <- res
time.Sleep(100 * time.Millisecond)
common.Log.Debug("Cancelling allocate")
http.DefaultTransport.(*http.Transport).CancelRequest(req)
}()
time.Sleep(100 * time.Millisecond)
fmt.Println("Cancelling allocate")
http.DefaultTransport.(*http.Transport).CancelRequest(req)
unpause()
res := <-done
res, _ := http.DefaultClient.Do(req)
if res != nil {
wt.Fatalf(t, "Error: Allocate returned non-nil")
body, _ := ioutil.ReadAll(res.Body)
require.FailNow(t, "Error: Allocate returned non-nil", string(body))
}
}
+44
View File
@@ -0,0 +1,44 @@
package paxos
type Participant interface {
GossipState() GossipState
Update(from GossipState) bool
SetQuorum(uint)
Propose()
Think() bool
Consensus() (bool, AcceptedValue)
IsElector() bool
}
type Observer struct {
}
func NewObserver() Participant {
return &Observer{}
}
func (observer *Observer) GossipState() GossipState {
return nil
}
func (observer *Observer) Update(from GossipState) bool {
return false
}
func (observer *Observer) Propose() {
}
func (observer *Observer) SetQuorum(uint) {
}
func (observer *Observer) Think() bool {
return false
}
func (observer *Observer) Consensus() (bool, AcceptedValue) {
return false, AcceptedValue{}
}
func (observer *Observer) IsElector() bool {
return false
}
+29 -15
View File
@@ -1,8 +1,7 @@
package paxos
import (
"fmt"
"github.com/weaveworks/weave/router"
"github.com/weaveworks/mesh"
)
// The node identifier. The use of the UID here is important: Paxos
@@ -10,8 +9,8 @@ import (
// node does not restart and lose its Paxos state but claim to have
// the same ID.
type NodeID struct {
Name router.PeerName
UID router.PeerUID
Name mesh.PeerName
UID mesh.PeerUID
}
// note all fields exported in structs so we can Gob them
@@ -40,7 +39,7 @@ func (a ProposalID) valid() bool {
}
// For seeding IPAM, the value we want consensus on is a set of peer names
type Value []router.PeerName
type Value []mesh.PeerName
// An AcceptedValue is a Value plus the proposal which originated that
// Value. The origin is not essential, but makes comparing
@@ -73,7 +72,7 @@ type Node struct {
knows GossipState
}
func NewNode(name router.PeerName, uid router.PeerUID, quorum uint) *Node {
func NewNode(name mesh.PeerName, uid mesh.PeerUID, quorum uint) *Node {
return &Node{
id: NodeID{name, uid},
quorum: quorum,
@@ -81,6 +80,10 @@ func NewNode(name router.PeerName, uid router.PeerUID, quorum uint) *Node {
}
}
func (node *Node) SetQuorum(quorum uint) {
node.quorum = quorum
}
func (node *Node) GossipState() GossipState {
return node.knows
}
@@ -117,15 +120,17 @@ func (node *Node) Update(from GossipState) bool {
func max(a uint, b uint) uint {
if a > b {
return a
} else {
return b
}
return b
}
// Initiate a new proposal, i.e. the Paxos "Prepare" step. This is
// simply a matter of gossipping a new proposal that supersedes all
// others.
func (node *Node) Propose() {
if node.quorum == 0 {
panic("Paxos node.Propose() called with no quorum set")
}
// Find the highest round number around
round := uint(0)
@@ -225,7 +230,7 @@ func (node *Node) Think() bool {
// about. This is not necessarily all peer names, but it is at least
// a quorum, and so good enough for seeding the ring.
func (node *Node) pickValue() Value {
val := make([]router.PeerName, len(node.knows))
val := make([]mesh.PeerName, len(node.knows))
i := 0
for id := range node.knows {
val[i] = id.Name
@@ -236,6 +241,9 @@ func (node *Node) pickValue() Value {
// Has a consensus been reached, based on the known claims of other nodes?
func (node *Node) Consensus() (bool, AcceptedValue) {
if node.quorum == 0 {
return false, AcceptedValue{}
}
counts := map[ProposalID]uint{}
for _, claims := range node.knows {
@@ -252,10 +260,16 @@ func (node *Node) Consensus() (bool, AcceptedValue) {
return false, AcceptedValue{}
}
func (node *Node) String() string {
if ok, val := node.Consensus(); ok {
return fmt.Sprintf("Consensus reached with size %d", len(val.Value))
} else {
return fmt.Sprintf("Nodes known: %d, Quorum size: %d", len(node.knows), node.quorum)
}
func (node *Node) IsElector() bool {
return true
}
type Status struct {
Elector bool
KnownNodes int
Quorum uint
}
func NewStatus(node *Node) *Status {
return &Status{true, len(node.knows), node.quorum}
}
+8 -7
View File
@@ -2,10 +2,11 @@ package paxos
import (
"fmt"
"github.com/weaveworks/weave/router"
"math/rand"
"testing"
"time"
"github.com/weaveworks/mesh"
)
type TestNode struct {
@@ -96,8 +97,8 @@ func makeRandomModel(params *TestParams, r *rand.Rand, t *testing.T) *Model {
}
for i := range m.nodes {
m.nodes[i].Node = NewNode(router.PeerName(i/2+1),
router.PeerUID(r.Int63()), m.quorum)
m.nodes[i].Node = NewNode(mesh.PeerName(i/2+1),
mesh.PeerUID(r.Int63()), m.quorum)
m.nodes[i].Propose()
}
@@ -171,8 +172,8 @@ func (m *Model) isolateNode(node *TestNode) {
// Restart a node
func (m *Model) restart(node *TestNode) {
node.Node = NewNode(router.PeerName(m.nextID),
router.PeerUID(m.r.Int63()), m.quorum)
node.Node = NewNode(mesh.PeerName(m.nextID),
mesh.PeerUID(m.r.Int63()), m.quorum)
m.nextID++
node.Propose()
@@ -299,14 +300,14 @@ func (m *Model) validate() {
for i := range m.nodes {
ok, val := m.nodes[i].Consensus()
if !ok {
//m.dump()
m.dump()
m.t.Fatal("Node doesn't know about consensus")
}
firstConsensus := m.nodes[i].firstConsensus
if firstConsensus.Origin.valid() &&
firstConsensus.Origin != val.Origin {
//m.dump()
m.dump()
m.t.Fatal("Consensus mismatch")
}
+24
View File
@@ -0,0 +1,24 @@
package ipam
type prime struct {
resultChan chan<- struct{}
}
func (c *prime) Try(alloc *Allocator) bool {
if !alloc.ring.Empty() {
close(c.resultChan)
return true
}
alloc.establishRing()
return false
}
func (c *prime) Cancel() {
close(c.resultChan)
}
func (c *prime) ForContainer(ident string) bool {
return false
}
+6 -9
View File
@@ -3,17 +3,18 @@ package ring
import (
"sort"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/router"
"github.com/weaveworks/weave/net/address"
)
// Entry represents entries around the ring
type entry struct {
Token address.Address // The start of this range
Peer router.PeerName // Who owns this range
Peer mesh.PeerName // Who owns this range
Version uint32 // Version of this range
Free address.Offset // Number of free IPs in this range
Free address.Count // Number of free IPs in this range
}
func (e *entry) Equal(e2 *entry) bool {
@@ -21,7 +22,7 @@ func (e *entry) Equal(e2 *entry) bool {
e.Version == e2.Version
}
func (e *entry) update(peername router.PeerName, free address.Offset) {
func (e *entry) update(peername mesh.PeerName, free address.Count) {
e.Peer = peername
e.Version++
e.Free = free
@@ -68,10 +69,6 @@ func (es entries) get(token address.Address) (*entry, bool) {
return nil, false
}
func (es *entries) remove(i int) {
*es = (*es)[:i+copy((*es)[i:], (*es)[i+1:])]
}
// Is token between entries at i and j?
// NB i and j can overflow and will wrap
// NBB this function does not work very well if there is only one
-31
View File
@@ -1,31 +0,0 @@
package ring
/* Exported variables for monitoring and management */
import (
"expvar"
"strconv"
)
var (
expRingSize = expvar.NewMap("ipam.ringSize")
expRingEntries = expvar.NewMap("ipam.ringEntries")
)
type _int int
func (i _int) String() string {
return strconv.Itoa(int(i))
}
type _uint32 uint32
func (i _uint32) String() string {
return strconv.FormatUint(uint64(i), 10)
}
func (r *Ring) updateExportedVariables() {
ringName := r.Start.String()
expRingSize.Set(ringName, _uint32(r.End-r.Start))
expRingEntries.Set(ringName, _int(len(r.Entries)))
}
+244 -151
View File
@@ -10,17 +10,23 @@ import (
"io"
"math/rand"
"sort"
"time"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/router"
"github.com/weaveworks/weave/net/address"
)
type OnUpdate func(prev, curr []address.Range, local bool)
// Ring represents the ring itself
type Ring struct {
Start, End address.Address // [min, max) tokens in this ring. Due to wrapping, min == max (effectively)
Peer router.PeerName // name of peer owning this ring instance
Peer mesh.PeerName // name of peer owning this ring instance
Entries entries // list of entries sorted by token
Seeds []mesh.PeerName // peers with which the ring was seeded
onUpdate OnUpdate
}
func (r *Ring) assertInvariants() {
@@ -32,46 +38,55 @@ func (r *Ring) assertInvariants() {
// Errors returned by Merge
var (
ErrNotSorted = errors.New("Ring not sorted")
ErrTokenRepeated = errors.New("Token appears twice in ring")
ErrTokenOutOfRange = errors.New("Token is out of range")
ErrDifferentSubnets = errors.New("IP Allocator with different subnet detected")
ErrNewerVersion = errors.New("Received new version for entry I own!")
ErrInvalidEntry = errors.New("Received invalid state update!")
ErrEntryInMyRange = errors.New("Received new entry in my range!")
ErrNoFreeSpace = errors.New("No free space found!")
ErrInvalidTimeout = errors.New("dt must be greater than 0")
ErrNotFound = errors.New("No entries for peer found")
ErrNotSorted = errors.New("Ring not sorted")
ErrTokenRepeated = errors.New("Token appears twice in ring")
ErrTokenOutOfRange = errors.New("Token is out of range")
ErrDifferentSeeds = errors.New("Received ring was seeded differently from ours")
ErrDifferentRange = errors.New("Received range differs from ours")
)
func errInconsistentEntry(mine, theirs *entry) error {
return fmt.Errorf("Inconsistent entries for %s: owned by %s but incoming message says %s", mine.Token, mine.Peer, theirs.Peer)
}
func errEntryInMyRange(theirs *entry) error {
return fmt.Errorf("Peer %s says it owns the IP range from %s, which I think I own", theirs.Peer, theirs.Token)
}
func errNewerVersion(mine, theirs *entry) error {
return fmt.Errorf("Received update for IP range I own at %s v%d: incoming message says owner %s v%d", mine.Token, mine.Version, theirs.Peer, theirs.Version)
}
func (r *Ring) checkInvariants() error {
if !sort.IsSorted(r.Entries) {
return r.checkEntries(r.Entries)
}
func (r *Ring) checkEntries(entries entries) error {
if !sort.IsSorted(entries) {
return ErrNotSorted
}
// Check no token appears twice
// We know it's sorted...
for i := 1; i < len(r.Entries); i++ {
if r.Entries[i-1].Token == r.Entries[i].Token {
for i := 1; i < len(entries); i++ {
if entries[i-1].Token == entries[i].Token {
return ErrTokenRepeated
}
}
if len(r.Entries) == 0 {
if len(entries) == 0 {
return nil
}
// Check tokens are in range
if r.Entries.entry(0).Token < r.Start {
if entries.entry(0).Token < r.Start {
return ErrTokenOutOfRange
}
if r.Entries.entry(-1).Token >= r.End {
if entries.entry(-1).Token >= r.End {
return ErrTokenOutOfRange
}
// Check all the freespaces are in range
for i, entry := range r.Entries {
next := r.Entries.entry(i + 1)
for i, entry := range entries {
next := entries.entry(i + 1)
distance := r.distance(entry.Token, next.Token)
if entry.Free > distance {
@@ -82,35 +97,46 @@ func (r *Ring) checkInvariants() error {
return nil
}
func (r *Ring) trackUpdates() func() {
return r.trackUpdatesOfPeer(r.Peer)
}
func (r *Ring) trackUpdatesOfPeer(peer mesh.PeerName) func() {
if r.onUpdate == nil {
return func() {}
}
ranges := r.OwnedRangesOfPeer(peer)
return func() { r.onUpdate(ranges, r.OwnedRangesOfPeer(peer), peer == r.Peer) }
}
// New creates an empty ring belonging to peer.
func New(start, end address.Address, peer router.PeerName) *Ring {
func New(start, end address.Address, peer mesh.PeerName, f OnUpdate) *Ring {
common.Assert(start < end)
ring := &Ring{Start: start, End: end, Peer: peer, Entries: make([]*entry, 0)}
ring.updateExportedVariables()
ring := &Ring{Start: start, End: end, Peer: peer, Entries: make([]*entry, 0), onUpdate: f}
return ring
}
// TotalRemoteFree returns the approximate number of free IPs
// on other hosts.
func (r *Ring) TotalRemoteFree() address.Offset {
result := address.Offset(0)
for _, entry := range r.Entries {
if entry.Peer != r.Peer {
result += entry.Free
}
}
return result
func (r *Ring) Restore(other *Ring) {
defer r.trackUpdates()()
onUpdate := r.onUpdate
*r = *other
r.onUpdate = onUpdate
}
func (r *Ring) Range() address.Range {
return address.Range{Start: r.Start, End: r.End}
}
// Returns the distance between two tokens on this ring, dealing
// with ranges which cross the origin
func (r *Ring) distance(start, end address.Address) address.Offset {
func (r *Ring) distance(start, end address.Address) address.Count {
if end > start {
return address.Offset(end - start)
return address.Count(end - start)
}
return address.Offset((r.End - start) + (end - r.Start))
return address.Count((r.End - start) + (end - r.Start))
}
// GrantRangeToHost modifies the ring such that range [start, end)
@@ -118,12 +144,12 @@ func (r *Ring) distance(start, end address.Address) address.Offset {
// Preconditions:
// - start < end
// - [start, end) must be owned by the calling peer
func (r *Ring) GrantRangeToHost(start, end address.Address, peer router.PeerName) {
func (r *Ring) GrantRangeToHost(start, end address.Address, peer mesh.PeerName) {
//fmt.Printf("%s GrantRangeToHost [%v,%v) -> %s\n", r.Peer, start, end, peer)
r.assertInvariants()
defer r.trackUpdates()()
defer r.assertInvariants()
defer r.updateExportedVariables()
// ----------------- Start of Checks -----------------
@@ -185,32 +211,69 @@ func (r *Ring) GrantRangeToHost(start, end address.Address, peer router.PeerName
r.Entries.insert(entry{Token: end, Peer: r.Peer, Free: endFree})
}
// Merge the given ring into this ring and return any new ranges added
func (r *Ring) Merge(gossip Ring) error {
// Merge the given ring into this ring and indicate whether this ring
// got updated as a result.
func (r *Ring) Merge(gossip Ring) (bool, error) {
r.assertInvariants()
defer r.assertInvariants()
defer r.updateExportedVariables()
defer r.trackUpdates()()
// Don't panic when checking the gossiped in ring.
// In this case just return any error found.
if err := gossip.checkInvariants(); err != nil {
return err
return false, err
}
if len(gossip.Seeds) > 0 && len(r.Seeds) > 0 {
if len(gossip.Seeds) != len(r.Seeds) {
return false, ErrDifferentSeeds
}
for i, seed := range gossip.Seeds {
if seed != r.Seeds[i] {
return false, ErrDifferentSeeds
}
}
}
if r.Start != gossip.Start || r.End != gossip.End {
return ErrDifferentSubnets
return false, ErrDifferentRange
}
// Now merge their ring with yours, in a temporary ring.
var result entries
addToResult := func(e entry) { result = append(result, &e) }
result, updated, err := r.Entries.merge(gossip.Entries, r.Peer)
if err != nil {
return false, err
}
if err := r.checkEntries(result); err != nil {
return false, fmt.Errorf("Merge of incoming data causes: %s", err)
}
if len(r.Seeds) == 0 {
r.Seeds = gossip.Seeds
}
r.Entries = result
return updated, nil
}
// Merge other entries into ours, and complain when that stomps on
// entries belonging to ourPeer. Returns the merged entries and an
// indication whether the merge resulted in any changes, i.e. the
// result differs from the original.
func (es entries) merge(other entries, ourPeer mesh.PeerName) (result entries, updated bool, err error) {
var mine, theirs *entry
var previousOwner *router.PeerName
// i is index into r.Entries; j is index into gossip.Entries
var previousOwner *mesh.PeerName
addToResult := func(e entry) { result = append(result, &e) }
addTheirs := func(e entry) {
addToResult(e)
updated = true
previousOwner = nil
}
// i is index into es; j is index into other
var i, j int
for i < len(r.Entries) && j < len(gossip.Entries) {
mine, theirs = r.Entries[i], gossip.Entries[j]
for i < len(es) && j < len(other) {
mine, theirs = es[i], other[j]
switch {
case mine.Token < theirs.Token:
addToResult(*mine)
@@ -218,53 +281,52 @@ func (r *Ring) Merge(gossip Ring) error {
i++
case mine.Token > theirs.Token:
// insert, checking that a range owned by us hasn't been split
if previousOwner != nil && *previousOwner == r.Peer && theirs.Peer != r.Peer {
return ErrEntryInMyRange
if previousOwner != nil && *previousOwner == ourPeer && theirs.Peer != ourPeer {
err = errEntryInMyRange(theirs)
return
}
addToResult(*theirs)
previousOwner = nil
addTheirs(*theirs)
j++
case mine.Token == theirs.Token:
// merge
switch {
case mine.Version >= theirs.Version:
if mine.Version == theirs.Version && !mine.Equal(theirs) {
common.Debug.Printf("Error merging entries at %s - %v != %v\n", mine.Token, mine, theirs)
return ErrInvalidEntry
err = errInconsistentEntry(mine, theirs)
return
}
addToResult(*mine)
previousOwner = &mine.Peer
case mine.Version < theirs.Version:
if mine.Peer == r.Peer { // We shouldn't receive updates to our own tokens
return ErrNewerVersion
if mine.Peer == ourPeer { // We shouldn't receive updates to our own tokens
err = errNewerVersion(mine, theirs)
return
}
addToResult(*theirs)
previousOwner = nil
addTheirs(*theirs)
}
i++
j++
}
}
// At this point, either i is at the end of r or j is at the end
// of gossip, so copy over the remaining entries.
// At this point, either i is at the end of es or j is at the end
// of other, so copy over the remaining entries.
for ; i < len(r.Entries); i++ {
mine = r.Entries[i]
for ; i < len(es); i++ {
mine = es[i]
addToResult(*mine)
}
for ; j < len(gossip.Entries); j++ {
theirs = gossip.Entries[j]
if previousOwner != nil && *previousOwner == r.Peer && theirs.Peer != r.Peer {
return ErrEntryInMyRange
for ; j < len(other); j++ {
theirs = other[j]
if previousOwner != nil && *previousOwner == ourPeer && theirs.Peer != ourPeer {
err = errEntryInMyRange(theirs)
return
}
addToResult(*theirs)
previousOwner = nil
addTheirs(*theirs)
}
r.Entries = result
return nil
return
}
// Empty returns true if the ring has no entries
@@ -297,10 +359,14 @@ func (r *Ring) splitRangesOverZero(ranges []address.Range) []address.Range {
// ranges are owned by this peer. Will split ranges which
// span 0 in the ring.
func (r *Ring) OwnedRanges() (result []address.Range) {
return r.OwnedRangesOfPeer(r.Peer)
}
func (r *Ring) OwnedRangesOfPeer(peer mesh.PeerName) (result []address.Range) {
r.assertInvariants()
for i, entry := range r.Entries {
if entry.Peer == r.Peer {
if entry.Peer == peer {
nextEntry := r.Entries.entry(i + 1)
result = append(result, address.Range{Start: entry.Token, End: nextEntry.Token})
}
@@ -309,43 +375,58 @@ func (r *Ring) OwnedRanges() (result []address.Range) {
return r.splitRangesOverZero(result)
}
// ClaimForPeers claims the entire ring for the array of peers passed
// in. Only works for empty rings.
func (r *Ring) ClaimForPeers(peers []router.PeerName) {
common.Assert(r.Empty())
defer r.assertInvariants()
defer r.updateExportedVariables()
// For printing status
type RangeInfo struct {
Peer mesh.PeerName
address.Range
Version uint32
}
totalSize := r.distance(r.Start, r.End)
share := totalSize/address.Offset(len(peers)) + 1
remainder := totalSize % address.Offset(len(peers))
pos := r.Start
for i, peer := range peers {
if address.Offset(i) == remainder {
share--
if share == 0 {
break
}
func (r *Ring) AllRangeInfo() (result []RangeInfo) {
for i, entry := range r.Entries {
nextEntry := r.Entries.entry(i + 1)
ranges := []address.Range{{Start: entry.Token, End: nextEntry.Token}}
ranges = r.splitRangesOverZero(ranges)
for _, r := range ranges {
result = append(result, RangeInfo{entry.Peer, r, entry.Version})
}
if e, found := r.Entries.get(pos); found {
e.update(peer, share)
} else {
r.Entries.insert(entry{Token: pos, Peer: peer, Free: share})
}
pos += address.Address(share)
}
common.Assert(pos == r.End)
return
}
func (r *Ring) ClaimItAll() {
r.ClaimForPeers([]router.PeerName{r.Peer})
// ClaimForPeers claims the entire ring for the array of peers passed
// in. Only works for empty rings. Each claimed range is CIDR-aligned.
func (r *Ring) ClaimForPeers(peers []mesh.PeerName) {
common.Assert(r.Empty())
defer r.trackUpdates()()
defer r.assertInvariants()
defer func() {
e := r.Entries[len(r.Entries)-1]
common.Assert(address.Add(e.Token, address.Offset(e.Free)) == r.End)
}()
r.subdivide(r.Start, r.End, peers)
r.Seeds = peers
}
func (r *Ring) FprintWithNicknames(w io.Writer, m map[router.PeerName]string) {
// subdivide subdivides the [from,to) CIDR for the given peers into
// CIDR-aligned subranges.
func (r *Ring) subdivide(from, to address.Address, peers []mesh.PeerName) {
share := address.Length(to, from)
if share == 0 {
return
}
if share == 1 || len(peers) == 1 {
r.Entries.insert(entry{Token: from, Peer: peers[0], Free: share})
return
}
mid := address.Add(from, address.Offset(share/2))
r.subdivide(from, mid, peers[:len(peers)/2])
r.subdivide(address.Add(mid, address.Offset(share%2)), to, peers[len(peers)/2:])
}
func (r *Ring) FprintWithNicknames(w io.Writer, m map[mesh.PeerName]string) {
for _, entry := range r.Entries {
nickname, found := m[entry.Peer]
if found {
@@ -360,17 +441,16 @@ func (r *Ring) FprintWithNicknames(w io.Writer, m map[router.PeerName]string) {
func (r *Ring) String() string {
var buffer bytes.Buffer
fmt.Fprintf(&buffer, "Ring [%s, %s)", r.Start, r.End)
r.FprintWithNicknames(&buffer, make(map[router.PeerName]string))
r.FprintWithNicknames(&buffer, make(map[mesh.PeerName]string))
return buffer.String()
}
// ReportFree is used by the allocator to tell the ring
// how many free ips are in a given range, so that ChoosePeerToAskForSpace
// can make more intelligent decisions.
func (r *Ring) ReportFree(freespace map[address.Address]address.Offset) {
// ReportFree is used by the allocator to tell the ring how many free
// ips are in a given range, so that ChoosePeersToAskForSpace can make
// more intelligent decisions. Returns true if any changes made.
func (r *Ring) ReportFree(freespace map[address.Address]address.Count) (updated bool) {
r.assertInvariants()
defer r.assertInvariants()
defer r.updateExportedVariables()
common.Assert(!r.Empty())
entries := r.Entries
@@ -397,27 +477,44 @@ func (r *Ring) ReportFree(freespace map[address.Address]address.Offset) {
// Check we're not reporting more space than the range
entry, next := entries.entry(i), entries.entry(i+1)
maxSize := r.distance(entry.Token, next.Token)
common.Assert(free <= maxSize)
common.Assert(free <= address.Count(maxSize))
if entries[i].Free == free {
return
continue
}
entries[i].Free = free
entries[i].Version++
updated = true
}
return
}
// ChoosePeerToAskForSpace chooses a weighted-random peer to ask
// for space.
func (r *Ring) ChoosePeerToAskForSpace() (result router.PeerName, err error) {
var (
sum address.Offset
totalSpacePerPeer = make(map[router.PeerName]address.Offset) // Compute total free space per peer
)
type weightedPeer struct {
weight float64
peername mesh.PeerName
}
type weightedPeers []weightedPeer
// Note Less is using > so that bigger weights sort earlier
func (ws weightedPeers) Less(i, j int) bool { return ws[i].weight > ws[j].weight }
func (ws weightedPeers) Len() int { return len(ws) }
func (ws weightedPeers) Swap(i, j int) { ws[i], ws[j] = ws[j], ws[i] }
// ChoosePeersToAskForSpace returns all peers we can ask for space in
// the range [start, end), in weighted-random order. Assumes start<end.
func (r *Ring) ChoosePeersToAskForSpace(start, end address.Address) []mesh.PeerName {
totalSpacePerPeer := make(map[mesh.PeerName]address.Count)
// iterate through tokens
for _, entry := range r.Entries {
for i, entry := range r.Entries {
// Ignore entries that don't span the range we want
if i+1 < len(r.Entries) && r.Entries.entry(i+1).Token-1 < start {
continue
}
if entry.Token >= end {
break
}
// Ignore ranges with no free space
if entry.Free <= 0 {
continue
@@ -429,59 +526,51 @@ func (r *Ring) ChoosePeerToAskForSpace() (result router.PeerName, err error) {
}
totalSpacePerPeer[entry.Peer] += entry.Free
sum += entry.Free
}
if sum == 0 {
err = ErrNoFreeSpace
return
}
// Pick random peer, weighted by total free space
rn := rand.Int63n(int64(sum))
// Compute weighted random numbers, then sort.
// This isn't perfect, e.g. an item with weight 2 will get chosen more than
// twice as often as an item with weight 1, but it's good enough for our purposes.
ws := make(weightedPeers, 0, len(totalSpacePerPeer))
for peername, space := range totalSpacePerPeer {
rn -= int64(space)
if rn < 0 {
return peername, nil
}
ws = append(ws, weightedPeer{weight: float64(space) * rand.Float64(), peername: peername})
}
panic("Should never reach this point")
sort.Sort(ws)
result := make([]mesh.PeerName, len(ws))
for i, wp := range ws {
result[i] = wp.peername
}
return result
}
func (r *Ring) PickPeerForTransfer() router.PeerName {
func (r *Ring) PickPeerForTransfer(isValid func(mesh.PeerName) bool) mesh.PeerName {
for _, entry := range r.Entries {
if entry.Peer != r.Peer {
if entry.Peer != r.Peer && isValid(entry.Peer) {
return entry.Peer
}
}
return router.UnknownPeerName
return mesh.UnknownPeerName
}
// Transfer will mark all entries associated with 'from' peer as owned by 'to' peer
// and return ranges indicating the new space we picked up
func (r *Ring) Transfer(from, to router.PeerName) (error, []address.Range) {
func (r *Ring) Transfer(from, to mesh.PeerName) []address.Range {
r.assertInvariants()
defer r.trackUpdates()()
defer r.trackUpdatesOfPeer(from)()
defer r.assertInvariants()
defer r.updateExportedVariables()
var newRanges []address.Range
found := false
for i, entry := range r.Entries {
if entry.Peer == from {
found = true
entry.Peer = to
entry.Version++
newRanges = append(newRanges, address.Range{Start: entry.Token, End: r.Entries.entry(i + 1).Token})
}
}
if !found {
return ErrNotFound, nil
}
return nil, r.splitRangesOverZero(newRanges)
return r.splitRangesOverZero(newRanges)
}
// Contains returns true if addr is in this ring
@@ -490,13 +579,13 @@ func (r *Ring) Contains(addr address.Address) bool {
}
// Owner returns the peername which owns the range containing addr
func (r *Ring) Owner(token address.Address) router.PeerName {
func (r *Ring) Owner(token address.Address) mesh.PeerName {
common.Assert(r.Start <= token && token < r.End)
r.assertInvariants()
// There can be no owners on an empty ring
if r.Empty() {
return router.UnknownPeerName
return mesh.UnknownPeerName
}
// Look for the right-most entry, less than or equal to token
@@ -509,8 +598,8 @@ func (r *Ring) Owner(token address.Address) router.PeerName {
}
// Get the set of PeerNames mentioned in the ring
func (r *Ring) PeerNames() map[router.PeerName]struct{} {
res := make(map[router.PeerName]struct{})
func (r *Ring) PeerNames() map[mesh.PeerName]struct{} {
res := make(map[mesh.PeerName]struct{})
for _, entry := range r.Entries {
res[entry.Peer] = struct{}{}
@@ -518,3 +607,7 @@ func (r *Ring) PeerNames() map[router.PeerName]struct{} {
return res
}
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
+272 -203
View File
@@ -7,18 +7,20 @@ import (
"sort"
"testing"
"github.com/stretchr/testify/require"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/router"
wt "github.com/weaveworks/weave/testing"
"github.com/weaveworks/weave/net/address"
)
var (
peer1name, _ = router.PeerNameFromString("01:00:00:00:02:00")
peer2name, _ = router.PeerNameFromString("02:00:00:00:02:00")
peer3name, _ = router.PeerNameFromString("03:00:00:00:02:00")
peer1name, _ = mesh.PeerNameFromString("01:00:00:00:02:00")
peer2name, _ = mesh.PeerNameFromString("02:00:00:00:02:00")
peer3name, _ = mesh.PeerNameFromString("03:00:00:00:02:00")
start, end = ParseIP("10.0.0.0"), ParseIP("10.0.0.255")
start, end = ParseIP("10.0.0.0"), ParseIP("10.0.1.0")
dot8 = ParseIP("10.0.0.8")
dot10, dot245 = ParseIP("10.0.0.10"), ParseIP("10.0.0.245")
dot250 = ParseIP("10.0.0.250")
middle = ParseIP("10.0.0.128")
@@ -29,54 +31,69 @@ func ParseIP(s string) address.Address {
return addr
}
func merge(r1, r2 *Ring) error {
_, err := r1.Merge(*r2)
return err
}
func NewRing(start, end address.Address, peer mesh.PeerName) *Ring {
return New(start, end, peer, nil)
}
func TestInvariants(t *testing.T) {
ring := New(start, end, peer1name)
ring := NewRing(start, end, peer1name)
// Check ring is sorted
ring.Entries = []*entry{{Token: dot245, Peer: peer1name}, {Token: dot10, Peer: peer2name}}
wt.AssertTrue(t, ring.checkInvariants() == ErrNotSorted, "Expected error")
require.True(t, ring.checkInvariants() == ErrNotSorted, "Expected error")
// Check tokens don't appear twice
ring.Entries = []*entry{{Token: dot245, Peer: peer1name}, {Token: dot245, Peer: peer2name}}
wt.AssertTrue(t, ring.checkInvariants() == ErrTokenRepeated, "Expected error")
require.True(t, ring.checkInvariants() == ErrTokenRepeated, "Expected error")
// Check tokens are in bounds
ring = New(dot10, dot245, peer1name)
ring = NewRing(dot10, dot245, peer1name)
ring.Entries = []*entry{{Token: start, Peer: peer1name}}
wt.AssertTrue(t, ring.checkInvariants() == ErrTokenOutOfRange, "Expected error")
require.True(t, ring.checkInvariants() == ErrTokenOutOfRange, "Expected error")
ring.Entries = []*entry{{Token: end, Peer: peer1name}}
wt.AssertTrue(t, ring.checkInvariants() == ErrTokenOutOfRange, "Expected error")
require.True(t, ring.checkInvariants() == ErrTokenOutOfRange, "Expected error")
}
func TestInsert(t *testing.T) {
ring := New(start, end, peer1name)
ring := NewRing(start, end, peer1name)
ring.Entries = []*entry{{Token: start, Peer: peer1name, Free: 255}}
wt.AssertPanic(t, func() {
require.Panics(t, func() {
ring.Entries.insert(entry{Token: start, Peer: peer1name})
})
ring.Entries.entry(0).Free = 0
ring.Entries.insert(entry{Token: dot245, Peer: peer1name})
ring2 := New(start, end, peer1name)
ring2.Entries = []*entry{{Token: start, Peer: peer1name, Free: 0}, {Token: dot245, Peer: peer1name}}
wt.AssertEquals(t, ring, ring2)
check := []RangeInfo{
{Peer: peer1name, Range: address.Range{Start: start, End: dot245}},
{Peer: peer1name, Range: address.Range{Start: dot245, End: end}},
}
require.Equal(t, check, ring.AllRangeInfo())
ring.Entries.insert(entry{Token: dot10, Peer: peer1name})
ring2.Entries = []*entry{{Token: start, Peer: peer1name, Free: 0}, {Token: dot10, Peer: peer1name}, {Token: dot245, Peer: peer1name}}
wt.AssertEquals(t, ring, ring2)
check2 := []RangeInfo{
{Peer: peer1name, Range: address.Range{Start: start, End: dot10}},
{Peer: peer1name, Range: address.Range{Start: dot10, End: dot245}},
{Peer: peer1name, Range: address.Range{Start: dot245, End: end}},
}
require.Equal(t, check2, ring.AllRangeInfo())
}
func TestBetween(t *testing.T) {
ring1 := New(start, end, peer1name)
ring1 := NewRing(start, end, peer1name)
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 255}}
// First off, in a ring where everything is owned by the peer
// between should return true for everything
for i := 1; i <= 255; i++ {
ip := ParseIP(fmt.Sprintf("10.0.0.%d", i))
wt.AssertTrue(t, ring1.Entries.between(ip, 0, 1), "between should be true!")
require.True(t, ring1.Entries.between(ip, 0, 1), "between should be true!")
}
// Now, construct a ring with entries at +10 and -10
@@ -87,151 +104,157 @@ func TestBetween(t *testing.T) {
for i := 10; i <= 244; i++ {
ipStr := fmt.Sprintf("10.0.0.%d", i)
ip := ParseIP(ipStr)
wt.AssertTrue(t, ring1.Entries.between(ip, 0, 1),
require.True(t, ring1.Entries.between(ip, 0, 1),
fmt.Sprintf("Between should be true for %s!", ipStr))
wt.AssertFalse(t, ring1.Entries.between(ip, 1, 2),
require.False(t, ring1.Entries.between(ip, 1, 2),
fmt.Sprintf("Between should be false for %s!", ipStr))
}
for i := 0; i <= 9; i++ {
ipStr := fmt.Sprintf("10.0.0.%d", i)
ip := ParseIP(ipStr)
wt.AssertFalse(t, ring1.Entries.between(ip, 0, 1),
require.False(t, ring1.Entries.between(ip, 0, 1),
fmt.Sprintf("Between should be false for %s!", ipStr))
wt.AssertTrue(t, ring1.Entries.between(ip, 1, 2),
require.True(t, ring1.Entries.between(ip, 1, 2),
fmt.Sprintf("Between should be true for %s!", ipStr))
}
for i := 245; i <= 255; i++ {
ipStr := fmt.Sprintf("10.0.0.%d", i)
ip := ParseIP(ipStr)
wt.AssertFalse(t, ring1.Entries.between(ip, 0, 1),
require.False(t, ring1.Entries.between(ip, 0, 1),
fmt.Sprintf("Between should be false for %s!", ipStr))
wt.AssertTrue(t, ring1.Entries.between(ip, 1, 2),
require.True(t, ring1.Entries.between(ip, 1, 2),
fmt.Sprintf("Between should be true for %s!", ipStr))
}
}
func TestGrantSimple(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
// Claim everything for peer1
ring1.ClaimItAll()
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer1name, Free: 255}})
require.Equal(t, entries{{Token: start, Peer: peer1name, Free: 256}}, ring1.Entries)
// Now grant everything to peer2
ring1.GrantRangeToHost(start, end, peer2name)
ring2.Entries = []*entry{{Token: start, Peer: peer2name, Free: 255, Version: 1}}
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
ring2.Entries = []*entry{{Token: start, Peer: peer2name, Free: 256, Version: 1}}
require.Equal(t, ring2.Entries, ring1.Entries)
// Now spint back to peer 1
ring2.GrantRangeToHost(dot10, end, peer1name)
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 10, Version: 2},
{Token: dot10, Peer: peer1name, Free: 245}}
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
{Token: dot10, Peer: peer1name, Free: 246}}
require.Equal(t, ring2.Entries, ring1.Entries)
// And spint back to peer 2 again
ring1.GrantRangeToHost(dot245, end, peer2name)
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer2name, Free: 10, Version: 2},
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 10, Version: 2},
{Token: dot10, Peer: peer1name, Free: 235, Version: 1},
{Token: dot245, Peer: peer2name, Free: 10}})
{Token: dot245, Peer: peer2name, Free: 11}}, ring1.Entries)
// Grant range spanning a live token
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 10, Version: 2},
{Token: dot10, Peer: peer1name, Free: 235}, {Token: dot245, Peer: peer1name, Free: 10}}
ring1.GrantRangeToHost(dot10, end, peer2name)
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer1name, Free: 10, Version: 2},
require.Equal(t, entries{{Token: start, Peer: peer1name, Free: 10, Version: 2},
{Token: dot10, Peer: peer2name, Free: 235, Version: 1},
{Token: dot245, Peer: peer2name, Free: 10, Version: 1}})
{Token: dot245, Peer: peer2name, Free: 10, Version: 1}}, ring1.Entries)
}
func TestGrantSplit(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
// Claim everything for peer1
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 255}}
ring2.Merge(*ring1)
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 256}}
merge(ring2, ring1)
require.Equal(t, ring2.Entries, ring1.Entries)
// Now grant a split range to peer2
ring1.GrantRangeToHost(dot10, dot245, peer2name)
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer1name, Free: 10, Version: 1},
require.Equal(t, entries{{Token: start, Peer: peer1name, Free: 10, Version: 1},
{Token: dot10, Peer: peer2name, Free: 235},
{Token: dot245, Peer: peer1name, Free: 10}})
{Token: dot245, Peer: peer1name, Free: 11}}, ring1.Entries)
ring1.assertInvariants()
// Grant range spanning a live token, and inserting a new token
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 10, Version: 2},
{Token: dot10, Peer: peer1name, Free: 118}, {Token: middle, Peer: peer1name, Free: 127}}
ring1.GrantRangeToHost(dot10, dot245, peer2name)
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer1name, Free: 10, Version: 2},
require.Equal(t, entries{{Token: start, Peer: peer1name, Free: 10, Version: 2},
{Token: dot10, Peer: peer2name, Free: 118, Version: 1},
{Token: middle, Peer: peer2name, Free: 117, Version: 1},
{Token: dot245, Peer: peer1name, Free: 10, Version: 0}})
{Token: dot245, Peer: peer1name, Free: 11, Version: 0}}, ring1.Entries)
ring1.assertInvariants()
}
func TestMergeSimple(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
// Claim everything for peer1
ring1.ClaimItAll()
ring1.GrantRangeToHost(middle, end, peer2name)
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer1name, Free: 128, Version: 1},
{Token: middle, Peer: peer2name, Free: 127}})
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
require.Equal(t, entries{{Token: start, Peer: peer1name, Free: 128, Version: 1},
{Token: middle, Peer: peer2name, Free: 128}}, ring1.Entries)
require.Equal(t, ring2.Entries, ring1.Entries)
// Now to two different operations on either side,
// check we can Merge again
ring1.GrantRangeToHost(start, middle, peer2name)
ring2.GrantRangeToHost(middle, end, peer1name)
wt.AssertSuccess(t, ring2.Merge(*ring1))
wt.AssertSuccess(t, ring1.Merge(*ring2))
require.NoError(t, merge(ring2, ring1))
require.NoError(t, merge(ring1, ring2))
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127, Version: 1}})
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 128, Version: 1}}, ring1.Entries)
require.Equal(t, ring2.Entries, ring1.Entries)
}
func TestMergeErrors(t *testing.T) {
// Cannot Merge in an invalid ring
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
ring2.Entries = []*entry{{Token: middle, Peer: peer2name}, {Token: start, Peer: peer2name}}
wt.AssertTrue(t, ring1.Merge(*ring2) == ErrNotSorted, "Expected ErrNotSorted")
require.True(t, merge(ring1, ring2) == ErrNotSorted, "Expected ErrNotSorted")
// Should Merge two rings for different ranges
ring2 = New(start, middle, peer2name)
ring2 = NewRing(start, middle, peer2name)
ring2.Entries = []*entry{}
wt.AssertTrue(t, ring1.Merge(*ring2) == ErrDifferentSubnets, "Expected ErrDifferentSubnets")
require.True(t, merge(ring1, ring2) == ErrDifferentRange, "Expected ErrDifferentRange")
// Cannot Merge newer version of entry I own
ring2 = New(start, end, peer2name)
ring2 = NewRing(start, end, peer2name)
ring1.Entries = []*entry{{Token: start, Peer: peer1name}}
ring2.Entries = []*entry{{Token: start, Peer: peer1name, Version: 1}}
wt.AssertTrue(t, ring1.Merge(*ring2) == ErrNewerVersion, "Expected ErrNewerVersion")
fmt.Println(merge(ring1, ring2))
require.Error(t, merge(ring1, ring2), "Expected error")
// Cannot Merge two entries with same version but different hosts
ring1.Entries = []*entry{{Token: start, Peer: peer1name}}
ring2.Entries = []*entry{{Token: start, Peer: peer2name}}
wt.AssertTrue(t, ring1.Merge(*ring2) == ErrInvalidEntry, "Expected ErrInvalidEntry")
require.Error(t, merge(ring1, ring2), "Expected error")
// Cannot Merge an entry into a range I own
ring1.Entries = []*entry{{Token: start, Peer: peer1name}}
ring2.Entries = []*entry{{Token: middle, Peer: peer2name}}
wt.AssertTrue(t, ring1.Merge(*ring2) == ErrEntryInMyRange, "Expected ErrEntryInMyRange")
require.Error(t, merge(ring1, ring2), "Expected error")
}
func TestMergeMore(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
assertRing := func(ring *Ring, entries entries) {
wt.AssertEquals(t, ring.Entries, entries)
require.Equal(t, entries, ring.Entries)
}
assertRing(ring1, []*entry{})
@@ -239,93 +262,97 @@ func TestMergeMore(t *testing.T) {
// Claim everything for peer1
ring1.ClaimItAll()
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 255}})
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 256}})
assertRing(ring2, []*entry{})
// Check the Merge sends it to the other ring
wt.AssertSuccess(t, ring2.Merge(*ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 255}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 255}})
require.NoError(t, merge(ring2, ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 256}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 256}})
// Give everything to peer2
ring1.GrantRangeToHost(start, end, peer2name)
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 255, Version: 1}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 255}})
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 256, Version: 1}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 256}})
wt.AssertSuccess(t, ring2.Merge(*ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 255, Version: 1}})
assertRing(ring2, []*entry{{Token: start, Peer: peer2name, Free: 255, Version: 1}})
require.NoError(t, merge(ring2, ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 256, Version: 1}})
assertRing(ring2, []*entry{{Token: start, Peer: peer2name, Free: 256, Version: 1}})
// And carve off some space
ring2.GrantRangeToHost(middle, end, peer1name)
assertRing(ring2, []*entry{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127}})
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 255, Version: 1}})
{Token: middle, Peer: peer1name, Free: 128}})
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 256, Version: 1}})
// And Merge back
wt.AssertSuccess(t, ring1.Merge(*ring2))
require.NoError(t, merge(ring1, ring2))
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127}})
{Token: middle, Peer: peer1name, Free: 128}})
assertRing(ring2, []*entry{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127}})
{Token: middle, Peer: peer1name, Free: 128}})
// This should be a no-op
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127}})
{Token: middle, Peer: peer1name, Free: 128}})
assertRing(ring2, []*entry{{Token: start, Peer: peer2name, Free: 128, Version: 2},
{Token: middle, Peer: peer1name, Free: 127}})
{Token: middle, Peer: peer1name, Free: 128}})
}
func TestMergeSplit(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
// Claim everything for peer2
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 255}}
wt.AssertSuccess(t, ring2.Merge(*ring1))
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 256}}
require.NoError(t, merge(ring2, ring1))
require.Equal(t, ring2.Entries, ring1.Entries)
// Now grant a split range to peer1
ring2.GrantRangeToHost(dot10, dot245, peer1name)
wt.AssertEquals(t, ring2.Entries, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot10, Peer: peer1name, Free: 235},
{Token: dot245, Peer: peer2name, Free: 10}})
wt.AssertSuccess(t, ring1.Merge(*ring2))
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot245, Peer: peer2name, Free: 11}}, ring2.Entries)
require.NoError(t, merge(ring1, ring2))
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot10, Peer: peer1name, Free: 235},
{Token: dot245, Peer: peer2name, Free: 10}})
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
{Token: dot245, Peer: peer2name, Free: 11}}, ring1.Entries)
require.Equal(t, ring2.Entries, ring1.Entries)
}
func TestMergeSplit2(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
// Claim everything for peer2
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 250}, {Token: dot250, Peer: peer2name, Free: 5}}
wt.AssertSuccess(t, ring2.Merge(*ring1))
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
require.NoError(t, merge(ring2, ring1))
require.Equal(t, ring2.Entries, ring1.Entries)
// Now grant a split range to peer1
ring2.GrantRangeToHost(dot10, dot245, peer1name)
wt.AssertEquals(t, ring2.Entries, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot10, Peer: peer1name, Free: 235},
{Token: dot245, Peer: peer2name, Free: 5}, {Token: dot250, Peer: peer2name, Free: 5}})
wt.AssertSuccess(t, ring1.Merge(*ring2))
wt.AssertEquals(t, ring1.Entries, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot245, Peer: peer2name, Free: 5}, {Token: dot250, Peer: peer2name, Free: 5}}, ring2.Entries)
require.NoError(t, merge(ring1, ring2))
require.Equal(t, entries{{Token: start, Peer: peer2name, Free: 10, Version: 1},
{Token: dot10, Peer: peer1name, Free: 235},
{Token: dot245, Peer: peer2name, Free: 5}, {Token: dot250, Peer: peer2name, Free: 5}})
wt.AssertEquals(t, ring1.Entries, ring2.Entries)
{Token: dot245, Peer: peer2name, Free: 5}, {Token: dot250, Peer: peer2name, Free: 5}}, ring1.Entries)
require.Equal(t, ring2.Entries, ring1.Entries)
}
// A simple test, very similar to above, but using the marshalling to byte[]s
func TestGossip(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
assertRing := func(ring *Ring, entries entries) {
wt.AssertEquals(t, ring.Entries, entries)
require.Equal(t, entries, ring.Entries)
}
assertRing(ring1, []*entry{})
@@ -333,57 +360,66 @@ func TestGossip(t *testing.T) {
// Claim everything for peer1
ring1.ClaimItAll()
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 255}})
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 256}})
assertRing(ring2, []*entry{})
// Check the Merge sends it to the other ring
wt.AssertSuccess(t, ring2.Merge(*ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 255}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 255}})
require.NoError(t, merge(ring2, ring1))
assertRing(ring1, []*entry{{Token: start, Peer: peer1name, Free: 256}})
assertRing(ring2, []*entry{{Token: start, Peer: peer1name, Free: 256}})
}
func assertPeersWithSpace(t *testing.T, ring *Ring, start, end address.Address, expected int) []mesh.PeerName {
peers := ring.ChoosePeersToAskForSpace(start, end)
require.Equal(t, expected, len(peers))
return peers
}
func TestFindFree(t *testing.T) {
ring1 := New(start, end, peer1name)
ring1 := NewRing(start, end, peer1name)
_, err := ring1.ChoosePeerToAskForSpace()
wt.AssertTrue(t, err == ErrNoFreeSpace, "Expected ErrNoFreeSpace")
assertPeersWithSpace(t, ring1, start, end, 0)
ring1.Entries = []*entry{{Token: start, Peer: peer1name}}
_, err = ring1.ChoosePeerToAskForSpace()
wt.AssertTrue(t, err == ErrNoFreeSpace, "Expected ErrNoFreeSpace")
assertPeersWithSpace(t, ring1, start, end, 0)
// We shouldn't return outselves
ring1.ReportFree(map[address.Address]address.Offset{start: 10})
_, err = ring1.ChoosePeerToAskForSpace()
wt.AssertTrue(t, err == ErrNoFreeSpace, "Expected ErrNoFreeSpace")
ring1.ReportFree(map[address.Address]address.Count{start: 10})
assertPeersWithSpace(t, ring1, start, end, 0)
ring1.Entries = []*entry{{Token: start, Peer: peer1name, Free: 1},
{Token: start, Peer: peer1name, Free: 1}}
_, err = ring1.ChoosePeerToAskForSpace()
wt.AssertTrue(t, err == ErrNoFreeSpace, "Expected ErrNoFreeSpace")
{Token: middle, Peer: peer1name, Free: 1}}
assertPeersWithSpace(t, ring1, start, end, 0)
ring1.assertInvariants()
// We should return others
var peers []mesh.PeerName
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 1}}
peer, err := ring1.ChoosePeerToAskForSpace()
wt.AssertSuccess(t, err)
wt.AssertEquals(t, peer, peer2name)
peers = assertPeersWithSpace(t, ring1, start, end, 1)
require.Equal(t, peer2name, peers[0])
ring1.Entries = []*entry{{Token: start, Peer: peer2name, Free: 1},
{Token: start, Peer: peer2name, Free: 1}}
peer, err = ring1.ChoosePeerToAskForSpace()
wt.AssertSuccess(t, err)
wt.AssertEquals(t, peer, peer2name)
{Token: middle, Peer: peer3name, Free: 1}}
peers = assertPeersWithSpace(t, ring1, start, middle, 1)
require.Equal(t, peer2name, peers[0])
peers = assertPeersWithSpace(t, ring1, middle, end, 1)
require.Equal(t, peer3name, peers[0])
assertPeersWithSpace(t, ring1, start, end, 2)
ring1.assertInvariants()
}
func TestReportFree(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
ring1.ClaimItAll()
ring1.GrantRangeToHost(middle, end, peer2name)
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
freespace := make(map[address.Address]address.Offset)
freespace := make(map[address.Address]address.Count)
for _, r := range ring2.OwnedRanges() {
freespace[r.Start] = 0
}
@@ -391,100 +427,130 @@ func TestReportFree(t *testing.T) {
}
func TestMisc(t *testing.T) {
ring := New(start, end, peer1name)
ring := NewRing(start, end, peer1name)
wt.AssertTrue(t, ring.Empty(), "empty")
require.True(t, ring.Empty(), "empty")
ring.ClaimItAll()
println(ring.String())
}
func TestEmptyGossip(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
ring1.ClaimItAll()
// This used to panic, and it shouldn't
wt.AssertSuccess(t, ring1.Merge(*ring2))
require.NoError(t, merge(ring1, ring2))
}
func TestMergeOldMessage(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
ring1.ClaimItAll()
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
ring1.GrantRangeToHost(middle, end, peer1name)
wt.AssertSuccess(t, ring1.Merge(*ring2))
require.NoError(t, merge(ring1, ring2))
}
func TestSplitRangeAtBeginning(t *testing.T) {
ring1 := New(start, end, peer1name)
ring2 := New(start, end, peer2name)
ring1 := NewRing(start, end, peer1name)
ring2 := NewRing(start, end, peer2name)
ring1.ClaimItAll()
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
ring1.GrantRangeToHost(start, middle, peer2name)
wt.AssertSuccess(t, ring2.Merge(*ring1))
require.NoError(t, merge(ring2, ring1))
}
func TestOwnedRange(t *testing.T) {
ring1 := New(start, end, peer1name)
ring1 := NewRing(start, end, peer1name)
ring1.ClaimItAll()
wt.AssertEquals(t, ring1.OwnedRanges(), []address.Range{{Start: start, End: end}})
require.Equal(t, []address.Range{{Start: start, End: end}}, ring1.OwnedRanges())
ring1.GrantRangeToHost(middle, end, peer2name)
wt.AssertEquals(t, ring1.OwnedRanges(), []address.Range{{Start: start, End: middle}})
require.Equal(t, []address.Range{{Start: start, End: middle}}, ring1.OwnedRanges())
ring2 := New(start, end, peer2name)
ring2.Merge(*ring1)
wt.AssertEquals(t, ring2.OwnedRanges(), []address.Range{{Start: middle, End: end}})
ring2 := NewRing(start, end, peer2name)
merge(ring2, ring1)
require.Equal(t, []address.Range{{Start: middle, End: end}}, ring2.OwnedRanges())
ring2.Entries = []*entry{{Token: middle, Peer: peer2name}}
wt.AssertEquals(t, ring2.OwnedRanges(),
[]address.Range{{Start: start, End: middle}, {Start: middle, End: end}})
require.Equal(t, []address.Range{{Start: start, End: middle}, {Start: middle, End: end}}, ring2.OwnedRanges())
ring2.Entries = []*entry{{Token: dot10, Peer: peer2name}, {Token: middle, Peer: peer2name}}
wt.AssertEquals(t, ring2.OwnedRanges(),
[]address.Range{{Start: start, End: dot10}, {Start: dot10, End: middle},
{Start: middle, End: end}})
require.Equal(t, []address.Range{{Start: start, End: dot10}, {Start: dot10, End: middle},
{Start: middle, End: end}}, ring2.OwnedRanges())
}
func TestTransfer(t *testing.T) {
// First test just checks if we can grant some range to a host, when we transfer it, we get it back
ring1 := New(start, end, peer1name)
ring1 := NewRing(start, end, peer1name)
ring1.ClaimItAll()
ring1.GrantRangeToHost(middle, end, peer2name)
ring1.Transfer(peer2name, peer1name)
wt.AssertEquals(t, ring1.OwnedRanges(), []address.Range{{start, middle}, {middle, end}})
require.Equal(t, []address.Range{{Start: start, End: middle}, {Start: middle, End: end}}, ring1.OwnedRanges())
// Second test is what happens when a token exists at the end of a range but is transferred
// - does it get resurrected correctly?
ring1 = New(start, end, peer1name)
ring1 = NewRing(start, end, peer1name)
ring1.ClaimItAll()
ring1.GrantRangeToHost(middle, end, peer2name)
ring1.Transfer(peer2name, peer1name)
ring1.GrantRangeToHost(dot10, middle, peer2name)
wt.AssertEquals(t, ring1.OwnedRanges(), []address.Range{{start, dot10}, {middle, end}})
require.Equal(t, []address.Range{{Start: start, End: dot10}, {Start: middle, End: end}}, ring1.OwnedRanges())
}
func TestOwner(t *testing.T) {
ring1 := New(start, end, peer1name)
wt.AssertTrue(t, ring1.Contains(start), "start should be in ring")
wt.AssertFalse(t, ring1.Contains(end), "end should not be in ring")
ring1 := NewRing(start, end, peer1name)
require.True(t, ring1.Contains(start), "start should be in ring")
require.False(t, ring1.Contains(end), "end should not be in ring")
wt.AssertEquals(t, ring1.Owner(start), router.UnknownPeerName)
require.Equal(t, mesh.UnknownPeerName, ring1.Owner(start))
ring1.ClaimItAll()
ring1.GrantRangeToHost(middle, end, peer2name)
wt.AssertEquals(t, ring1.Owner(start), peer1name)
wt.AssertEquals(t, ring1.Owner(middle), peer2name)
wt.AssertPanic(t, func() {
require.Equal(t, peer1name, ring1.Owner(start))
require.Equal(t, peer2name, ring1.Owner(middle))
require.Panics(t, func() {
ring1.Owner(end)
})
}
func makePeerName(i int) mesh.PeerName {
if i >= 10000 {
panic("makePeerName: invalid value")
}
peer, _ := mesh.PeerNameFromString(fmt.Sprintf("%02d:%02d:00:00:00:ff", i/100, i%100))
return peer
}
func makePeers(numPeers int) []mesh.PeerName {
peers := make([]mesh.PeerName, numPeers)
for i := 0; i < numPeers; i++ {
peers[i] = makePeerName(i)
}
return peers
}
func TestClaimForPeers(t *testing.T) {
const numPeers = 12
// Different end to usual so we get a number of addresses that a)
// is smaller than the max number of peers, and b) is divisible by
// some number of peers. This maximises coverage of edge cases.
end := dot8
peers := makePeers(numPeers)
// Test for a range of peer counts
for i := 0; i < numPeers; i++ {
ring := NewRing(start, end, peers[0])
ring.ClaimForPeers(peers[:i+1])
}
}
type addressSlice []address.Address
@@ -499,10 +565,9 @@ func TestFuzzRing(t *testing.T) {
iterations = 1000
)
peers := make([]router.PeerName, numPeers)
peers := make([]mesh.PeerName, numPeers)
for i := 0; i < numPeers; i++ {
peer, _ := router.PeerNameFromString(fmt.Sprintf("%02d:00:00:00:02:00", i))
peers[i] = peer
peers[i] = makePeerName(i)
}
// Make a valid, random ring
@@ -521,7 +586,7 @@ func TestFuzzRing(t *testing.T) {
sort.Sort(addressSlice(tokens))
peer := peers[rand.Intn(len(peers))]
ring := New(start, end, peer)
ring := NewRing(start, end, peer)
for _, token := range tokens {
peer = peers[rand.Intn(len(peers))]
ring.Entries = append(ring.Entries, &entry{Token: start + token, Peer: peer})
@@ -538,7 +603,7 @@ func TestFuzzRing(t *testing.T) {
// Merge them - this might fail, we don't care
// We just want to make sure it doesn't panic
ring1.Merge(*ring2)
merge(ring1, ring2)
// Check whats left still passes assertions
ring1.assertInvariants()
@@ -555,7 +620,7 @@ func TestFuzzRing(t *testing.T) {
}
peer := peers[rand.Intn(len(peers))]
ring := New(start, end, peer)
ring := NewRing(start, end, peer)
for _, token := range tokens {
peer = peers[rand.Intn(len(peers))]
ring.Entries = append(ring.Entries, &entry{Token: start + token, Peer: peer})
@@ -571,7 +636,7 @@ func TestFuzzRing(t *testing.T) {
// Merge them - this might fail, we don't care
// We just want to make sure it doesn't panic
ring1.Merge(*ring2)
merge(ring1, ring2)
// Check whats left still passes assertions
ring1.assertInvariants()
@@ -579,21 +644,21 @@ func TestFuzzRing(t *testing.T) {
}
func TestFuzzRingHard(t *testing.T) {
//common.InitDefaultLogging(true)
//common.SetLogLevel("debug")
var (
numPeers = 100
iterations = 3000
peers []router.PeerName
peers []mesh.PeerName
rings []*Ring
nextPeerID = 0
)
addPeer := func() {
peer, _ := router.PeerNameFromString(fmt.Sprintf("%02d:%02d:00:00:00:00", nextPeerID/10, nextPeerID%10))
common.Debug.Printf("%s: Adding peer", peer)
peer := makePeerName(nextPeerID)
common.Log.Debugf("%s: Adding peer", peer)
nextPeerID++
peers = append(peers, peer)
rings = append(rings, New(start, end, peer))
rings = append(rings, NewRing(start, end, peer))
}
for i := 0; i < numPeers; i++ {
@@ -602,7 +667,7 @@ func TestFuzzRingHard(t *testing.T) {
rings[0].ClaimItAll()
randomPeer := func(exclude int) (int, router.PeerName, *Ring) {
randomPeer := func(exclude int) (int, mesh.PeerName, *Ring) {
var peerIndex int
if exclude >= 0 {
peerIndex = rand.Intn(len(peers) - 1)
@@ -626,27 +691,27 @@ func TestFuzzRingHard(t *testing.T) {
return
}
// Pick one peer to remove, and a different one to transfer to
peerIndex, peername, _ := randomPeer(-1)
_, otherPeername, otherRing := randomPeer(peerIndex)
// We need to be in a ~converged ring to rmpeer
for _, ring := range rings {
require.NoError(t, merge(otherRing, ring))
}
common.Log.Debugf("%s: transferring from peer %s", otherPeername, peername)
otherRing.Transfer(peername, otherPeername)
// Remove peer from our state
peers = append(peers[:peerIndex], peers[peerIndex+1:]...)
rings = append(rings[:peerIndex], rings[peerIndex+1:]...)
theRanges = make(map[int][]address.Range)
// Transfer the space for this peer on another peer, but not this one
_, otherPeername, otherRing := randomPeer(peerIndex)
// We need to be in a ~converged ring to rmpeer
for _, ring := range rings {
wt.AssertSuccess(t, otherRing.Merge(*ring))
}
common.Debug.Printf("%s: transferring from peer %s", otherPeername, peername)
otherRing.Transfer(peername, peername)
// And now tell everyone about the transfer - rmpeer is
// not partition safe
for i, ring := range rings {
wt.AssertSuccess(t, ring.Merge(*otherRing))
require.NoError(t, merge(ring, otherRing))
theRanges[i] = ring.OwnedRanges()
}
}
@@ -669,13 +734,13 @@ func TestFuzzRingHard(t *testing.T) {
size := address.Subtract(rangeToSplit.End, rangeToSplit.Start)
ipInRange := address.Add(rangeToSplit.Start, address.Offset(rand.Intn(int(size))))
_, peerToGiveTo, _ := randomPeer(-1)
common.Debug.Printf("%s: Granting [%v, %v) to %s", ring.Peer, ipInRange, rangeToSplit.End, peerToGiveTo)
common.Log.Debugf("%s: Granting [%v, %v) to %s", ring.Peer, ipInRange, rangeToSplit.End, peerToGiveTo)
ring.GrantRangeToHost(ipInRange, rangeToSplit.End, peerToGiveTo)
// Now 'gossip' this to a random host (note, note could be same host as above)
otherIndex, _, otherRing := randomPeer(-1)
common.Debug.Printf("%s: 'Gossiping' to %s", ring.Peer, otherRing.Peer)
wt.AssertSuccess(t, otherRing.Merge(*ring))
common.Log.Debugf("%s: 'Gossiping' to %s", ring.Peer, otherRing.Peer)
require.NoError(t, merge(otherRing, ring))
theRanges[indexWithRanges] = ring.OwnedRanges()
theRanges[otherIndex] = otherRing.OwnedRanges()
@@ -693,8 +758,8 @@ func TestFuzzRingHard(t *testing.T) {
}
ring1 := ringsWithEntries[rand.Intn(len(ringsWithEntries))]
ring2index, _, ring2 := randomPeer(-1)
common.Debug.Printf("%s: 'Gossiping' to %s", ring1.Peer, ring2.Peer)
wt.AssertSuccess(t, ring2.Merge(*ring1))
common.Log.Debugf("%s: 'Gossiping' to %s", ring1.Peer, ring2.Peer)
require.NoError(t, merge(ring2, ring1))
theRanges[ring2index] = ring2.OwnedRanges()
}
@@ -710,6 +775,10 @@ func TestFuzzRingHard(t *testing.T) {
}
}
func (r *Ring) ClaimItAll() {
r.ClaimForPeers([]mesh.PeerName{r.Peer})
}
func (es entries) String() string {
var buffer bytes.Buffer
fmt.Fprintf(&buffer, "[")
+92 -60
View File
@@ -6,11 +6,9 @@ import (
"sort"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/ipam/address"
"github.com/weaveworks/weave/net/address"
)
type Addr address.Address
type Space struct {
// ours and free represent a set of addresses as a sorted
// sequences of ranges. Even elements give the inclusive
@@ -33,19 +31,51 @@ func (s *Space) Add(start address.Address, size address.Offset) {
// Clear removes all spaces from this space set. Used during node shutdown.
func (s *Space) Clear() {
s.free = s.free[:0]
s.ours = s.ours[:0]
s.free = s.free[:0]
}
func (s *Space) Allocate() (bool, address.Address) {
if len(s.free) == 0 {
return false, 0
} else {
res := s.free[0]
s.ours = add(s.ours, res, res+1)
s.free = subtract(s.free, res, res+1)
return true, res
// Walk down the free list calling f() on the in-range portions, until
// f() returns true or we run out of free space. Return true iff f() returned true
func (s *Space) walkFree(r address.Range, f func(address.Range) bool) bool {
if r.Start >= r.End { // degenerate case
return false
}
for i := 0; i < len(s.free); i += 2 {
chunk := address.Range{Start: s.free[i], End: s.free[i+1]}
if chunk.End <= r.Start { // this chunk comes before the range
continue
}
if chunk.Start >= r.End {
// all remaining free space is completely after range
break
}
// at this point we know chunk.End>chunk.Start &&
// chunk.End>r.Start && r.End>chunk.Start && r.End>r.Start
// therefore max(start, r.Start) < min(end, r.End)
// Restrict this block of free space to be in range
if chunk.Start < r.Start {
chunk.Start = r.Start
}
if chunk.End > r.End {
chunk.End = r.End
}
// at this point we know start<end
if f(chunk) {
return true
}
}
return false
}
func (s *Space) Allocate(r address.Range) (bool, address.Address) {
var result address.Address
return s.walkFree(r, func(chunk address.Range) bool {
result = chunk.Start
s.ours = add(s.ours, result, result+1)
s.free = subtract(s.free, result, result+1)
return true
}), result
}
func (s *Space) Claim(addr address.Address) error {
@@ -58,32 +88,31 @@ func (s *Space) Claim(addr address.Address) error {
return nil
}
func (s *Space) NumFreeAddresses() address.Offset {
res := address.Offset(0)
for i := 0; i < len(s.free); i += 2 {
res += address.Subtract(s.free[i+1], s.free[i])
func (s *Space) NumOwnedAddresses() address.Count {
res := address.Count(0)
for i := 0; i < len(s.ours); i += 2 {
res += address.Length(s.ours[i+1], s.ours[i])
}
return res
}
func (s *Space) NumFreeAddressesInRange(start, end address.Address) address.Offset {
res := address.Offset(0)
func (s *Space) NumFreeAddresses() address.Count {
res := address.Count(0)
for i := 0; i < len(s.free); i += 2 {
s, e := s.free[i], s.free[i+1]
if s < start {
s = start
}
if e > end {
e = end
}
if s >= e {
continue
}
res += address.Subtract(e, s)
res += address.Length(s.free[i+1], s.free[i])
}
return res
}
func (s *Space) NumFreeAddressesInRange(r address.Range) address.Count {
res := address.Count(0)
s.walkFree(r, func(chunk address.Range) bool {
res += chunk.Size()
return false
})
return res
}
func (s *Space) Free(addr address.Address) error {
if !contains(s.ours, addr) {
return fmt.Errorf("Address %v is not ours", addr)
@@ -97,35 +126,38 @@ func (s *Space) Free(addr address.Address) error {
return nil
}
func (s *Space) biggestFreeRange() (int, address.Offset) {
pos := -1
biggest := address.Offset(0)
for i := 0; i < len(s.free); i += 2 {
size := address.Subtract(s.free[i+1], s.free[i])
if size >= biggest {
pos = i
biggest = size
func (s *Space) biggestFreeRange(r address.Range) (biggest address.Range) {
biggestSize := address.Count(0)
s.walkFree(r, func(chunk address.Range) bool {
if size := chunk.Size(); size >= biggestSize {
chunk = chunk.BiggestCIDRRange()
if size = chunk.Size(); size >= biggestSize {
biggest = chunk
biggestSize = size
}
}
}
return pos, biggest
return false
})
return
}
func (s *Space) Donate() (address.Address, address.Offset, bool) {
if len(s.free) == 0 {
return 0, 0, false
func (s *Space) Donate(r address.Range) (address.Range, bool) {
biggest := s.biggestFreeRange(r)
if biggest.Size() == 0 {
return address.Range{}, false
}
pos, biggest := s.biggestFreeRange()
// Donate no more than half what we have available
if biggest.Size() > s.NumFreeAddressesInRange(r)/2 {
// Note size/2 rounds down, so the resulting donation size
// rounds up, and in particular can't be empty.
biggest.Start = address.Add(biggest.Start, address.Offset(biggest.Size()/2))
}
// Donate half of that biggest free range, rounding up so
// that the donation can't be empty
end := s.free[pos+1]
start := end - address.Address((biggest+1)/2)
s.ours = subtract(s.ours, start, end)
s.free = subtract(s.free, start, end)
return start, address.Subtract(end, start), true
s.ours = subtract(s.ours, biggest.Start, biggest.End)
s.free = subtract(s.free, biggest.Start, biggest.End)
return biggest, true
}
func firstGreater(a []address.Address, x address.Address) int {
@@ -152,25 +184,25 @@ func subtract(addrs []address.Address, start address.Address, end address.Addres
}
func addSub(addrs []address.Address, start address.Address, end address.Address, sense int) []address.Address {
start_pos := firstGreaterOrEq(addrs, start)
end_pos := firstGreater(addrs[start_pos:], end) + start_pos
startPos := firstGreaterOrEq(addrs, start)
endPos := firstGreater(addrs[startPos:], end) + startPos
// Boundaries up to start_pos are unaffected
res := make([]address.Address, start_pos, len(addrs)+2)
// Boundaries up to startPos are unaffected
res := make([]address.Address, startPos, len(addrs)+2)
copy(res, addrs)
// Include start and end as new boundaries if they lie
// outside/inside existing ranges (according to sense).
if start_pos&1 == sense {
if startPos&1 == sense {
res = append(res, start)
}
if end_pos&1 == sense {
if endPos&1 == sense {
res = append(res, end)
}
// Boundaries after end_pos are unaffected
return append(res, addrs[end_pos:]...)
// Boundaries after endPos are unaffected
return append(res, addrs[endPos:]...)
}
func (s *Space) String() string {
+121 -113
View File
@@ -1,10 +1,10 @@
package space
import (
"reflect"
"testing"
"github.com/weaveworks/weave/ipam/address"
"github.com/stretchr/testify/require"
"github.com/weaveworks/weave/net/address"
wt "github.com/weaveworks/weave/testing"
)
@@ -22,194 +22,202 @@ func ip(s string) address.Address {
func TestLowlevel(t *testing.T) {
a := []address.Address{}
a = add(a, 100, 200)
wt.AssertEquals(t, a, []address.Address{100, 200})
wt.AssertTrue(t, !contains(a, 99), "")
wt.AssertTrue(t, contains(a, 100), "")
wt.AssertTrue(t, contains(a, 199), "")
wt.AssertTrue(t, !contains(a, 200), "")
require.Equal(t, []address.Address{100, 200}, a)
require.True(t, !contains(a, 99), "")
require.True(t, contains(a, 100), "")
require.True(t, contains(a, 199), "")
require.True(t, !contains(a, 200), "")
a = add(a, 700, 800)
wt.AssertEquals(t, a, []address.Address{100, 200, 700, 800})
require.Equal(t, []address.Address{100, 200, 700, 800}, a)
a = add(a, 300, 400)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 400, 700, 800})
require.Equal(t, []address.Address{100, 200, 300, 400, 700, 800}, a)
a = add(a, 400, 500)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 500, 700, 800})
require.Equal(t, []address.Address{100, 200, 300, 500, 700, 800}, a)
a = add(a, 600, 700)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 500, 600, 800})
require.Equal(t, []address.Address{100, 200, 300, 500, 600, 800}, a)
a = add(a, 500, 600)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 800})
require.Equal(t, []address.Address{100, 200, 300, 800}, a)
a = subtract(a, 500, 600)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 500, 600, 800})
require.Equal(t, []address.Address{100, 200, 300, 500, 600, 800}, a)
a = subtract(a, 600, 700)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 500, 700, 800})
require.Equal(t, []address.Address{100, 200, 300, 500, 700, 800}, a)
a = subtract(a, 400, 500)
wt.AssertEquals(t, a, []address.Address{100, 200, 300, 400, 700, 800})
require.Equal(t, []address.Address{100, 200, 300, 400, 700, 800}, a)
a = subtract(a, 300, 400)
wt.AssertEquals(t, a, []address.Address{100, 200, 700, 800})
require.Equal(t, []address.Address{100, 200, 700, 800}, a)
a = subtract(a, 700, 800)
wt.AssertEquals(t, a, []address.Address{100, 200})
require.Equal(t, []address.Address{100, 200}, a)
a = subtract(a, 100, 200)
wt.AssertEquals(t, a, []address.Address{})
require.Equal(t, []address.Address{}, a)
s := New()
wt.AssertEquals(t, s.NumFreeAddresses(), address.Offset(0))
ok, got := s.Allocate()
wt.AssertFalse(t, ok, "allocate in empty space should fail")
require.Equal(t, address.Count(0), s.NumFreeAddresses())
ok, got := s.Allocate(address.NewRange(0, 1000))
require.False(t, ok, "allocate in empty space should fail")
s.Add(100, 100)
wt.AssertEquals(t, s.NumFreeAddresses(), address.Offset(100))
ok, got = s.Allocate()
wt.AssertTrue(t, ok && got == 100, "allocate")
wt.AssertEquals(t, s.NumFreeAddresses(), address.Offset(99))
wt.AssertNoErr(t, s.Claim(150))
wt.AssertEquals(t, s.NumFreeAddresses(), address.Offset(98))
wt.AssertNoErr(t, s.Free(100))
wt.AssertEquals(t, s.NumFreeAddresses(), address.Offset(99))
wt.AssertErrorInterface(t, s.Free(0), (*error)(nil), "free not allocated")
wt.AssertErrorInterface(t, s.Free(100), (*error)(nil), "double free")
require.Equal(t, address.Count(100), s.NumFreeAddresses())
ok, got = s.Allocate(address.NewRange(0, 1000))
require.True(t, ok && got == 100, "allocate")
require.Equal(t, address.Count(99), s.NumFreeAddresses())
require.NoError(t, s.Claim(150))
require.Equal(t, address.Count(98), s.NumFreeAddresses())
require.NoError(t, s.Free(100))
require.Equal(t, address.Count(99), s.NumFreeAddresses())
wt.AssertErrorInterface(t, (*error)(nil), s.Free(0), "free not allocated")
wt.AssertErrorInterface(t, (*error)(nil), s.Free(100), "double free")
start, size, ok := s.Donate()
wt.AssertTrue(t, ok && start == 125 && size == 25, "donate")
r, ok := s.Donate(address.NewRange(0, 1000))
require.Equal(t, address.NewRange(0xa0, 0x20), r, "donate")
// test Donate when addresses are scarce
s = New()
start, size, ok = s.Donate()
wt.AssertTrue(t, !ok, "donate on empty space should fail")
r, ok = s.Donate(address.NewRange(0, 1000))
require.True(t, !ok, "donate on empty space should fail")
s.Add(0, 3)
wt.AssertNoErr(t, s.Claim(0))
wt.AssertNoErr(t, s.Claim(2))
start, size, ok = s.Donate()
wt.AssertTrue(t, ok && start == 1 && size == 1, "donate")
start, size, ok = s.Donate()
wt.AssertTrue(t, !ok, "donate should fail")
require.NoError(t, s.Claim(0))
require.NoError(t, s.Claim(2))
r, ok = s.Donate(address.NewRange(0, 1000))
require.Equal(t, address.NewRange(1, 1), r, "donate")
r, ok = s.Donate(address.NewRange(0, 1000))
require.True(t, !ok, "donate should fail")
}
func TestSpaceAllocate(t *testing.T) {
const (
testAddr1 = "10.0.3.4"
testAddr2 = "10.0.3.5"
testAddrx = "10.0.3.19"
testAddry = "10.0.9.19"
containerID = "deadbeef"
size = 20
)
var (
start = ip(testAddr1)
)
space1 := makeSpace(ip(testAddr1), 20)
wt.AssertEquals(t, space1.NumFreeAddresses(), address.Offset(20))
space1 := makeSpace(start, size)
require.Equal(t, address.Count(20), space1.NumFreeAddresses())
require.Equal(t, address.Count(0), space1.NumOwnedAddresses())
space1.assertInvariants()
_, addr1 := space1.Allocate()
wt.AssertEqualString(t, addr1.String(), testAddr1, "address")
wt.AssertEquals(t, space1.NumFreeAddresses(), address.Offset(19))
_, addr1 := space1.Allocate(address.NewRange(start, size))
require.Equal(t, testAddr1, addr1.String(), "address")
require.Equal(t, address.Count(19), space1.NumFreeAddresses())
require.Equal(t, address.Count(1), space1.NumOwnedAddresses())
space1.assertInvariants()
_, addr2 := space1.Allocate()
wt.AssertFalse(t, addr2.String() == testAddr1, "address")
wt.AssertEquals(t, space1.NumFreeAddresses(), address.Offset(18))
wt.AssertEquals(t, space1.NumFreeAddressesInRange(ip(testAddr1), ip(testAddrx)), address.Offset(13))
wt.AssertEquals(t, space1.NumFreeAddressesInRange(ip(testAddr1), ip(testAddry)), address.Offset(18))
_, addr2 := space1.Allocate(address.NewRange(start, size))
require.False(t, addr2.String() == testAddr1, "address")
require.Equal(t, address.Count(18), space1.NumFreeAddresses())
require.Equal(t, address.Count(2), space1.NumOwnedAddresses())
require.Equal(t, address.Count(13), space1.NumFreeAddressesInRange(address.Range{Start: ip(testAddr1), End: ip(testAddrx)}))
require.Equal(t, address.Count(18), space1.NumFreeAddressesInRange(address.Range{Start: ip(testAddr1), End: ip(testAddry)}))
space1.assertInvariants()
space1.Free(addr2)
space1.assertInvariants()
wt.AssertErrorInterface(t, space1.Free(addr2), (*error)(nil), "double free")
wt.AssertErrorInterface(t, space1.Free(ip(testAddrx)), (*error)(nil), "address not allocated")
wt.AssertErrorInterface(t, space1.Free(ip(testAddry)), (*error)(nil), "wrong out of range")
wt.AssertErrorInterface(t, (*error)(nil), space1.Free(addr2), "double free")
wt.AssertErrorInterface(t, (*error)(nil), space1.Free(ip(testAddrx)), "address not allocated")
wt.AssertErrorInterface(t, (*error)(nil), space1.Free(ip(testAddry)), "wrong out of range")
space1.assertInvariants()
}
func TestSpaceFree(t *testing.T) {
const (
testAddr1 = "10.0.3.4"
testAddr1 = "10.0.3.16"
testAddrx = "10.0.3.19"
testAddry = "10.0.9.19"
containerID = "deadbeef"
size = 16
)
space := makeSpace(ip(testAddr1), 20)
entireRange := address.NewRange(ip(testAddr1), size)
space := makeSpace(ip(testAddr1), size)
// Check we are prepared to give up the entire space
pos, size := space.biggestFreeRange()
wt.AssertTrue(t, space.free[pos] == ip(testAddr1) && size == 20, "Wrong space")
r := space.biggestFreeRange(entireRange)
require.Equal(t, address.NewRange(ip(testAddr1), size), r, "Wrong space")
for i := 0; i < 20; i++ {
ok, _ := space.Allocate()
wt.AssertTrue(t, ok, "Failed to get address")
for i := 0; i < size; i++ {
ok, _ := space.Allocate(entireRange)
require.True(t, ok, "Failed to get address")
}
// Check we are full
ok, _ := space.Allocate()
wt.AssertTrue(t, !ok, "Should have failed to get address")
_, size, ok = space.Donate()
wt.AssertTrue(t, size == 0, "Wrong space")
ok, _ := space.Allocate(entireRange)
require.True(t, !ok, "Should have failed to get address")
r, _ = space.Donate(entireRange)
require.True(t, r.Size() == 0, "Wrong space")
// Free in the middle
wt.AssertSuccess(t, space.Free(ip("10.0.3.13")))
pos, size = space.biggestFreeRange()
wt.AssertTrue(t, space.free[pos] == ip("10.0.3.13") && size == 1, "Wrong space")
require.NoError(t, space.Free(ip("10.0.3.23")))
r = space.biggestFreeRange(entireRange)
require.True(t, r.Start == ip("10.0.3.23") && r.Size() == 1, "Wrong space")
// Free one at the end
wt.AssertSuccess(t, space.Free(ip("10.0.3.23")))
pos, size = space.biggestFreeRange()
wt.AssertTrue(t, space.free[pos] == ip("10.0.3.23") && size == 1, "Wrong space")
require.NoError(t, space.Free(ip("10.0.3.31")))
r = space.biggestFreeRange(entireRange)
require.True(t, r.Start == ip("10.0.3.31") && r.Size() == 1, "Wrong space")
// Now free a few at the end
wt.AssertSuccess(t, space.Free(ip("10.0.3.22")))
wt.AssertSuccess(t, space.Free(ip("10.0.3.21")))
require.NoError(t, space.Free(ip("10.0.3.30")))
require.NoError(t, space.Free(ip("10.0.3.29")))
wt.AssertEquals(t, space.NumFreeAddresses(), address.Offset(4))
require.Equal(t, address.Count(4), space.NumFreeAddresses())
// Now get the biggest free space; should be 3.21
pos, size = space.biggestFreeRange()
wt.AssertTrue(t, space.free[pos] == ip("10.0.3.21") && size == 3, "Wrong space")
// Now get the biggest free space; should be 3.30
r = space.biggestFreeRange(entireRange)
require.Equal(t, address.NewRange(ip("10.0.3.30"), 2), r, "Wrong space")
// Now free a few in the middle
wt.AssertSuccess(t, space.Free(ip("10.0.3.12")))
wt.AssertSuccess(t, space.Free(ip("10.0.3.11")))
wt.AssertSuccess(t, space.Free(ip("10.0.3.10")))
require.NoError(t, space.Free(ip("10.0.3.24")))
require.NoError(t, space.Free(ip("10.0.3.22")))
require.NoError(t, space.Free(ip("10.0.3.21")))
wt.AssertEquals(t, space.NumFreeAddresses(), address.Offset(7))
require.Equal(t, address.Count(7), space.NumFreeAddresses())
// Now get the biggest free space; should be 3.21
pos, size = space.biggestFreeRange()
wt.AssertTrue(t, space.free[pos] == ip("10.0.3.10") && size == 4, "Wrong space")
// Now get the biggest free space; should be 3.30
r = space.biggestFreeRange(entireRange)
require.Equal(t, address.NewRange(ip("10.0.3.30"), 2), r, "Wrong space")
wt.AssertEquals(t, space.OwnedRanges(), []address.Range{address.Range{Start: ip("10.0.3.4"), End: ip("10.0.3.24")}})
}
func (s1 *Space) Equal(s2 *Space) bool {
return reflect.DeepEqual(s1.ours, s2.ours) && reflect.DeepEqual(s1.free, s2.free)
require.Equal(t, []address.Range{{Start: ip("10.0.3.16"), End: ip("10.0.3.32")}}, space.OwnedRanges())
}
func TestDonateSimple(t *testing.T) {
const (
testAddr1 = "10.0.1.0"
testAddr2 = "10.0.1.32"
size = 64
)
var (
ipAddr1 = ip(testAddr1)
)
ps1 := makeSpace(ipAddr1, 48)
ps1 := makeSpace(ipAddr1, size)
// Empty space set should split in two and give me the second half
start, numGivenUp, ok := ps1.Donate()
wt.AssertTrue(t, ok, "Donate result")
wt.AssertEqualString(t, start.String(), "10.0.1.24", "Invalid start")
wt.AssertEquals(t, numGivenUp, address.Offset(24))
wt.AssertEquals(t, ps1.NumFreeAddresses(), address.Offset(24))
r, ok := ps1.Donate(address.NewRange(ip(testAddr1), size))
numGivenUp := r.Size()
require.True(t, ok, "Donate result")
require.Equal(t, "10.0.1.32", r.Start.String(), "Invalid start")
require.Equal(t, address.Count(size/2), numGivenUp)
require.Equal(t, address.Count(size/2), ps1.NumFreeAddresses())
// Now check we can give the rest up.
count := 0 // count to avoid infinite loop
for ; count < 1000; count++ {
_, size, ok := ps1.Donate()
r, ok := ps1.Donate(address.NewRange(ip(testAddr1), size))
if !ok {
break
}
numGivenUp += size
numGivenUp += r.Size()
}
wt.AssertEquals(t, ps1.NumFreeAddresses(), address.Offset(0))
wt.AssertEquals(t, numGivenUp, address.Offset(48))
require.Equal(t, address.Count(0), ps1.NumFreeAddresses())
require.Equal(t, address.Count(size), numGivenUp)
}
func TestDonateHard(t *testing.T) {
@@ -222,28 +230,28 @@ func TestDonateHard(t *testing.T) {
// Fill a fresh space
spaceset := makeSpace(start, size)
for i := address.Offset(0); i < size; i++ {
ok, _ := spaceset.Allocate()
wt.AssertTrue(t, ok, "Failed to get IP!")
ok, _ := spaceset.Allocate(address.NewRange(start, size))
require.True(t, ok, "Failed to get IP!")
}
wt.AssertEquals(t, spaceset.NumFreeAddresses(), address.Offset(0))
require.Equal(t, address.Count(0), spaceset.NumFreeAddresses())
// Now free all but the last address
// this will force us to split the free list
for i := address.Offset(0); i < size-1; i++ {
wt.AssertSuccess(t, spaceset.Free(address.Add(start, i)))
require.NoError(t, spaceset.Free(address.Add(start, i)))
}
// Now split
newRange, numGivenUp, ok := spaceset.Donate()
wt.AssertTrue(t, ok, "GiveUpSpace result")
wt.AssertEquals(t, newRange, ip("10.0.1.23"))
wt.AssertEquals(t, numGivenUp, address.Offset(24))
wt.AssertEquals(t, spaceset.NumFreeAddresses(), address.Offset(23))
newRange, ok := spaceset.Donate(address.NewRange(start, size))
require.True(t, ok, "GiveUpSpace result")
require.Equal(t, address.NewRange(ip("10.0.1.16"), 16), newRange, "Wrong space")
require.Equal(t, address.Count(31), spaceset.NumFreeAddresses())
//Space set should now have 2 spaces
expected := New()
expected.Add(start, 23)
expected.ours = add(nil, ip("10.0.1.47"), ip("10.0.1.48"))
wt.AssertEquals(t, spaceset, expected)
//Space set should now have 3 spaces
expected := &Space{
ours: add(nil, ip("10.0.1.47"), ip("10.0.1.48")),
free: add(add(nil, ip("10.0.1.0"), ip("10.0.1.16")), ip("10.0.1.32"), ip("10.0.1.47")),
}
require.Equal(t, expected, spaceset)
}
+103
View File
@@ -0,0 +1,103 @@
package ipam
import (
"fmt"
"github.com/weaveworks/weave/ipam/paxos"
"github.com/weaveworks/weave/net/address"
)
type Status struct {
Paxos *paxos.Status
Range string
RangeNumIPs int
ActiveIPs int
DefaultSubnet string
Entries []EntryStatus
PendingClaims []ClaimStatus
PendingAllocates []string
}
type EntryStatus struct {
Token string
Size uint32
Peer string
Nickname string
IsKnownPeer bool
Version uint32
}
type ClaimStatus struct {
Ident string
CIDR address.CIDR
}
func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
if allocator == nil {
return nil
}
var paxosStatus *paxos.Status
if allocator.awaitingConsensus && allocator.paxos != nil {
if allocator.paxos.IsElector() {
if node, ok := allocator.paxos.(*paxos.Node); ok {
paxosStatus = paxos.NewStatus(node)
}
} else {
paxosStatus = &paxos.Status{Elector: false}
}
}
resultChan := make(chan *Status)
allocator.actionChan <- func() {
resultChan <- &Status{
paxosStatus,
allocator.universe.String(),
int(allocator.universe.Size()),
int(allocator.space.NumOwnedAddresses()),
defaultSubnet.String(),
newEntryStatusSlice(allocator),
newClaimStatusSlice(allocator),
newAllocateIdentSlice(allocator)}
}
return <-resultChan
}
func newEntryStatusSlice(allocator *Allocator) []EntryStatus {
var slice []EntryStatus
if allocator.ring.Empty() {
return slice
}
for _, r := range allocator.ring.AllRangeInfo() {
slice = append(slice, EntryStatus{
Token: r.Start.String(),
Size: uint32(r.Size()),
Peer: r.Peer.String(),
Nickname: allocator.nicknames[r.Peer],
IsKnownPeer: allocator.isKnownPeer(r.Peer),
Version: r.Version,
})
}
return slice
}
func newClaimStatusSlice(allocator *Allocator) []ClaimStatus {
var slice []ClaimStatus
for _, op := range allocator.pendingClaims {
claim := op.(*claim)
slice = append(slice, ClaimStatus{claim.ident, claim.cidr})
}
return slice
}
func newAllocateIdentSlice(allocator *Allocator) []string {
var slice []string
for _, op := range allocator.pendingAllocates {
allocate := op.(*allocate)
slice = append(slice, fmt.Sprintf("%s %s", allocate.ident, allocate.r.String()))
}
return slice
}
+97 -136
View File
@@ -3,16 +3,19 @@ package ipam
import (
"fmt"
"math/rand"
"sync"
"testing"
"time"
"github.com/weaveworks/weave/common"
"github.com/weaveworks/weave/router"
wt "github.com/weaveworks/weave/testing"
"github.com/weaveworks/mesh"
"github.com/stretchr/testify/require"
"github.com/weaveworks/weave/net/address"
"github.com/weaveworks/weave/testing/gossip"
)
type mockMessage struct {
dst router.PeerName
dst mesh.PeerName
msgType byte
buf []byte
}
@@ -30,12 +33,15 @@ func toStringArray(messages []mockMessage) []string {
}
type mockGossipComms struct {
t *testing.T
sync.RWMutex
*testing.T
name string
messages []mockMessage
}
func (m *mockGossipComms) String() string {
m.RLock()
defer m.RUnlock()
return fmt.Sprintf("[mockGossipComms %s]", m.name)
}
@@ -43,19 +49,20 @@ func (m *mockGossipComms) String() string {
// that the contents of messages are never re-ordered. Which, for instance,
// requires they are not based off iterating through a map.
func (m *mockGossipComms) GossipBroadcast(update router.GossipData) error {
func (m *mockGossipComms) GossipBroadcast(update mesh.GossipData) {
m.Lock()
defer m.Unlock()
buf := []byte{}
if len(m.messages) == 0 {
m.Fatalf("%s: Gossip broadcast message unexpected: \n%x", m.name, buf)
} else if msg := m.messages[0]; msg.dst != router.UnknownPeerName {
m.Fatalf("%s: Expected Gossip message to %s but got broadcast", m.name, msg.dst)
require.FailNow(m, fmt.Sprintf("%s: Gossip broadcast message unexpected: \n%x", m.name, buf))
} else if msg := m.messages[0]; msg.dst != mesh.UnknownPeerName {
require.FailNow(m, fmt.Sprintf("%s: Expected Gossip message to %s but got broadcast", m.name, msg.dst))
} else if msg.buf != nil && !equalByteBuffer(msg.buf, buf) {
m.Fatalf("%s: Gossip message not sent as expected: \nwant: %x\ngot : %x", m.name, msg.buf, buf)
require.FailNow(m, fmt.Sprintf("%s: Gossip message not sent as expected: \nwant: %x\ngot : %x", m.name, msg.buf, buf))
} else {
// Swallow this message
m.messages = m.messages[1:]
}
return nil
}
func equalByteBuffer(a, b []byte) bool {
@@ -70,22 +77,19 @@ func equalByteBuffer(a, b []byte) bool {
return true
}
func (m *mockGossipComms) Fatalf(format string, args ...interface{}) {
// this sometimes hangs: wt.Fatalf(m.t, args...)
panic(fmt.Sprintf(format, args...))
}
func (m *mockGossipComms) GossipUnicast(dstPeerName router.PeerName, buf []byte) error {
func (m *mockGossipComms) GossipUnicast(dstPeerName mesh.PeerName, buf []byte) error {
m.Lock()
defer m.Unlock()
if len(m.messages) == 0 {
m.Fatalf("%s: Gossip message to %s unexpected: \n%s", m.name, dstPeerName, buf)
} else if msg := m.messages[0]; msg.dst == router.UnknownPeerName {
m.Fatalf("%s: Expected Gossip broadcast message but got dest %s", m.name, dstPeerName)
require.FailNow(m, fmt.Sprintf("%s: Gossip message to %s unexpected: \n%s", m.name, dstPeerName, buf))
} else if msg := m.messages[0]; msg.dst == mesh.UnknownPeerName {
require.FailNow(m, fmt.Sprintf("%s: Expected Gossip broadcast message but got dest %s", m.name, dstPeerName))
} else if msg.dst != dstPeerName {
m.Fatalf("%s: Expected Gossip message to %s but got dest %s", m.name, msg.dst, dstPeerName)
require.FailNow(m, fmt.Sprintf("%s: Expected Gossip message to %s but got dest %s", m.name, msg.dst, dstPeerName))
} else if buf[0] != msg.msgType {
m.Fatalf("%s: Expected Gossip message of type %d but got type %d", m.name, msg.msgType, buf[0])
require.FailNow(m, fmt.Sprintf("%s: Expected Gossip message of type %d but got type %d", m.name, msg.msgType, buf[0]))
} else if msg.buf != nil && !equalByteBuffer(msg.buf, buf[1:]) {
m.Fatalf("%s: Gossip message not sent as expected: \nwant: %x\ngot : %x", m.name, msg.buf, buf[1:])
require.FailNow(m, fmt.Sprintf("%s: Gossip message not sent as expected: \nwant: %x\ngot : %x", m.name, msg.buf, buf[1:]))
} else {
// Swallow this message
m.messages = m.messages[1:]
@@ -95,49 +99,69 @@ func (m *mockGossipComms) GossipUnicast(dstPeerName router.PeerName, buf []byte)
func ExpectMessage(alloc *Allocator, dst string, msgType byte, buf []byte) {
m := alloc.gossip.(*mockGossipComms)
dstPeerName, _ := router.PeerNameFromString(dst)
dstPeerName, _ := mesh.PeerNameFromString(dst)
m.Lock()
m.messages = append(m.messages, mockMessage{dstPeerName, msgType, buf})
m.Unlock()
}
func ExpectBroadcastMessage(alloc *Allocator, buf []byte) {
m := alloc.gossip.(*mockGossipComms)
m.messages = append(m.messages, mockMessage{router.UnknownPeerName, 0, buf})
m.Lock()
m.messages = append(m.messages, mockMessage{mesh.UnknownPeerName, 0, buf})
m.Unlock()
}
func CheckAllExpectedMessagesSent(allocs ...*Allocator) {
for _, alloc := range allocs {
m := alloc.gossip.(*mockGossipComms)
m.RLock()
if len(m.messages) > 0 {
wt.Fatalf(m.t, "%s: Gossip message(s) not sent as expected: \n%x", m.name, m.messages)
require.FailNow(m, fmt.Sprintf("%s: Gossip message(s) not sent as expected: \n%x", m.name, m.messages))
}
m.RUnlock()
}
}
func makeAllocator(name string, cidr string, quorum uint) *Allocator {
peername, err := router.PeerNameFromString(name)
type mockDB struct{}
func (d *mockDB) Load(_ string, _ interface{}) (bool, error) { return false, nil }
func (d *mockDB) Save(_ string, _ interface{}) error { return nil }
func makeAllocator(name string, cidrStr string, quorum uint, preClaims ...PreClaim) (*Allocator, address.CIDR) {
peername, err := mesh.PeerNameFromString(name)
if err != nil {
panic(err)
}
alloc, err := NewAllocator(peername, router.PeerUID(rand.Int63()),
"nick-"+name, cidr, quorum)
cidr, err := address.ParseCIDR(cidrStr)
if err != nil {
panic(err)
}
return alloc
return NewAllocator(Config{
OurName: peername,
OurUID: mesh.PeerUID(rand.Int63()),
OurNickname: "nick-" + name,
Universe: cidr,
IsObserver: quorum == 0,
PreClaims: preClaims,
Quorum: func() uint { return quorum },
Db: new(mockDB),
IsKnownPeer: func(mesh.PeerName) bool { return true },
}), cidr
}
func makeAllocatorWithMockGossip(t *testing.T, name string, universeCIDR string, quorum uint) *Allocator {
alloc := makeAllocator(name, universeCIDR, quorum)
gossip := &mockGossipComms{t: t, name: name}
func makeAllocatorWithMockGossip(t *testing.T, name string, universeCIDR string, quorum uint) (*Allocator, address.CIDR) {
alloc, subnet := makeAllocator(name, universeCIDR, quorum)
gossip := &mockGossipComms{T: t, name: name}
alloc.SetInterfaces(gossip)
alloc.Start()
return alloc
return alloc, subnet
}
func (alloc *Allocator) claimRingForTesting(allocs ...*Allocator) {
peers := []router.PeerName{alloc.ourName}
peers := []mesh.PeerName{alloc.ourName}
for _, alloc2 := range allocs {
peers = append(peers, alloc2.ourName)
}
@@ -145,6 +169,22 @@ func (alloc *Allocator) claimRingForTesting(allocs ...*Allocator) {
alloc.space.AddRanges(alloc.ring.OwnedRanges())
}
func (alloc *Allocator) NumFreeAddresses(r address.Range) address.Count {
resultChan := make(chan address.Count)
alloc.actionChan <- func() {
resultChan <- alloc.space.NumFreeAddressesInRange(r)
}
return <-resultChan
}
func (alloc *Allocator) OwnedRanges() (result []address.Range) {
resultChan := make(chan []address.Range)
alloc.actionChan <- func() {
resultChan <- alloc.ring.OwnedRanges()
}
return <-resultChan
}
// Check whether or not something was sent on a channel
func AssertSent(t *testing.T, ch <-chan bool) {
timeout := time.After(10 * time.Second)
@@ -152,14 +192,14 @@ func AssertSent(t *testing.T, ch <-chan bool) {
case <-ch:
// This case is ok
case <-timeout:
wt.Fatalf(t, "Nothing sent on channel")
require.FailNow(t, "Nothing sent on channel")
}
}
func AssertNothingSent(t *testing.T, ch <-chan bool) {
select {
case val := <-ch:
wt.Fatalf(t, "Unexpected value on channel: %t", val)
require.FailNow(t, fmt.Sprintf("Unexpected value on channel: %v", val))
default:
// no message received
}
@@ -168,118 +208,39 @@ func AssertNothingSent(t *testing.T, ch <-chan bool) {
func AssertNothingSentErr(t *testing.T, ch <-chan error) {
select {
case val := <-ch:
wt.Fatalf(t, "Unexpected value on channel: %t", val)
require.FailNow(t, fmt.Sprintf("Unexpected value on channel: %v", val))
default:
// no message received
}
}
// Router to convey gossip from one gossiper to another, for testing
type gossipMessage struct {
isUnicast bool
sender *router.PeerName
buf []byte
exitChan chan bool
}
type TestGossipRouter struct {
gossipChans map[router.PeerName]chan gossipMessage
loss float32 // 0.0 means no loss
}
func (grouter *TestGossipRouter) GossipBroadcast(update router.GossipData) error {
for _, gossipChan := range grouter.gossipChans {
select {
case gossipChan <- gossipMessage{buf: update.(*ipamGossipData).alloc.encode()}:
default: // drop the message if we cannot send it
}
}
return nil
}
func (grouter *TestGossipRouter) removePeer(peer router.PeerName) {
gossipChan := grouter.gossipChans[peer]
resultChan := make(chan bool)
gossipChan <- gossipMessage{exitChan: resultChan}
<-resultChan
delete(grouter.gossipChans, peer)
}
type TestGossipRouterClient struct {
router *TestGossipRouter
sender router.PeerName
}
func (grouter *TestGossipRouter) connect(sender router.PeerName, gossiper router.Gossiper) router.Gossip {
gossipChan := make(chan gossipMessage, 100)
go func() {
gossipTimer := time.Tick(10 * time.Second)
for {
select {
case message := <-gossipChan:
if message.exitChan != nil {
message.exitChan <- true
return
}
if rand.Float32() > (1.0 - grouter.loss) {
continue
}
if message.isUnicast {
err := gossiper.OnGossipUnicast(*message.sender, message.buf)
if err != nil {
panic(fmt.Sprintf("Error doing gossip unicast to %s: %s", sender, err))
}
} else {
_, err := gossiper.OnGossipBroadcast(message.buf)
if err != nil {
panic(fmt.Sprintf("Error doing gossip broadcast to %s: %s", sender, err))
}
}
case <-gossipTimer:
grouter.GossipBroadcast(gossiper.Gossip())
}
}
}()
grouter.gossipChans[sender] = gossipChan
return TestGossipRouterClient{grouter, sender}
}
func (client TestGossipRouterClient) GossipUnicast(dstPeerName router.PeerName, buf []byte) error {
select {
case client.router.gossipChans[dstPeerName] <- gossipMessage{isUnicast: true, sender: &client.sender, buf: buf}:
default: // drop the message if we cannot send it
common.Error.Printf("Dropping message")
}
return nil
}
func (client TestGossipRouterClient) GossipBroadcast(update router.GossipData) error {
return client.router.GossipBroadcast(update)
}
func makeNetworkOfAllocators(size int, cidr string) ([]*Allocator, TestGossipRouter) {
gossipRouter := TestGossipRouter{make(map[router.PeerName]chan gossipMessage), 0.0}
func makeNetworkOfAllocators(size int, cidr string, preClaims ...[]PreClaim) ([]*Allocator, *gossip.TestRouter, address.CIDR) {
gossipRouter := gossip.NewTestRouter(0.0)
allocs := make([]*Allocator, size)
var subnet address.CIDR
for i := 0; i < size; i++ {
alloc := makeAllocator(fmt.Sprintf("%02d:00:00:02:00:00", i),
cidr, uint(size/2+1))
alloc.SetInterfaces(gossipRouter.connect(alloc.ourName, alloc))
var alloc *Allocator
preClaim := []PreClaim{}
if i < len(preClaims) {
preClaim = preClaims[i]
}
alloc, subnet = makeAllocator(fmt.Sprintf("%02d:00:00:02:00:00", i),
cidr, uint(size/2+1), preClaim...)
alloc.SetInterfaces(gossipRouter.Connect(alloc.ourName, alloc))
alloc.Start()
allocs[i] = alloc
}
gossipRouter.GossipBroadcast(allocs[size-1].Gossip())
time.Sleep(1000 * time.Millisecond)
return allocs, gossipRouter
allocs[size-1].gossip.GossipBroadcast(allocs[size-1].Gossip())
gossipRouter.Flush()
return allocs, gossipRouter, subnet
}
func stopNetworkOfAllocators(allocs []*Allocator) {
func stopNetworkOfAllocators(allocs []*Allocator, gossipRouter *gossip.TestRouter) {
// NB: We must stop the router first since ipam gossip makes
// synchronous calls into the allocator.
gossipRouter.Stop()
for _, alloc := range allocs {
alloc.Stop()
}
+285
View File
@@ -0,0 +1,285 @@
package tracker
// The AWSVPC tracker tracks the IPAM ring changes and accordingly updates
// the AWS VPC route table and, if the announced change is local
// (denoted by local=true) to the host, the host route table.
//
// During the initialization, the tracker detects AWS VPC route table id which
// is associated with the host's subnet on the AWS network. If such a table does
// not exist, the default VPC route table is used.
//
// When a host A donates a range to a host B, the necessary route table
// updates (removal) happen on the host A first, and afterwards on
// the host B (installation).
//
// NB: there is a hard limit for 50 routes within any VPC route table
// (practically, it is 48, because one route is used by the AWS Internet GW and
// one by the AWS host subnet), therefore it is suggested to avoid
// an excessive fragmentation within the IPAM ring which might happen due to
// the claim operations or uneven distribution of containers across the hosts.
import (
"fmt"
"net"
"syscall"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/vishvananda/netlink"
"github.com/weaveworks/weave/common"
wnet "github.com/weaveworks/weave/net"
"github.com/weaveworks/weave/net/address"
)
type AWSVPCTracker struct {
ec2 *ec2.EC2
instanceID string // EC2 Instance ID
routeTableID string // VPC Route Table ID
linkIndex int // The weave bridge link index
}
// NewAWSVPCTracker creates and initialises AWS VPC based tracker.
func NewAWSVPCTracker() (*AWSVPCTracker, error) {
var (
err error
session = session.New()
t = &AWSVPCTracker{}
)
// Detect region and instance id
meta := ec2metadata.New(session)
t.instanceID, err = meta.GetMetadata("instance-id")
if err != nil {
return nil, fmt.Errorf("cannot detect instance-id: %s", err)
}
region, err := meta.Region()
if err != nil {
return nil, fmt.Errorf("cannot detect region: %s", err)
}
t.ec2 = ec2.New(session, aws.NewConfig().WithRegion(region))
routeTableID, err := t.detectRouteTableID()
if err != nil {
return nil, err
}
t.routeTableID = *routeTableID
// Detect Weave bridge link index
link, err := netlink.LinkByName(wnet.WeaveBridgeName)
if err != nil {
return nil, fmt.Errorf("cannot find \"%s\" interface: %s", wnet.WeaveBridgeName, err)
}
t.linkIndex = link.Attrs().Index
t.infof("AWSVPC has been initialized on %s instance for %s route table at %s region",
t.instanceID, t.routeTableID, region)
return t, nil
}
// HandleUpdate method updates the AWS VPC and the host route tables.
func (t *AWSVPCTracker) HandleUpdate(prevRanges, currRanges []address.Range, local bool) error {
t.debugf("replacing %q by %q; local(%t)", prevRanges, currRanges, local)
prev, curr := removeCommon(address.NewCIDRs(merge(prevRanges)), address.NewCIDRs(merge(currRanges)))
// It might make sense to do the removal first and then add entries
// because of the 50 routes limit. However, in such case a container might
// not be reachable for a short period of time which is not a desired behavior.
// Add new entries
for _, cidr := range curr {
cidrStr := cidr.String()
t.debugf("adding route %s to %s", cidrStr, t.instanceID)
if _, err := t.createVPCRoute(cidrStr); err != nil {
return fmt.Errorf("createVPCRoutes failed: %s", err)
}
if local {
if err := t.createHostRoute(cidrStr); err != nil {
if errno, ok := err.(syscall.Errno); !(ok && errno == syscall.EEXIST) {
return fmt.Errorf("createHostRoute failed: %s", err)
}
}
}
}
// Remove obsolete entries
for _, cidr := range prev {
cidrStr := cidr.String()
t.debugf("removing %s route", cidrStr)
if _, err := t.deleteVPCRoute(cidrStr); err != nil {
return fmt.Errorf("deleteVPCRoute failed: %s", err)
}
if local {
if err := t.deleteHostRoute(cidrStr); err != nil {
return fmt.Errorf("deleteHostRoute failed: %s", err)
}
}
}
return nil
}
func (t *AWSVPCTracker) createVPCRoute(cidr string) (*ec2.CreateRouteOutput, error) {
route := &ec2.CreateRouteInput{
RouteTableId: &t.routeTableID,
InstanceId: &t.instanceID,
DestinationCidrBlock: &cidr,
}
return t.ec2.CreateRoute(route)
}
func (t *AWSVPCTracker) createHostRoute(cidr string) error {
dst, err := parseCIDR(cidr)
if err != nil {
return err
}
route := &netlink.Route{
LinkIndex: t.linkIndex,
Dst: dst,
Scope: netlink.SCOPE_LINK,
}
return netlink.RouteAdd(route)
}
func (t *AWSVPCTracker) deleteVPCRoute(cidr string) (*ec2.DeleteRouteOutput, error) {
route := &ec2.DeleteRouteInput{
RouteTableId: &t.routeTableID,
DestinationCidrBlock: &cidr,
}
return t.ec2.DeleteRoute(route)
}
func (t *AWSVPCTracker) deleteHostRoute(cidr string) error {
dst, err := parseCIDR(cidr)
if err != nil {
return err
}
route := &netlink.Route{
LinkIndex: t.linkIndex,
Dst: dst,
Scope: netlink.SCOPE_LINK,
}
return netlink.RouteDel(route)
}
// detectRouteTableID detects AWS VPC Route Table ID of the given tracker instance.
func (t *AWSVPCTracker) detectRouteTableID() (*string, error) {
instancesParams := &ec2.DescribeInstancesInput{
InstanceIds: []*string{aws.String(t.instanceID)},
}
instancesResp, err := t.ec2.DescribeInstances(instancesParams)
if err != nil {
return nil, fmt.Errorf("DescribeInstances failed: %s", err)
}
if len(instancesResp.Reservations) == 0 ||
len(instancesResp.Reservations[0].Instances) == 0 {
return nil, fmt.Errorf("cannot find %s instance within reservations", t.instanceID)
}
vpcID := instancesResp.Reservations[0].Instances[0].VpcId
subnetID := instancesResp.Reservations[0].Instances[0].SubnetId
// First try to find a routing table associated with the subnet of the instance
tablesParams := &ec2.DescribeRouteTablesInput{
Filters: []*ec2.Filter{
{
Name: aws.String("association.subnet-id"),
Values: []*string{subnetID},
},
},
}
tablesResp, err := t.ec2.DescribeRouteTables(tablesParams)
if err != nil {
return nil, fmt.Errorf("DescribeRouteTables failed: %s", err)
}
if len(tablesResp.RouteTables) != 0 {
return tablesResp.RouteTables[0].RouteTableId, nil
}
// Fallback to the default routing table
tablesParams = &ec2.DescribeRouteTablesInput{
Filters: []*ec2.Filter{
{
Name: aws.String("association.main"),
Values: []*string{aws.String("true")},
},
{
Name: aws.String("vpc-id"),
Values: []*string{vpcID},
},
},
}
tablesResp, err = t.ec2.DescribeRouteTables(tablesParams)
if err != nil {
return nil, fmt.Errorf("DescribeRouteTables failed: %s", err)
}
if len(tablesResp.RouteTables) != 0 {
return tablesResp.RouteTables[0].RouteTableId, nil
}
return nil, fmt.Errorf("cannot find routetable for %s instance", t.instanceID)
}
func (t *AWSVPCTracker) debugf(fmt string, args ...interface{}) {
common.Log.Debugf("[tracker] "+fmt, args...)
}
func (t *AWSVPCTracker) infof(fmt string, args ...interface{}) {
common.Log.Infof("[tracker] "+fmt, args...)
}
// Helpers
// merge merges adjacent range entries.
// The given slice has to be sorted in increasing order.
func merge(r []address.Range) []address.Range {
var merged []address.Range
for i := range r {
if prev := len(merged) - 1; prev >= 0 && merged[prev].End == r[i].Start {
merged[prev].End = r[i].End
} else {
merged = append(merged, r[i])
}
}
return merged
}
// removeCommon filters out CIDR ranges which are contained in both a and b slices.
// Both slices have to be sorted in increasing order.
func removeCommon(a, b []address.CIDR) (newA, newB []address.CIDR) {
i, j := 0, 0
for i < len(a) && j < len(b) {
switch {
case a[i].Start() < b[j].Start() || a[i].End() < b[j].End():
newA = append(newA, a[i])
i++
case a[i].Start() > b[j].Start() || a[i].End() > b[j].End():
newB = append(newB, b[j])
j++
default:
i++
j++
}
}
newA = append(newA, a[i:]...)
newB = append(newB, b[j:]...)
return
}
func parseCIDR(cidr string) (*net.IPNet, error) {
ip, ipnet, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}
ipnet.IP = ip
return ipnet, nil
}
+52
View File
@@ -0,0 +1,52 @@
package tracker
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/weaveworks/weave/net/address"
)
var (
r0to127 = cidr("10.0.0.0", "10.0.0.127")
r128to255 = cidr("10.0.0.128", "10.0.0.255")
r0to255 = cidr("10.0.0.0", "10.0.0.255")
r1dot0to255 = cidr("10.0.1.0", "10.0.1.255")
r2dot0to255 = cidr("10.0.2.0", "10.0.2.255")
)
func TestRemoveCommon(t *testing.T) {
a := []address.CIDR{r0to127, r1dot0to255}
b := []address.CIDR{r1dot0to255, r2dot0to255}
newA, newB := removeCommon(a, b)
require.Equal(t, []address.CIDR{r0to127}, newA)
require.Equal(t, []address.CIDR{r2dot0to255}, newB)
}
func TestMerge(t *testing.T) {
ranges := []address.Range{
r0to127.Range(),
r128to255.Range(),
r2dot0to255.Range(),
}
require.Equal(t, []address.Range{r0to255.Range(), r2dot0to255.Range()}, merge(ranges))
}
// Helper
// TODO(mp) DRY with helpers of other tests.
func ip(s string) address.Address {
addr, _ := address.ParseIP(s)
return addr
}
// [start; end]
func cidr(start, end string) address.CIDR {
c := address.Range{Start: ip(start), End: ip(end) + 1}.CIDRs()
if len(c) != 1 {
panic("invalid cidr")
}
return c[0]
}
+20
View File
@@ -0,0 +1,20 @@
package tracker
import (
"github.com/weaveworks/weave/net/address"
)
// LocalRangeTracker is an interface for tracking changes in the IPAM ring.
type LocalRangeTracker interface {
// HandleUpdate is called whenever an address ring gets updated.
//
// prevRanges corresponds to ranges which were owned by a peer before
// a change in the ring, while currRanges to the ones which are currently
// owned by the peer.
// Both slices have to be sorted in increasing order.
// Adjacent ranges within each slice might appear as separate ranges.
//
// The local parameter indicates whether the ranges belong to the peer
// by which the method is called.
HandleUpdate(prevRanges, currRanges []address.Range, local bool) error
}
-125
View File
@@ -1,125 +0,0 @@
package nameserver
import (
"bytes"
"fmt"
"net"
)
// A zone record
// Note: we will try to keep all the zone records information is concentrated here. Maybe not all queries will
// use things like priorities or weights, but we do not want to create a hierarchy for dealing with all
// possible queries...
type ZoneRecord interface {
Name() string // The name for this IP
IP() net.IP // The IP (v4) address
Priority() int // The priority
Weight() int // The weight
TTL() int // TTL
}
type ZoneLookup interface {
// Lookup for a name
LookupName(name string) ([]ZoneRecord, error)
// Lookup for an address
LookupInaddr(inaddr string) ([]ZoneRecord, error)
}
type ZoneObserver interface {
// Observe anything that affects a particular name in the zone
ObserveName(name string, observer ZoneRecordObserver) error
// Observe anything that affects a particular IP in the zone
ObserveInaddr(inaddr string, observer ZoneRecordObserver) error
}
type ZoneRecordObserver func()
/////////////////////////////////////////////////////////////
// A basic record struct (satisfying the ZoneRecord interface)
type Record struct {
name string
ip net.IP
priority int
weight int
ttl int
}
func (r Record) Name() string { return r.name }
func (r Record) IP() net.IP { return r.ip }
func (r Record) Priority() int { return r.priority }
func (r Record) Weight() int { return r.weight }
func (r Record) TTL() int { return r.ttl }
func (r Record) String() string {
var buf bytes.Buffer
if len(r.Name()) > 0 {
fmt.Fprintf(&buf, "%s", r.Name())
}
if !r.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", r.IP())
}
if r.Priority() > 0 {
fmt.Fprintf(&buf, "/P:%d", r.Priority())
}
if r.Weight() > 0 {
fmt.Fprintf(&buf, "/W:%d", r.Weight())
}
if r.TTL() > 0 {
fmt.Fprintf(&buf, "/TTL:%d", r.TTL())
}
return buf.String()
}
/////////////////////////////////////////////////////////////
func newParseError(reason string, addr string) *net.ParseError {
return &net.ParseError{Type: reason, Text: addr}
}
// simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc...
type IPv4 [4]byte
func (ip IPv4) toNetIP() net.IP { return net.IPv4(ip[0], ip[1], ip[2], ip[3]) }
func (ip IPv4) String() string { return ip.toNetIP().String() }
func ipToIPv4(nip net.IP) IPv4 { ip := nip.To4(); return IPv4([4]byte{ip[0], ip[1], ip[2], ip[3]}) }
// Parse an address (eg, "10.13.12.11") and return the corresponding IPv4 (eg, "10.13.12.11")
func addrToIPv4(addr string) (IPv4, error) {
ip := net.ParseIP(addr)
if ip == nil {
return IPv4{}, newParseError("IP address", addr)
}
return ipToIPv4(ip), nil
}
// Parse a reverse address (eg, "11.12.13.10.in-addr.arpa.") and return the corresponding IPv4 (eg, "10.13.12.11")
func raddrToIPv4(addr string) (IPv4, error) {
l := len(addr)
if l < rdnsDomainLen+1 {
return IPv4{}, newParseError("too short reverse IP address", addr)
}
suffixLen := l - rdnsDomainLen
suffix := addr[suffixLen+1:]
if suffix != RDNSDomain {
return IPv4{}, newParseError("suffix of reverse IP address", addr)
}
ipStr := addr[:suffixLen]
revIP := net.ParseIP(ipStr)
if revIP == nil {
return IPv4{}, newParseError("reverse IP address", addr)
}
revIP4 := revIP.To4()
return IPv4([4]byte{revIP4[3], revIP4[2], revIP4[1], revIP4[0]}), nil
}
func raddrToIP(addr string) (net.IP, error) {
r, err := raddrToIPv4(addr)
if err != nil {
return net.IP{}, err
}
return r.toNetIP(), nil
}
-31
View File
@@ -1,31 +0,0 @@
package nameserver
import (
. "github.com/weaveworks/weave/common"
wt "github.com/weaveworks/weave/testing"
"net"
"testing"
)
func TestAddrs(t *testing.T) {
InitDefaultLogging(testing.Verbose())
Info.Println("TestAddrs starting")
ip, err := addrToIPv4("10.13.12.11")
wt.AssertNoErr(t, err)
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
ip, err = raddrToIPv4("11.12.13.10.in-addr.arpa.")
wt.AssertNoErr(t, err)
wt.AssertTrue(t, net.ParseIP("10.13.12.11").Equal(ip.toNetIP()), "IP")
// some malformed addresses
ip, err = addrToIPv4("10.13.12")
wt.AssertTrue(t, err != nil, "when parsing malformed address")
ip, err = addrToIPv4("10.13.AA.12")
wt.AssertTrue(t, err != nil, "when parsing malformed address")
ip, err = raddrToIPv4("11.12.13.10.in-axxx.arpa.")
wt.AssertTrue(t, err != nil, "when parsing malformed address")
ip, err = raddrToIPv4("11.12.13.10.in-addr")
wt.AssertTrue(t, err != nil, "when parsing malformed address")
}
-401
View File
@@ -1,401 +0,0 @@
package nameserver
import (
"bytes"
"container/heap"
"errors"
"fmt"
"math"
"math/rand"
"sync"
"time"
"github.com/benbjohnson/clock"
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
)
var (
errInvalidCapacity = errors.New("Invalid cache capacity")
errCouldNotResolve = errors.New("Could not resolve")
errTimeout = errors.New("Timeout while waiting for resolution")
errNoLocalReplies = errors.New("No local replies")
)
const (
defPendingTimeout int = 5 // timeout for a resolution
)
const nullTTL = 0 // a null TTL
type entryStatus uint8
const (
stPending entryStatus = iota // someone is waiting for the resolution
stResolved entryStatus = iota // resolved
)
var statusToString = map[entryStatus]string{
stPending: "pending",
stResolved: "resolved",
}
const (
CacheNoLocalReplies uint8 = 1 << iota // not found in local network (stored in the cache so we skip another local lookup or some time)
)
// shuffleAnswers reorders answers for very basic load balancing
func shuffleAnswers(answers []dns.RR) []dns.RR {
n := len(answers)
if n > 1 {
rand.Seed(time.Now().UTC().UnixNano())
for i := 0; i < n; i++ {
r := i + rand.Intn(n-i)
answers[r], answers[i] = answers[i], answers[r]
}
}
return answers
}
// a cache entry
type cacheEntry struct {
Status entryStatus // status of the entry
Flags uint8 // some extra flags
ReplyLen int
question dns.Question
protocol dnsProtocol
reply dns.Msg
validUntil time.Time // obtained from the reply and stored here for convenience/speed
putTime time.Time
index int // for fast lookups in the heap
}
func newCacheEntry(question *dns.Question, now time.Time) *cacheEntry {
e := &cacheEntry{
Status: stPending,
validUntil: now.Add(time.Second * time.Duration(defPendingTimeout)),
question: *question,
index: -1,
}
return e
}
// Get a copy of the reply stored in the entry, but with some values adjusted like the TTL
func (e *cacheEntry) getReply(request *dns.Msg, maxLen int, now time.Time) (*dns.Msg, error) {
if e.Status != stResolved {
return nil, nil
}
// if the reply has expired or is invalid, force the caller to start a new resolution
if e.hasExpired(now) {
return nil, nil
}
if e.Flags&CacheNoLocalReplies != 0 {
return nil, errNoLocalReplies
}
if e.ReplyLen >= maxLen {
Debug.Printf("[cache msgid %d] returning truncated reponse: %d > %d", request.MsgHdr.Id, e.ReplyLen, maxLen)
return makeTruncatedReply(request), nil
}
// create a copy of the reply, with values for this particular query
reply := e.reply.Copy()
reply.SetReply(request)
// adjust the TTLs
passedSecs := uint32(now.Sub(e.putTime).Seconds())
for _, rr := range reply.Answer {
hdr := rr.Header()
ttl := hdr.Ttl
if passedSecs < ttl {
hdr.Ttl = ttl - passedSecs
} else {
return nil, nil // it is expired: do not spend more time and return nil...
}
}
reply.Rcode = e.reply.Rcode
reply.Authoritative = true
// shuffle the values, etc...
reply.Answer = shuffleAnswers(reply.Answer)
return reply, nil
}
func (e cacheEntry) hasExpired(now time.Time) bool {
return e.validUntil.Before(now) || e.validUntil == now
}
// set the reply for the entry
// returns True if the entry has changed the validUntil time
func (e *cacheEntry) setReply(reply *dns.Msg, ttl int, flags uint8, now time.Time) bool {
var prevValidUntil time.Time
if e.Status == stResolved {
if reply != nil {
Debug.Printf("[cache msgid %d] replacing response in cache", reply.MsgHdr.Id)
}
prevValidUntil = e.validUntil
}
// make sure we do not overwrite noLocalReplies entries
if flags&CacheNoLocalReplies != 0 {
if e.Flags&CacheNoLocalReplies != 0 {
return false
}
}
if ttl != nullTTL {
e.validUntil = now.Add(time.Second * time.Duration(ttl))
} else if reply != nil {
// calculate the validUntil from the reply TTL
var minTTL uint32 = math.MaxUint32
for _, rr := range reply.Answer {
ttl := rr.Header().Ttl
if ttl < minTTL {
minTTL = ttl // TODO: improve the minTTL calculation (maybe we should skip some RRs)
}
}
e.validUntil = now.Add(time.Second * time.Duration(minTTL))
} else {
Warning.Printf("[cache] no valid TTL could be calculated")
}
e.Status = stResolved
e.Flags = flags
e.putTime = now
if reply != nil {
e.reply = *reply
e.ReplyLen = reply.Len()
}
return (prevValidUntil != e.validUntil)
}
func (e *cacheEntry) String() string {
var buf bytes.Buffer
q := e.question
fmt.Fprintf(&buf, "'%s'[%s]: ", q.Name, dns.TypeToString[q.Qtype])
if e.Flags&CacheNoLocalReplies != 0 {
fmt.Fprintf(&buf, "neg-local")
} else {
fmt.Fprintf(&buf, "%s", statusToString[e.Status])
}
fmt.Fprintf(&buf, "(%d bytes)", e.ReplyLen)
return buf.String()
}
//////////////////////////////////////////////////////////////////////////////////////
// An entriesPtrHeap is a min-heap of cache entries.
type entriesPtrsHeap []*cacheEntry
func (h entriesPtrsHeap) Len() int { return len(h) }
func (h entriesPtrsHeap) Less(i, j int) bool { return h[i].validUntil.Before(h[j].validUntil) }
func (h entriesPtrsHeap) Swap(i, j int) {
h[i], h[j] = h[j], h[i]
h[i].index = i
h[j].index = j
}
func (h *entriesPtrsHeap) Push(x interface{}) {
// Push and Pop use pointer receivers because they modify the slice's length,
// not just its contents.
n := len(*h)
entry := x.(*cacheEntry)
entry.index = n
*h = append(*h, entry)
}
func (h *entriesPtrsHeap) Pop() interface{} {
old := *h
n := len(old)
item := old[n-1]
item.index = -1 // for safety
*h = old[0 : n-1]
return item
}
//////////////////////////////////////////////////////////////////////////////////////
// The cache interface
type ZoneCache interface {
// Get from the cache
Get(request *dns.Msg, maxLen int) (reply *dns.Msg, err error)
// Put in the cache
Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8) int
// Remove from the cache
Remove(question *dns.Question)
// Purge all expired entries from the cache
Purge()
// Remove all entries
Clear()
// Return the cache length
Len() int
// Return the max capacity
Capacity() int
}
type cacheKey dns.Question
type entries map[cacheKey]*cacheEntry
// Cache is a thread-safe fixed capacity LRU cache.
type Cache struct {
capacity int
entries entries
entriesH entriesPtrsHeap // len(entriesH) <= len(entries), as pending entries can be in entries but not in entriesH
clock clock.Clock
lock sync.RWMutex
}
// NewCache creates a cache of the given capacity
func NewCache(capacity int, clk clock.Clock) (*Cache, error) {
if capacity <= 0 {
return nil, errInvalidCapacity
}
c := &Cache{
capacity: capacity,
entries: make(entries, capacity),
clock: clk,
}
if c.clock == nil {
c.clock = clock.New()
}
heap.Init(&c.entriesH)
return c, nil
}
// Clear removes all the entries in the cache
func (c *Cache) Clear() {
c.lock.Lock()
defer c.lock.Unlock()
c.entries = make(entries, c.capacity)
heap.Init(&c.entriesH)
}
// Purge removes the old elements in the cache
func (c *Cache) Purge() {
c.lock.Lock()
defer c.lock.Unlock()
now := c.clock.Now()
for i, entry := range c.entriesH {
if entry.hasExpired(now) {
heap.Remove(&c.entriesH, i)
delete(c.entries, cacheKey(entry.question))
} else {
return // all remaining entries must be still valid...
}
}
}
// Add adds a reply to the cache.
// When `ttl` is equal to `nullTTL`, the cache entry will be valid until the closest TTL in the `reply`
func (c *Cache) Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8) int {
c.lock.Lock()
defer c.lock.Unlock()
now := c.clock.Now()
question := request.Question[0]
key := cacheKey(question)
ent, found := c.entries[key]
if found {
updated := ent.setReply(reply, ttl, flags, now)
if updated {
heap.Fix(&c.entriesH, ent.index)
}
} else {
// If we will add a new item and the capacity has been exceeded, make some room...
if len(c.entriesH) >= c.capacity {
lowestEntry := heap.Pop(&c.entriesH).(*cacheEntry)
delete(c.entries, cacheKey(lowestEntry.question))
}
ent = newCacheEntry(&question, now)
ent.setReply(reply, ttl, flags, now)
heap.Push(&c.entriesH, ent)
c.entries[key] = ent
}
return ent.ReplyLen
}
// Look up for a question's reply from the cache.
// If no reply is stored in the cache, it returns a `nil` reply and no error.
func (c *Cache) Get(request *dns.Msg, maxLen int) (reply *dns.Msg, err error) {
c.lock.Lock()
defer c.lock.Unlock()
now := c.clock.Now()
question := request.Question[0]
key := cacheKey(question)
if ent, found := c.entries[key]; found {
reply, err = ent.getReply(request, maxLen, now)
if ent.hasExpired(now) {
Debug.Printf("[cache msgid %d] expired: removing", request.MsgHdr.Id)
if ent.index > 0 {
heap.Remove(&c.entriesH, ent.index)
}
delete(c.entries, key)
reply = nil
}
} else {
// we are the first asking for this name: create an entry with no reply... the caller must wait
Debug.Printf("[cache msgid %d] addind in pending state", request.MsgHdr.Id)
c.entries[key] = newCacheEntry(&question, now)
}
return
}
// Remove removes the provided question from the cache.
func (c *Cache) Remove(question *dns.Question) {
c.lock.Lock()
defer c.lock.Unlock()
key := cacheKey(*question)
if entry, found := c.entries[key]; found {
Debug.Printf("[cache] removing %s-response for '%s'", dns.TypeToString[question.Qtype], question.Name)
if entry.index > 0 {
heap.Remove(&c.entriesH, entry.index)
}
delete(c.entries, key)
}
}
// Len returns the number of entries in the cache.
func (c *Cache) Len() int {
c.lock.RLock()
defer c.lock.RUnlock()
return len(c.entries)
}
// Return the max capacity
func (c *Cache) Capacity() int {
c.lock.RLock()
defer c.lock.RUnlock()
return c.capacity
}
// Return the max capacity
func (c *Cache) String() string {
c.lock.RLock()
defer c.lock.RUnlock()
var buf bytes.Buffer
for _, entry := range c.entries {
fmt.Fprintf(&buf, "%s\n", entry)
}
return buf.String()
}
-228
View File
@@ -1,228 +0,0 @@
package nameserver
import (
"fmt"
"net"
"testing"
"time"
"github.com/benbjohnson/clock"
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
wt "github.com/weaveworks/weave/testing"
)
// Check that the cache keeps its intended capacity constant
func TestCacheLength(t *testing.T) {
InitDefaultLogging(testing.Verbose())
Info.Println("TestCacheLength starting")
const cacheLen = 128
l, err := NewCache(cacheLen, nil)
wt.AssertNoErr(t, err)
insTime := time.Now()
t.Logf("Inserting 256 questions in the cache at '%s', with TTL from 0 to 255", insTime)
for i := 0; i < cacheLen*2; i++ {
name := fmt.Sprintf("name%d", i)
questionMsg := new(dns.Msg)
questionMsg.SetQuestion(name, dns.TypeA)
questionMsg.RecursionDesired = true
question := &questionMsg.Question[0]
ip := net.ParseIP(fmt.Sprintf("10.0.1.%d", i))
records := []ZoneRecord{Record{name, ip, 0, 0, 0}}
reply := makeAddressReply(questionMsg, question, records)
reply.Answer[0].Header().Ttl = uint32(i)
l.Put(questionMsg, reply, 0, 0)
}
wt.AssertEqualInt(t, l.Len(), cacheLen, "cache length")
minExpectedTime := insTime.Add(time.Duration(cacheLen) * time.Second)
t.Logf("Checking all remaining entries expire after insert_time + %d secs='%s'", cacheLen, minExpectedTime)
for _, entry := range l.entries {
if entry.validUntil.Before(minExpectedTime) {
t.Fatalf("Entry valid until %s", entry.validUntil)
}
}
}
// Check that the cache entries are ok
func TestCacheEntries(t *testing.T) {
InitDefaultLogging(testing.Verbose())
Info.Println("TestCacheEntries starting")
Info.Println("Checking cache consistency")
const cacheLen = 128
clk := clock.NewMock()
l, err := NewCache(cacheLen, clk)
wt.AssertNoErr(t, err)
questionMsg := new(dns.Msg)
questionMsg.SetQuestion("some.name", dns.TypeA)
questionMsg.RecursionDesired = true
question := &questionMsg.Question[0]
t.Logf("Trying to get a name")
resp, err := l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
if resp != nil {
t.Logf("Got\n%s", resp)
t.Fatalf("ERROR: Did not expect a reponse from Get() yet")
}
t.Logf("Trying to get it again")
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
if resp != nil {
t.Logf("Got\n%s", resp)
t.Fatalf("ERROR: Did not expect a reponse from Get() yet")
}
t.Logf("Inserting the reply")
records := []ZoneRecord{Record{"some.name", net.ParseIP("10.0.1.1"), 0, 0, 0}}
reply1 := makeAddressReply(questionMsg, question, records)
l.Put(questionMsg, reply1, nullTTL, 0)
t.Logf("Checking we can Get() the reply now")
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp != nil, "reponse from Get()")
t.Logf("Received '%s'", resp.Answer[0])
wt.AssertType(t, resp.Answer[0], (*dns.A)(nil), "DNS record")
ttlGet1 := resp.Answer[0].Header().Ttl
clk.Add(time.Duration(1) * time.Second)
t.Logf("Checking that a second Get(), after 1 second, gets the same result, but with reduced TTL")
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp != nil, "reponse from a second Get()")
t.Logf("Received '%s'", resp.Answer[0])
wt.AssertType(t, resp.Answer[0], (*dns.A)(nil), "DNS record")
ttlGet2 := resp.Answer[0].Header().Ttl
wt.AssertEqualInt(t, int(ttlGet1-ttlGet2), 1, "TTL difference")
clk.Add(time.Duration(localTTL) * time.Second)
t.Logf("Checking that a third Get(), after %d second, gets no result", localTTL)
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
if resp != nil {
t.Logf("Got\n%s", resp)
t.Fatalf("ERROR: Did NOT expect a reponse from the second Get()")
}
t.Logf("Checking that an Remove() results in Get() returning nothing")
records = []ZoneRecord{Record{"some.name", net.ParseIP("10.0.9.9"), 0, 0, 0}}
replyTemp := makeAddressReply(questionMsg, question, records)
l.Put(questionMsg, replyTemp, nullTTL, 0)
lenBefore := l.Len()
l.Remove(question)
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length")
l.Remove(question) // do it again: should have no effect...
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length")
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp == nil, "reponse from the Get() after a Remove()")
t.Logf("Inserting a two replies for the same query")
records = []ZoneRecord{Record{"some.name", net.ParseIP("10.0.1.2"), 0, 0, 0}}
reply2 := makeAddressReply(questionMsg, question, records)
l.Put(questionMsg, reply2, nullTTL, 0)
clk.Add(time.Duration(1) * time.Second)
records = []ZoneRecord{Record{"some.name", net.ParseIP("10.0.1.3"), 0, 0, 0}}
reply3 := makeAddressReply(questionMsg, question, records)
l.Put(questionMsg, reply3, nullTTL, 0)
t.Logf("Checking we get the last one...")
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp != nil, "reponse from the Get()")
t.Logf("Received '%s'", resp.Answer[0])
wt.AssertType(t, resp.Answer[0], (*dns.A)(nil), "DNS record")
wt.AssertEqualString(t, resp.Answer[0].(*dns.A).A.String(), "10.0.1.3", "IP address")
wt.AssertEqualInt(t, int(resp.Answer[0].Header().Ttl), int(localTTL), "TTL")
clk.Add(time.Duration(localTTL-1) * time.Second)
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertTrue(t, resp != nil, "reponse from the Get()")
t.Logf("Received '%s'", resp.Answer[0])
wt.AssertType(t, resp.Answer[0], (*dns.A)(nil), "DNS record")
wt.AssertEqualString(t, resp.Answer[0].(*dns.A).A.String(), "10.0.1.3", "IP address")
wt.AssertEqualInt(t, int(resp.Answer[0].Header().Ttl), 1, "TTL")
t.Logf("Checking we get empty replies when they are expired...")
lenBefore = l.Len()
clk.Add(time.Duration(localTTL) * time.Second)
resp, err = l.Get(questionMsg, minUDPSize)
wt.AssertNoErr(t, err)
if resp != nil {
t.Logf("Got\n%s", resp.Answer[0])
t.Fatalf("ERROR: Did NOT expect a reponse from the Get()")
}
wt.AssertEqualInt(t, l.Len(), lenBefore-1, "cache length (after getting an expired entry)")
questionMsg2 := new(dns.Msg)
questionMsg2.SetQuestion("some.other.name", dns.TypeA)
questionMsg2.RecursionDesired = true
question2 := &questionMsg2.Question[0]
t.Logf("Trying to Get() a name")
resp, err = l.Get(questionMsg2, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertNil(t, resp, "reponse from Get() yet")
t.Logf("Checking that an Remove() between Get() and Put() does not break things")
records = []ZoneRecord{Record{"some.name", net.ParseIP("10.0.9.9"), 0, 0, 0}}
replyTemp2 := makeAddressReply(questionMsg2, question2, records)
l.Remove(question2)
l.Put(questionMsg2, replyTemp2, nullTTL, 0)
resp, err = l.Get(questionMsg2, minUDPSize)
wt.AssertNoErr(t, err)
wt.AssertNotNil(t, resp, "reponse from Get()")
questionMsg3 := new(dns.Msg)
questionMsg3.SetQuestion("some.other.name", dns.TypeA)
questionMsg3.RecursionDesired = true
question3 := &questionMsg3.Question[0]
t.Logf("Checking that a entry with CacheNoLocalReplies return an error")
l.Put(questionMsg3, nil, negLocalTTL, CacheNoLocalReplies)
resp, err = l.Get(questionMsg3, minUDPSize)
wt.AssertNil(t, resp, "Get() response with CacheNoLocalReplies")
wt.AssertTrue(t, err == errNoLocalReplies, "Get() error with CacheNoLocalReplies")
t.Logf("Checking that more Put's do not make the negative TTL longer")
clk.Add(time.Duration(negLocalTTL/2) * time.Second)
l.Put(questionMsg3, nil, negLocalTTL, CacheNoLocalReplies)
clk.Add(time.Duration(1) * time.Second)
l.Put(questionMsg3, nil, negLocalTTL, CacheNoLocalReplies)
clk.Add(time.Duration(1) * time.Second)
l.Put(questionMsg3, nil, negLocalTTL, CacheNoLocalReplies)
resp, err = l.Get(questionMsg3, minUDPSize)
wt.AssertNil(t, resp, "Get() response with CacheNoLocalReplies")
wt.AssertTrue(t, err == errNoLocalReplies, "Get() error with CacheNoLocalReplies")
clk.Add(time.Duration(negLocalTTL/2) * time.Second)
t.Logf("Checking that we get an expired response after %f seconds", negLocalTTL)
resp, err = l.Get(questionMsg3, minUDPSize)
wt.AssertNil(t, resp, "expired Get() response with CacheNoLocalReplies")
wt.AssertNil(t, err, "expired Get() error with CacheNoLocalReplies")
l.Remove(question3)
t.Logf("Checking that Put&Get with CacheNoLocalReplies with a Remove in the middle returns nothing")
l.Put(questionMsg3, nil, nullTTL, CacheNoLocalReplies)
l.Remove(question3)
resp, err = l.Get(questionMsg3, minUDPSize)
wt.AssertNil(t, resp, "Get() reponse with CacheNoLocalReplies")
wt.AssertNil(t, err, "Get() error with CacheNoLocalReplies")
}
+323 -58
View File
@@ -1,86 +1,351 @@
package nameserver
import (
"bytes"
"fmt"
"math/rand"
"net"
"os"
"sort"
"strings"
"sync"
"time"
"github.com/miekg/dns"
"github.com/weaveworks/weave/net/address"
)
const (
localTTL uint32 = 30 // somewhat arbitrary; we don't expect anyone downstream to cache results
negLocalTTL = 30 // TTL for negative local resolutions
minUDPSize = 512
maxUDPSize = 65535
topDomain = "."
reverseDNSdomain = "in-addr.arpa."
udpBuffSize = uint16(4096)
minUDPSize = 512
DefaultListenAddress = "0.0.0.0:53"
DefaultTTL = 1
DefaultClientTimeout = 5 * time.Second
)
func makeHeader(r *dns.Msg, q *dns.Question) *dns.RR_Header {
return &dns.RR_Header{
Name: q.Name, Rrtype: q.Qtype,
Class: dns.ClassINET, Ttl: localTTL}
type Upstream interface {
Config() (*dns.ClientConfig, error)
}
func makeReply(r *dns.Msg, as []dns.RR) *dns.Msg {
m := new(dns.Msg)
m.SetReply(r)
m.RecursionAvailable = true
m.Answer = as
return m
func NewUpstream(resolvConf, filterAddress string) Upstream {
return &upstream{
resolvConf: resolvConf,
filterAddress: filterAddress,
cachedConfig: &dns.ClientConfig{}}
}
func makeTruncatedReply(r *dns.Msg) *dns.Msg {
// for truncated response, we create a minimal reply with the Truncated bit set
reply := new(dns.Msg)
reply.SetReply(r)
reply.Truncated = true
return reply
type upstream struct {
sync.Mutex
resolvConf string
filterAddress string
cachedConfig *dns.ClientConfig
lastStat time.Time
lastModified time.Time
}
func makeAddressReply(r *dns.Msg, q *dns.Question, addrs []ZoneRecord) *dns.Msg {
answers := make([]dns.RR, len(addrs))
header := makeHeader(r, q)
count := 0
for _, addr := range addrs {
ip := addr.IP()
ip4 := ip.To4()
func (u *upstream) Config() (*dns.ClientConfig, error) {
u.Lock()
defer u.Unlock()
switch q.Qtype {
case dns.TypeA:
if ip4 != nil {
answers[count] = &dns.A{Hdr: *header, A: ip}
count++
}
case dns.TypeAAAA:
if ip4 == nil {
answers[count] = &dns.AAAA{Hdr: *header, AAAA: ip}
count++
}
// If we checked less than five seconds ago return what we already have
now := time.Now()
if now.Sub(u.lastStat) < 5*time.Second {
return u.cachedConfig, nil
}
u.lastStat = now
// Reread file if it has changed
if fi, err := os.Stat(u.resolvConf); err != nil {
return u.cachedConfig, err
} else if fi.ModTime() != u.lastModified {
if config, err := dns.ClientConfigFromFile(u.resolvConf); err == nil {
config.Servers = filter(config.Servers, u.filterAddress)
u.lastModified = fi.ModTime()
u.cachedConfig = config
} else {
return u.cachedConfig, err
}
}
return makeReply(r, answers[:count])
return u.cachedConfig, nil
}
func makePTRReply(r *dns.Msg, q *dns.Question, names []ZoneRecord) *dns.Msg {
answers := make([]dns.RR, len(names))
header := makeHeader(r, q)
for i, name := range names {
answers[i] = &dns.PTR{Hdr: *header, Ptr: name.Name()}
func filter(ss []string, s string) []string {
for i := 0; i < len(ss); {
if ss[i] == s {
ss = append(ss[:i], ss[i+1:]...)
continue
}
i++
}
return makeReply(r, answers)
return ss
}
func makeDNSFailResponse(r *dns.Msg) *dns.Msg {
m := new(dns.Msg)
m.SetReply(r)
m.RecursionAvailable = true
m.Rcode = dns.RcodeNameError
type DNSServer struct {
ns *Nameserver
domain string
ttl uint32
address string
servers []*dns.Server
upstream Upstream
tcpClient *dns.Client
udpClient *dns.Client
}
func NewDNSServer(ns *Nameserver, domain, address string, upstream Upstream, ttl uint32, clientTimeout time.Duration) (*DNSServer, error) {
s := &DNSServer{
ns: ns,
domain: dns.Fqdn(domain),
ttl: ttl,
address: address,
upstream: upstream,
tcpClient: &dns.Client{Net: "tcp", ReadTimeout: clientTimeout},
udpClient: &dns.Client{Net: "udp", ReadTimeout: clientTimeout, UDPSize: udpBuffSize},
}
err := s.listen(address)
return s, err
}
func (d *DNSServer) String() string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "WeaveDNS (%s)\n", d.ns.ourName)
fmt.Fprintf(&buf, " listening on %s, for domain %s\n", d.address, d.domain)
fmt.Fprintf(&buf, " response ttl %d\n", d.ttl)
return buf.String()
}
func (d *DNSServer) listen(address string) error {
udpListener, err := net.ListenPacket("udp", address)
if err != nil {
return err
}
udpServer := &dns.Server{PacketConn: udpListener, Handler: d.createMux(d.udpClient, minUDPSize)}
tcpListener, err := net.Listen("tcp", address)
if err != nil {
udpServer.Shutdown()
return err
}
tcpServer := &dns.Server{Listener: tcpListener, Handler: d.createMux(d.tcpClient, -1)}
d.servers = []*dns.Server{udpServer, tcpServer}
return nil
}
func (d *DNSServer) ActivateAndServe() {
for _, server := range d.servers {
go func(server *dns.Server) {
server.ActivateAndServe()
}(server)
}
}
func (d *DNSServer) Stop() error {
for _, server := range d.servers {
if err := server.Shutdown(); err != nil {
return err
}
}
return nil
}
type handler struct {
*DNSServer
maxResponseSize int
client *dns.Client
}
func (d *DNSServer) createMux(client *dns.Client, defaultMaxResponseSize int) *dns.ServeMux {
m := dns.NewServeMux()
h := &handler{
DNSServer: d,
maxResponseSize: defaultMaxResponseSize,
client: client,
}
m.HandleFunc(d.domain, h.handleLocal)
m.HandleFunc(reverseDNSdomain, h.handleReverse)
m.HandleFunc(topDomain, h.handleRecursive)
return m
}
// get the maximum UDP-reply length
func getMaxReplyLen(r *dns.Msg, proto dnsProtocol) int {
maxLen := minUDPSize
if proto == protTCP {
maxLen = maxUDPSize
} else if opt := r.IsEdns0(); opt != nil {
maxLen = int(opt.UDPSize())
func (h *handler) handleLocal(w dns.ResponseWriter, req *dns.Msg) {
h.ns.debugf("local request: %+v", *req)
if len(req.Question) != 1 {
h.nameError(w, req)
return
}
hostname := dns.Fqdn(req.Question[0].Name)
if strings.Count(hostname, ".") == 1 {
hostname = hostname + h.domain
}
addrs := h.ns.Lookup(hostname)
if len(addrs) == 0 {
h.nameError(w, req)
return
}
// Per RFC4074, if we have an A but another type was requested,
// return 'no error' with empty answer section
if req.Question[0].Qtype != dns.TypeA {
h.respond(w, h.makeResponse(req, nil))
return
}
header := dns.RR_Header{
Name: req.Question[0].Name,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: h.ttl,
}
answers := make([]dns.RR, len(addrs))
for i, addr := range addrs {
ip := addr.IP4()
answers[i] = &dns.A{Hdr: header, A: ip}
}
shuffleAnswers(&answers)
h.respond(w, h.makeResponse(req, answers))
}
func (h *handler) handleReverse(w dns.ResponseWriter, req *dns.Msg) {
h.ns.debugf("reverse request: %+v", *req)
if len(req.Question) != 1 || req.Question[0].Qtype != dns.TypePTR {
h.nameError(w, req)
return
}
ipStr := strings.TrimSuffix(strings.ToLower(req.Question[0].Name), "."+reverseDNSdomain)
ip, err := address.ParseIP(ipStr)
if err != nil {
h.nameError(w, req)
return
}
hostname, err := h.ns.ReverseLookup(ip.Reverse())
if err != nil {
h.handleRecursive(w, req)
return
}
header := dns.RR_Header{
Name: req.Question[0].Name,
Rrtype: dns.TypePTR,
Class: dns.ClassINET,
Ttl: h.ttl,
}
answers := []dns.RR{&dns.PTR{
Hdr: header,
Ptr: hostname,
}}
h.respond(w, h.makeResponse(req, answers))
}
func (h *handler) handleRecursive(w dns.ResponseWriter, req *dns.Msg) {
h.ns.debugf("recursive request: %+v", *req)
// Resolve unqualified names locally
if len(req.Question) == 1 {
hostname := dns.Fqdn(req.Question[0].Name)
if strings.Count(hostname, ".") == 1 {
h.handleLocal(w, req)
return
}
}
upstreamConfig, err := h.upstream.Config()
if err != nil {
h.ns.errorf("unable to read upstream config: %s", err)
}
for _, server := range upstreamConfig.Servers {
reqCopy := req.Copy()
reqCopy.Id = dns.Id()
response, _, err := h.client.Exchange(reqCopy, fmt.Sprintf("%s:%s", server, upstreamConfig.Port))
if (err != nil && err != dns.ErrTruncated) || response == nil {
h.ns.debugf("error trying %s: %v", server, err)
continue
}
response.Id = req.Id
if h.responseTooBig(req, response) {
response.Compress = true
}
h.respond(w, response)
return
}
h.respond(w, h.makeErrorResponse(req, dns.RcodeServerFailure))
}
func (h *handler) makeResponse(req *dns.Msg, answers []dns.RR) *dns.Msg {
response := &dns.Msg{}
response.SetReply(req)
response.RecursionAvailable = true
response.Authoritative = true
response.Answer = answers
if !h.responseTooBig(req, response) {
return response
}
// search for smallest i that is too big
maxSize := h.getMaxResponseSize(req)
i := sort.Search(len(answers), func(i int) bool {
// return true if too big
response.Answer = answers[:i+1]
return response.Len() > maxSize
})
response.Answer = answers[:i]
if i < len(answers) {
response.Truncated = true
}
return response
}
func (h *handler) makeErrorResponse(req *dns.Msg, code int) *dns.Msg {
response := &dns.Msg{}
response.SetReply(req)
response.RecursionAvailable = true
response.Rcode = code
return response
}
func (h *handler) responseTooBig(req, response *dns.Msg) bool {
return len(response.Answer) > 1 && h.maxResponseSize > 0 && response.Len() > h.getMaxResponseSize(req)
}
func (h *handler) respond(w dns.ResponseWriter, response *dns.Msg) {
h.ns.debugf("response: %+v", response)
if err := w.WriteMsg(response); err != nil {
h.ns.infof("error responding: %v", err)
}
}
func (h *handler) nameError(w dns.ResponseWriter, req *dns.Msg) {
h.respond(w, h.makeErrorResponse(req, dns.RcodeNameError))
}
func (h *handler) getMaxResponseSize(req *dns.Msg) int {
if opt := req.IsEdns0(); opt != nil {
return int(opt.UDPSize())
}
return h.maxResponseSize
}
func shuffleAnswers(answers *[]dns.RR) {
if len(*answers) <= 1 {
return
}
for i := range *answers {
j := rand.Intn(i + 1)
(*answers)[i], (*answers)[j] = (*answers)[j], (*answers)[i]
}
return maxLen
}
+177
View File
@@ -0,0 +1,177 @@
package nameserver
import (
"fmt"
"math/rand"
"net"
"strconv"
"testing"
"time"
"github.com/miekg/dns"
"github.com/stretchr/testify/require"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/net/address"
)
type mockUpstream struct {
config *dns.ClientConfig
}
func (mu *mockUpstream) Config() (*dns.ClientConfig, error) {
return mu.config, nil
}
func startServer(t *testing.T, upstream *dns.ClientConfig) (*DNSServer, *Nameserver, int, int) {
peername, err := mesh.PeerNameFromString("00:00:00:02:00:00")
require.Nil(t, err)
nameserver := New(peername, "", func(mesh.PeerName) bool { return true })
dnsserver, err := NewDNSServer(nameserver, "weave.local.", "0.0.0.0:0", &mockUpstream{upstream}, 30, 5*time.Second)
require.Nil(t, err)
udpPort := dnsserver.servers[0].PacketConn.LocalAddr().(*net.UDPAddr).Port
tcpPort := dnsserver.servers[1].Listener.Addr().(*net.TCPAddr).Port
go dnsserver.ActivateAndServe()
return dnsserver, nameserver, udpPort, tcpPort
}
func TestTruncation(t *testing.T) {
//common.SetLogLevel("debug")
dnsserver, nameserver, udpPort, tcpPort := startServer(t, nil)
defer dnsserver.Stop()
// Add 100 mappings to nameserver
addrs := []address.Address{}
for i := address.Address(0); i < 100; i++ {
addrs = append(addrs, i)
nameserver.AddEntry("foo.weave.local.", "", mesh.UnknownPeerName, i)
}
doRequest := func(client *dns.Client, request *dns.Msg, port int, expectedErr error) *dns.Msg {
request.SetQuestion("foo.weave.local.", dns.TypeA)
response, _, err := client.Exchange(request, fmt.Sprintf("127.0.0.1:%d", port))
require.Equal(t, expectedErr, err)
return response
}
// do a udp query, ensure we get a truncated response
{
udpClient := dns.Client{Net: "udp", UDPSize: minUDPSize}
response := doRequest(&udpClient, &dns.Msg{}, udpPort, dns.ErrTruncated)
require.True(t, response.MsgHdr.Truncated)
require.True(t, len(response.Answer) < 100)
}
// do a udp query with big size, ensure we don't get a truncated response
{
udpClient := dns.Client{Net: "udp", UDPSize: 65535}
request := &dns.Msg{}
request.SetEdns0(65535, false)
response := doRequest(&udpClient, request, udpPort, nil)
require.False(t, response.MsgHdr.Truncated)
require.Equal(t, len(response.Answer), 100)
}
// do a tcp query, ensure we don't get a truncated response
{
tcpClient := dns.Client{Net: "tcp"}
response := doRequest(&tcpClient, &dns.Msg{}, tcpPort, nil)
require.False(t, response.MsgHdr.Truncated)
require.Equal(t, len(response.Answer), 100)
}
}
func TestTruncateResponse(t *testing.T) {
header := dns.RR_Header{
Name: "host.domain.com",
Rrtype: dns.TypePTR,
Class: dns.ClassINET,
Ttl: 30,
}
for i := 0; i < 10000; i++ {
// generate a random answer set
numAnswers := 40 + rand.Intn(200)
answers := make([]dns.RR, numAnswers)
for j := 0; j < numAnswers; j++ {
answers[j] = &dns.A{Hdr: header, A: address.Address(j).IP4()}
}
// pick a random max size, truncate response to that, check it
maxSize := 512 + rand.Intn(2*512)
h := handler{maxResponseSize: maxSize}
response := h.makeResponse(&dns.Msg{}, answers)
require.True(t, response.Len() <= maxSize)
}
}
func TestRecursiveCompress(t *testing.T) {
const (
hostname = "foo.example."
maxSize = 512
)
// Construct a response that is >512 when uncompressed, <512 when compressed
response := dns.Msg{}
response.Authoritative = true
response.Answer = []dns.RR{}
header := dns.RR_Header{
Name: hostname,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: 10,
}
for response.Len() <= maxSize {
ip := address.Address(rand.Uint32()).IP4()
response.Answer = append(response.Answer, &dns.A{Hdr: header, A: ip})
}
response.Compress = true
require.True(t, response.Len() <= maxSize)
// A dns server that returns the above response
var gotRequest = make(chan struct{}, 1)
handleRecursive := func(w dns.ResponseWriter, req *dns.Msg) {
gotRequest <- struct{}{}
require.Equal(t, req.Question[0].Name, hostname)
response.SetReply(req)
err := w.WriteMsg(&response)
require.Nil(t, err)
}
mux := dns.NewServeMux()
mux.HandleFunc(topDomain, handleRecursive)
udpListener, err := net.ListenPacket("udp", "0.0.0.0:0")
require.Nil(t, err)
udpServer := &dns.Server{PacketConn: udpListener, Handler: mux}
udpServerPort := udpListener.LocalAddr().(*net.UDPAddr).Port
go udpServer.ActivateAndServe()
defer udpServer.Shutdown()
// The weavedns server, pointed at the above server
dnsserver, _, udpPort, _ := startServer(t, &dns.ClientConfig{
Servers: []string{"127.0.0.1"},
Port: strconv.Itoa(udpServerPort),
Ndots: 1,
Timeout: 5,
Attempts: 2,
})
defer dnsserver.Stop()
// Now do lookup, check its what we expected.
// NB this doesn't really test golang's resolver behaves correctly, as I can't see
// a way to point golangs resolver at a specific hosts.
req := new(dns.Msg)
req.Id = dns.Id()
req.RecursionDesired = true
req.Question = make([]dns.Question, 1)
req.Question[0] = dns.Question{
Name: hostname,
Qtype: dns.TypeA,
Qclass: dns.ClassINET,
}
c := new(dns.Client)
res, _, err := c.Exchange(req, fmt.Sprintf("127.0.0.1:%d", udpPort))
require.Nil(t, err)
require.True(t, len(gotRequest) > 0)
require.True(t, res.Len() > maxSize)
}
+304
View File
@@ -0,0 +1,304 @@
package nameserver
import (
"bytes"
"encoding/gob"
"fmt"
"sort"
"strings"
"time"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/net/address"
)
var now = func() int64 { return time.Now().Unix() }
type Entry struct {
ContainerID string
Origin mesh.PeerName
Addr address.Address
Hostname string // as supplied
lHostname string // lowercased (not exported, so not encoded by gob)
Version int
Tombstone int64 // timestamp of when it was deleted
}
type Entries []Entry
type CaseSensitive Entries
type CaseInsensitive Entries
type SortableEntries interface {
sort.Interface
Get(i int) Entry
}
// Gossip messages are sorted in a case sensitive order...
func (es CaseSensitive) Len() int { return len(es) }
func (es CaseSensitive) Swap(i, j int) { es[i], es[j] = es[j], es[i] }
func (es CaseSensitive) Get(i int) Entry { return es[i] }
func (es CaseSensitive) Less(i, j int) bool { return es[i].less(&es[j]) }
// ... but we store entries in a case insensitive order.
func (es CaseInsensitive) Len() int { return len(es) }
func (es CaseInsensitive) Swap(i, j int) { es[i], es[j] = es[j], es[i] }
func (es CaseInsensitive) Get(i int) Entry { return es[i] }
func (es CaseInsensitive) Less(i, j int) bool { return es[i].insensitiveLess(&es[j]) }
func (e1 Entry) equal(e2 Entry) bool {
return e1.ContainerID == e2.ContainerID &&
e1.Origin == e2.Origin &&
e1.Addr == e2.Addr &&
e1.Hostname == e2.Hostname
}
func (e1 *Entry) less(e2 *Entry) bool {
// Entries are kept sorted by Hostname, Origin, ContainerID then address
switch {
case e1.Hostname != e2.Hostname:
return e1.Hostname < e2.Hostname
case e1.Origin != e2.Origin:
return e1.Origin < e2.Origin
case e1.ContainerID != e2.ContainerID:
return e1.ContainerID < e2.ContainerID
default:
return e1.Addr < e2.Addr
}
}
func (e1 *Entry) insensitiveLess(e2 *Entry) bool {
// Entries are kept sorted by Hostname, Origin, ContainerID then address
e1Hostname, e2Hostname := e1.lHostname, e2.lHostname
switch {
case e1Hostname != e2Hostname:
return e1Hostname < e2Hostname
case e1.Origin != e2.Origin:
return e1.Origin < e2.Origin
case e1.ContainerID != e2.ContainerID:
return e1.ContainerID < e2.ContainerID
default:
return e1.Addr < e2.Addr
}
}
// returns true to indicate a change
func (e1 *Entry) merge(e2 *Entry) bool {
// we know container id, origin, add and hostname are equal
if e2.Version > e1.Version {
e1.Version = e2.Version
e1.Tombstone = e2.Tombstone
return true
} else if e2.Version == e1.Version && e2.Tombstone > e1.Tombstone {
e1.Tombstone = e2.Tombstone
return true
}
return false
}
func (e1 *Entry) String() string {
return fmt.Sprintf("%s -> %s", e1.Hostname, e1.Addr.String())
}
func (e1 *Entry) addLowercase() {
e1.lHostname = strings.ToLower(e1.Hostname)
}
func (e1 *Entry) tombstone() bool {
if e1.Tombstone > 0 {
return false
}
e1.Tombstone = now()
e1.Version++
return true
}
func check(es SortableEntries) error {
if !sort.IsSorted(es) {
return fmt.Errorf("Not sorted")
}
for i := 1; i < es.Len(); i++ {
if es.Get(i).equal(es.Get(i - 1)) {
return fmt.Errorf("Duplicate entry: %d:%v and %d:%v", i-1, es.Get(i-1), i, es.Get(i))
}
}
return nil
}
func checkAndPanic(es SortableEntries) {
if err := check(es); err != nil {
panic(err)
}
}
func (es *Entries) checkAndPanic() *Entries {
checkAndPanic(CaseInsensitive(*es))
return es
}
func (es *Entries) add(hostname, containerid string, origin mesh.PeerName, addr address.Address) Entry {
defer es.checkAndPanic().checkAndPanic()
entry := Entry{Hostname: hostname, lHostname: strings.ToLower(hostname),
Origin: origin, ContainerID: containerid, Addr: addr}
i := sort.Search(len(*es), func(i int) bool {
return !(*es)[i].insensitiveLess(&entry)
})
if i < len(*es) && (*es)[i].equal(entry) {
if (*es)[i].Tombstone > 0 {
(*es)[i].Tombstone = 0
(*es)[i].Version++
}
} else {
*es = append(*es, Entry{})
copy((*es)[i+1:], (*es)[i:])
(*es)[i] = entry
}
return (*es)[i]
}
func (es *Entries) merge(incoming Entries) Entries {
defer es.checkAndPanic().checkAndPanic()
incoming.checkAndPanic()
newEntries := Entries{}
i := 0
for _, entry := range incoming {
for i < len(*es) && (*es)[i].insensitiveLess(&entry) {
i++
}
if i < len(*es) && (*es)[i].equal(entry) {
if (*es)[i].merge(&entry) {
newEntries = append(newEntries, entry)
}
} else {
*es = append(*es, Entry{})
copy((*es)[i+1:], (*es)[i:])
(*es)[i] = entry
newEntries = append(newEntries, entry)
}
}
return newEntries
}
// f returning true means keep the entry.
func (es *Entries) tombstone(ourname mesh.PeerName, f func(*Entry) bool) Entries {
defer es.checkAndPanic().checkAndPanic()
tombstoned := Entries{}
for i, e := range *es {
if f(&e) && e.Origin == ourname && e.tombstone() {
(*es)[i] = e
tombstoned = append(tombstoned, e)
}
}
return tombstoned
}
// note f() may only modify entries such that they remain in order defined by less()
func (es *Entries) filter(f func(*Entry) bool) {
defer es.checkAndPanic().checkAndPanic()
i := 0
for _, e := range *es {
if !f(&e) {
continue
}
(*es)[i] = e
i++
}
*es = (*es)[:i]
}
func (es Entries) findEqual(e *Entry) (*Entry, bool) {
i := sort.Search(len(es), func(i int) bool {
return !es[i].insensitiveLess(e)
})
if i < len(es) && es[i].equal(*e) {
return &es[i], true
}
return nil, false
}
func (es Entries) lookup(hostname string) Entries {
es.checkAndPanic()
lowerHostname := strings.ToLower(hostname)
i := sort.Search(len(es), func(i int) bool {
return es[i].lHostname >= lowerHostname
})
if i >= len(es) || es[i].lHostname != lowerHostname {
return Entries{}
}
j := sort.Search(len(es)-i, func(j int) bool {
return es[i+j].lHostname > lowerHostname
})
return es[i : i+j]
}
func (es Entries) first(f func(*Entry) bool) (*Entry, error) {
es.checkAndPanic()
for _, e := range es {
if f(&e) {
return &e, nil
}
}
return nil, fmt.Errorf("Not found")
}
func (es Entries) addLowercase() {
for i := range es {
es[i].addLowercase()
}
}
type GossipData struct {
Timestamp int64
Entries
}
func (g *GossipData) Merge(o mesh.GossipData) mesh.GossipData {
other := o.(*GossipData)
gossip := g.copy()
gossip.Entries.merge(other.Entries)
if gossip.Timestamp < other.Timestamp {
gossip.Timestamp = other.Timestamp
}
return gossip
}
func (g *GossipData) Decode(msg []byte) error {
if err := gob.NewDecoder(bytes.NewReader(msg)).Decode(g); err != nil {
return err
}
g.Entries.addLowercase() // lowercase strings not sent on the wire
sort.Sort(CaseInsensitive(g.Entries))
return nil
}
func (g *GossipData) Encode() [][]byte {
g2 := g.copy()
sort.Sort(CaseSensitive(g2.Entries))
buf := &bytes.Buffer{}
if err := gob.NewEncoder(buf).Encode(g2); err != nil {
panic(err)
}
return [][]byte{buf.Bytes()}
}
func (g *GossipData) copy() *GossipData {
g2 := &GossipData{Timestamp: g.Timestamp, Entries: make(Entries, len(g.Entries))}
copy(g2.Entries, g.Entries)
return g2
}
+138
View File
@@ -0,0 +1,138 @@
package nameserver
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/weaveworks/mesh"
"github.com/weaveworks/weave/net/address"
)
func l(es Entries) Entries {
es.addLowercase()
return es
}
func makeEntries(values string) Entries {
entries := make(Entries, len(values))
for i, c := range values {
entries[i] = Entry{Hostname: string(c)}
}
return l(entries)
}
func TestAdd(t *testing.T) {
oldNow := now
defer func() { now = oldNow }()
now = func() int64 { return 1234 }
entries := Entries{}
entries.add("A", "", mesh.UnknownPeerName, address.Address(0))
expected := l(Entries{
Entry{Hostname: "A", Origin: mesh.UnknownPeerName, Addr: address.Address(0)},
})
require.Equal(t, entries, expected)
entries.tombstone(mesh.UnknownPeerName, func(e *Entry) bool { return e.Hostname == "A" })
expected = l(Entries{
Entry{Hostname: "A", Origin: mesh.UnknownPeerName, Addr: address.Address(0), Version: 1, Tombstone: 1234},
})
require.Equal(t, entries, expected)
entries.add("A", "", mesh.UnknownPeerName, address.Address(0))
expected = l(Entries{
Entry{Hostname: "A", Origin: mesh.UnknownPeerName, Addr: address.Address(0), Version: 2},
})
require.Equal(t, entries, expected)
}
func TestMerge(t *testing.T) {
e1 := makeEntries("ACDF")
e2 := makeEntries("BEF")
diff := e1.merge(e2)
require.Equal(t, makeEntries("BE"), diff)
require.Equal(t, makeEntries("ABCDEF"), e1)
diff = e1.merge(e1)
require.Equal(t, Entries{}, diff)
}
func TestOldMerge(t *testing.T) {
e1 := l(Entries{Entry{Hostname: "A", Version: 0}})
diff := e1.merge(l(Entries{Entry{Hostname: "A", Version: 1}}))
require.Equal(t, l(Entries{Entry{Hostname: "A", Version: 1}}), diff)
require.Equal(t, l(Entries{Entry{Hostname: "A", Version: 1}}), e1)
diff = e1.merge(l(Entries{Entry{Hostname: "A", Version: 0}}))
require.Equal(t, Entries{}, diff)
require.Equal(t, l(Entries{Entry{Hostname: "A", Version: 1}}), e1)
}
func TestTombstone(t *testing.T) {
oldNow := now
defer func() { now = oldNow }()
now = func() int64 { return 1234 }
es := makeEntries("AB")
es.tombstone(mesh.UnknownPeerName, func(e *Entry) bool {
return e.Hostname == "B"
})
expected := l(Entries{
Entry{Hostname: "A"},
Entry{Hostname: "B", Version: 1, Tombstone: 1234},
})
require.Equal(t, expected, es)
// Now try a merge including two entries which differ only in tombstone
e2 := make(Entries, len(es))
copy(e2, es)
e2[1].Tombstone = 5555
diff := es.merge(e2)
expected2 := l(Entries{
Entry{Hostname: "A"},
Entry{Hostname: "B", Version: 1, Tombstone: 5555},
})
require.Equal(t, expected2, es)
expectedDiff := l(Entries{Entry{Hostname: "B", Version: 1, Tombstone: 5555}})
require.Equal(t, expectedDiff, diff)
}
func TestDelete(t *testing.T) {
es := makeEntries("AB")
es.filter(func(e *Entry) bool {
return e.Hostname != "A"
})
require.Equal(t, makeEntries("B"), es)
}
func TestLookup(t *testing.T) {
es := l(Entries{
Entry{Hostname: "A"},
Entry{Hostname: "B", ContainerID: "bar"},
Entry{Hostname: "B", ContainerID: "foo"},
Entry{Hostname: "C"},
})
have := es.lookup("B")
want := l(Entries{
Entry{Hostname: "B", ContainerID: "bar"},
Entry{Hostname: "B", ContainerID: "foo"},
})
require.Equal(t, have, want)
}
func TestGossipDataMerge(t *testing.T) {
g1 := GossipData{Entries: makeEntries("AcDf")}
g2 := GossipData{Entries: makeEntries("BEf")}
g3 := g1.Merge(&g2).(*GossipData)
require.Equal(t, GossipData{Entries: makeEntries("ABcDEf")}, *g3)
}
+66 -70
View File
@@ -1,95 +1,91 @@
package nameserver
import (
"encoding/json"
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
"log"
"net"
"net/http"
"github.com/weaveworks/weave/common/docker"
"github.com/weaveworks/weave/net/address"
)
func httpErrorAndLog(level *log.Logger, w http.ResponseWriter, msg string,
status int, logmsg string, logargs ...interface{}) {
http.Error(w, msg, status)
level.Printf("[http] "+logmsg, logargs...)
func (n *Nameserver) badRequest(w http.ResponseWriter, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
n.infof("%v", err)
}
func ListenHTTP(version string, server *DNSServer, domain string, db Zone, port int) {
muxRouter := mux.NewRouter()
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "weave DNS", version)
fmt.Fprintln(w, server.Status())
func (n *Nameserver) HandleHTTP(router *mux.Router, dockerCli *docker.Client) {
router.Methods("GET").Path("/domain").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, n.domain)
})
muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
reqError := func(msg string, logmsg string, logargs ...interface{}) {
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
router.Methods("PUT").Path("/name/{container}/{ip}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var (
vars = mux.Vars(r)
container = vars["container"]
ipStr = vars["ip"]
hostname = dns.Fqdn(r.FormValue("fqdn"))
ip, err = address.ParseIP(ipStr)
)
if err != nil {
n.badRequest(w, err)
return
}
if !dns.IsSubDomain(n.domain, hostname) {
n.infof("Ignoring registration %s %s %s (not a subdomain of %s)", hostname, ipStr, container, n.domain)
return
}
n.AddEntry(hostname, container, n.ourName, ip)
if r.FormValue("check-alive") == "true" && dockerCli != nil && dockerCli.IsContainerNotRunning(container) {
n.infof("container '%s' is not running: removing", container)
n.Delete(hostname, container, ipStr, ip)
}
w.WriteHeader(204)
})
deleteHandler := func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
idStr := vars["id"]
ipStr := vars["ip"]
name := r.FormValue("fqdn")
if name == "" {
reqError("Invalid FQDN", "Invalid FQDN in request: %s, %s", r.URL, r.Form)
return
}
ip := net.ParseIP(ipStr)
if ip == nil {
reqError("Invalid IP", "Invalid IP in request: %s", ipStr)
return
}
if dns.IsSubDomain(domain, name) {
Info.Printf("[http] Adding %s -> %s", name, ipStr)
if err := db.AddRecord(idStr, name, ip); err != nil {
if _, ok := err.(DuplicateError); !ok {
httpErrorAndLog(
Error, w, "Internal error", http.StatusInternalServerError,
"Unexpected error from DB: %s", err)
return
} // oh, I already know this. whatever.
}
hostname := r.FormValue("fqdn")
if hostname == "" {
hostname = "*"
} else {
Info.Printf("[http] Ignoring name %s, not in %s", name, domain)
}
})
muxRouter.Methods("DELETE").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
reqError := func(msg string, logmsg string, logargs ...interface{}) {
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
hostname = dns.Fqdn(hostname)
}
vars := mux.Vars(r)
idStr := vars["id"]
ipStr := vars["ip"]
container, ok := vars["container"]
if !ok {
container = "*"
}
ip := net.ParseIP(ipStr)
if ip == nil {
reqError("Invalid IP in request", "Invalid IP in request: %s", ipStr)
ipStr, ok := vars["ip"]
ip, err := address.ParseIP(ipStr)
if ok && err != nil {
n.badRequest(w, err)
return
} else if !ok {
ipStr = "*"
}
Info.Printf("[http] Deleting %s (%s)", idStr, ipStr)
if err := db.DeleteRecord(idStr, ip); err != nil {
if _, ok := err.(LookupError); !ok {
httpErrorAndLog(
Error, w, "Internal error", http.StatusInternalServerError,
"Unexpected error from DB: %s", err)
return
}
n.Delete(hostname, container, ipStr, ip)
w.WriteHeader(204)
}
router.Methods("DELETE").Path("/name/{container}/{ip}").HandlerFunc(deleteHandler)
router.Methods("DELETE").Path("/name/{container}").HandlerFunc(deleteHandler)
router.Methods("DELETE").Path("/name").HandlerFunc(deleteHandler)
router.Methods("GET").Path("/name").Headers("Accept", "application/json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
n.RLock()
defer n.RUnlock()
if err := json.NewEncoder(w).Encode(n.entries); err != nil {
n.badRequest(w, fmt.Errorf("Error marshalling response: %v", err))
}
})
http.Handle("/", muxRouter)
address := fmt.Sprintf(":%d", port)
if err := http.ListenAndServe(address, nil); err != nil {
Error.Fatal("[http] Unable to create http listener: ", err)
}
}
-91
View File
@@ -1,91 +0,0 @@
package nameserver
import (
"fmt"
wt "github.com/weaveworks/weave/testing"
"math/rand"
"net"
"net/http"
"net/url"
"strings"
"testing"
"time"
)
func genForm(method string, url string, data url.Values) (resp *http.Response, err error) {
req, err := http.NewRequest(method, url, strings.NewReader(data.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
return http.DefaultClient.Do(req)
}
func TestHttp(t *testing.T) {
var (
containerID = "deadbeef"
testDomain = "weave.local."
successTestName = "test1." + testDomain
testAddr1 = "10.2.2.1/24"
dockerIP = "9.8.7.6"
)
zone := NewZoneDb(DefaultLocalDomain)
port := rand.Intn(10000) + 32768
fmt.Println("Http test on port", port)
go ListenHTTP("", nil, testDomain, zone, port)
time.Sleep(100 * time.Millisecond) // Allow for http server to get going
// Ask the http server to add our test address into the database
addrParts := strings.Split(testAddr1, "/")
addrURL := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, containerID, addrParts[0])
resp, err := genForm("PUT", addrURL,
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
// Check that the address is now there.
ip, _, _ := net.ParseCIDR(testAddr1)
foundIP, err := zone.LookupName(successTestName)
wt.AssertNoErr(t, err)
if !foundIP[0].IP().Equal(ip) {
t.Fatalf("Unexpected result for %s: received %s, expected %s", successTestName, foundIP, ip)
}
// Adding exactly the same address should be OK
resp, err = genForm("PUT", addrURL,
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http success response for duplicate add")
// Now try adding the same address again with a different ident --
// again should be fine
otherURL := fmt.Sprintf("http://localhost:%d/name/%s/%s", port, "other", addrParts[0])
resp, err = genForm("PUT", otherURL,
url.Values{"fqdn": {successTestName}, "local_ip": {dockerIP}, "routing_prefix": {addrParts[1]}})
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
// Delete the address
resp, err = genForm("DELETE", addrURL, nil)
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
// Check that the address is still resolvable.
x, err := zone.LookupName(successTestName)
t.Logf("Got %s", x)
wt.AssertNoErr(t, err)
// Delete the address record mentioning the other container
resp, err = genForm("DELETE", otherURL, nil)
wt.AssertNoErr(t, err)
wt.AssertStatus(t, resp.StatusCode, http.StatusOK, "http response")
// Check that the address is gone
x, err = zone.LookupName(successTestName)
t.Logf("Got %s", x)
wt.AssertErrorType(t, err, (*LookupError)(nil), "fully-removed address")
// Would like to shut down the http server at the end of this test
// but it's complicated.
// See https://groups.google.com/forum/#!topic/golang-nuts/vLHWa5sHnCE
}
-296
View File
@@ -1,296 +0,0 @@
package nameserver
import (
"bytes"
"fmt"
"github.com/miekg/dns"
"math"
"net"
"time"
)
// Portions of this code taken from github.com/armon/mdns
const (
ipv4mdns = "224.0.0.251" // link-local multicast address
mdnsPort = 5353 // mDNS assigned port
// We wait this long to hear a response from other mDNS servers on
// the network.
mDNSTimeout = 500 * time.Millisecond
MaxDuration = time.Duration(math.MaxInt64)
MailboxSize = 16
)
var (
ipv4Addr = &net.UDPAddr{
IP: net.ParseIP(ipv4mdns),
Port: mdnsPort,
}
)
type Response struct {
name string
addr net.IP
ttl int
err error
}
func (r Response) Name() string { return r.name }
func (r Response) IP() net.IP { return r.addr }
func (r Response) Priority() int { return 0 }
func (r Response) Weight() int { return 0 }
func (r Response) TTL() int { return r.ttl }
func (r Response) Equal(r2 *Response) bool {
if r.name != r2.name {
return false
}
if !r.addr.Equal(r2.addr) {
return false
}
if r.err != r2.err {
return false
}
return true
}
func (r Response) String() string {
var buf bytes.Buffer
if r.err != nil {
fmt.Fprintf(&buf, "%s", r.err)
} else {
if len(r.Name()) > 0 {
fmt.Fprintf(&buf, "%s", r.Name())
}
if !r.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", r.IP())
}
if r.ttl > 0 {
fmt.Fprintf(&buf, "(TTL:%d)", r.TTL())
}
}
return buf.String()
}
type responseInfo struct {
timeout time.Time // if no answer by this time, give up
insistent bool // insistent queries are not removed on the first reply
ch chan<- *Response
}
// Represents one query that we have sent for one name.
// If we, internally, get several requests for the same name while we have
// a query in flight, then we don't want to send more queries out.
// Invariant on responseInfos: they are in ascending order of timeout.
type inflightQuery struct {
name string
id uint16 // the DNS message ID
responseInfos []*responseInfo
}
type MDNSClient struct {
// note unorthodox use of 'Server' class in client logic - using it to
// listen on a multicast socket and call callback whenever a message comes in.
listener *dns.Server
conn *net.UDPConn
addr *net.UDPAddr
inflight map[string]*inflightQuery
actionChan chan<- MDNSAction
running bool
}
type mDNSQueryInfo struct {
name string
querytype uint16
responseCh chan<- *Response
}
func NewMDNSClient() (*MDNSClient, error) {
return &MDNSClient{
addr: ipv4Addr,
running: false,
inflight: make(map[string]*inflightQuery)}, nil
}
func (c *MDNSClient) Start(ifi *net.Interface) (err error) {
if c.running {
return nil
}
if c.conn, err = net.ListenUDP("udp4", &net.UDPAddr{IP: net.IPv4zero, Port: 0}); err != nil {
return err
}
multicast, err := LinkLocalMulticastListener(ifi)
if err != nil {
return err
}
handleMDNS := func(w dns.ResponseWriter, r *dns.Msg) {
// Don't want to handle queries here, so filter anything out that isn't a response
if len(r.Answer) > 0 {
c.ResponseCallback(r)
}
}
c.listener = &dns.Server{Unsafe: true, PacketConn: multicast, Handler: dns.HandlerFunc(handleMDNS)}
go c.listener.ActivateAndServe()
actionChan := make(chan MDNSAction, MailboxSize)
c.actionChan = actionChan
go c.actorLoop(actionChan)
return nil
}
func (c *MDNSClient) Stop() error {
if c.running {
c.actionChan <- nil
}
return nil
}
func LinkLocalMulticastListener(ifi *net.Interface) (net.PacketConn, error) {
return net.ListenMulticastUDP("udp", ifi, ipv4Addr)
}
// ACTOR client API
type MDNSAction func()
// Async
func (c *MDNSClient) SendQuery(name string, querytype uint16, insistent bool, responseCh chan<- *Response) {
c.actionChan <- func() {
query, found := c.inflight[name]
if !found {
m := new(dns.Msg)
m.SetQuestion(name, querytype)
m.RecursionDesired = false
buf, err := m.Pack()
if err != nil {
responseCh <- &Response{err: err}
close(responseCh)
return
}
query = &inflightQuery{
name: name,
id: m.Id,
}
if _, err = c.conn.WriteTo(buf, c.addr); err != nil {
responseCh <- &Response{err: err}
close(responseCh)
return
}
c.inflight[name] = query
}
info := &responseInfo{
ch: responseCh,
timeout: time.Now().Add(mDNSTimeout),
insistent: insistent,
}
// Invariant on responseInfos: they are in ascending order of
// timeout. Since we use a fixed interval from Now(), this
// must be after all existing timeouts.
query.responseInfos = append(query.responseInfos, info)
}
}
// Async - called from dns library multiplexer
func (c *MDNSClient) ResponseCallback(r *dns.Msg) {
c.actionChan <- func() {
for _, answer := range r.Answer {
var name string
var res *Response
switch rr := answer.(type) {
case *dns.A:
name = rr.Hdr.Name
res = &Response{name: name, addr: rr.A, ttl: int(rr.Hdr.Ttl)}
case *dns.PTR:
name = rr.Hdr.Name
raddr, _ := raddrToIP(name)
res = &Response{name: rr.Ptr, addr: raddr, ttl: int(rr.Hdr.Ttl)}
default:
return
}
if query, found := c.inflight[name]; found {
var newResponseInfos []*responseInfo
for _, resp := range query.responseInfos {
resp.ch <- res
// insistent queries are not removed on the first reply, but on the timeout
if resp.insistent {
newResponseInfos = append(newResponseInfos, resp)
} else {
close(resp.ch)
}
}
if len(newResponseInfos) == 0 {
delete(c.inflight, name)
} else {
query.responseInfos = newResponseInfos
}
} else {
// We've received a response that didn't match a query
// Do we want to cache it?
}
}
}
}
// ACTOR server
// Check all in-flight queries, close all that have already timed out,
// and return the duration until the next timeout
func (c *MDNSClient) checkInFlightQueries() time.Duration {
now := time.Now()
after := MaxDuration
for name, query := range c.inflight {
// Invariant on responseInfos: they are in ascending order of timeout.
numClosed := 0
for _, item := range query.responseInfos {
duration := item.timeout.Sub(now)
if duration <= 0 { // timed out
close(item.ch)
numClosed++
} else {
if duration < after {
after = duration
}
break // don't need to look at any more for this query
}
}
// Remove timed-out items from the slice
query.responseInfos = query.responseInfos[numClosed:]
if len(query.responseInfos) == 0 {
delete(c.inflight, name)
}
}
return after
}
func (c *MDNSClient) actorLoop(actionChan <-chan MDNSAction) {
timer := time.NewTimer(MaxDuration)
run := func() { timer.Reset(c.checkInFlightQueries()) }
c.running = true
for c.running {
select {
case action := <-actionChan:
if action == nil {
c.listener.Shutdown()
c.running = false
} else {
action()
run()
}
case <-timer.C:
run()
}
}
// Close all response channels at termination
for _, query := range c.inflight {
for _, item := range query.responseInfos {
close(item.ch)
}
}
}
-197
View File
@@ -1,197 +0,0 @@
package nameserver
import (
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
wt "github.com/weaveworks/weave/testing"
"log"
"net"
"testing"
"time"
)
var (
successTestName = "test1.weave."
failTestName = "test2.weave."
testAddr = net.ParseIP("9.8.7.6")
testInAddr = "6.7.8.9.in-addr.arpa."
)
func minimalServer(w dns.ResponseWriter, req *dns.Msg) {
sendAnswer := func(m *dns.Msg) {
buf, err := m.Pack()
CheckFatal(err)
if buf == nil {
log.Fatal("Nil buffer")
}
//log.Println("minimalServer sending:", buf)
// This is a bit of a kludge - per the RFC we should send responses from 5353, but that doesn't seem to work
sendconn, err := net.DialUDP("udp", nil, ipv4Addr)
CheckFatal(err)
_, err = sendconn.Write(buf)
sendconn.Close()
CheckFatal(err)
}
//log.Println("minimalServer received:", req)
if len(req.Answer) > 0 {
return // Only interested in questions.
}
if len(req.Question) != 1 {
return // We only handle single-question messages
}
if req.Question[0].Qtype == dns.TypeA && req.Question[0].Name == successTestName {
m := new(dns.Msg)
m.SetReply(req)
hdr := dns.RR_Header{Name: m.Question[0].Name, Rrtype: dns.TypeA,
Class: dns.ClassINET, Ttl: 3600}
a := &dns.A{Hdr: hdr, A: testAddr}
m.Answer = append(m.Answer, a)
sendAnswer(m)
} else if req.Question[0].Qtype == dns.TypePTR && req.Question[0].Name == testInAddr {
m := new(dns.Msg)
m.SetReply(req)
hdr := dns.RR_Header{Name: m.Question[0].Name, Rrtype: dns.TypePTR,
Class: dns.ClassINET, Ttl: 3600}
a := &dns.PTR{Hdr: hdr, Ptr: successTestName}
m.Answer = append(m.Answer, a)
sendAnswer(m)
}
}
func RunLocalMulticastServer() (*dns.Server, error) {
multicast, err := LinkLocalMulticastListener(nil)
if err != nil {
return nil, err
}
server := &dns.Server{
PacketConn: multicast,
Handler: dns.HandlerFunc(minimalServer),
ReadTimeout: 100 * time.Millisecond}
go server.ActivateAndServe()
return server, nil
}
func setup(t *testing.T) (*MDNSClient, *dns.Server, error) {
InitDefaultLogging(testing.Verbose())
server, err := RunLocalMulticastServer()
if err != nil {
t.Fatalf("Unable to run test server: %s. No default multicast interface?", err)
}
mdnsClient, err := NewMDNSClient()
wt.AssertNoErr(t, err)
err = mdnsClient.Start(nil)
wt.AssertNoErr(t, err)
return mdnsClient, server, err
}
func (c *MDNSClient) Shutdown() {
c.actionChan <- nil
}
type testContext struct {
receivedAddr net.IP
receivedCount int
channel chan *Response
}
func newTestContext() *testContext {
return &testContext{channel: make(chan *Response, 4)}
}
func (c *testContext) checkResponse(t *testing.T, channelOk bool, resp *Response) {
if !channelOk {
c.channel = nil
return
}
wt.AssertNoErr(t, resp.err)
log.Printf("Got address response %s addr %s", resp.Name(), resp.IP())
c.receivedAddr = resp.IP()
c.receivedCount++
}
func TestSimpleQuery(t *testing.T) {
log.Println("TestSimpleQuery starting")
mdnsClient, server, _ := setup(t)
defer mdnsClient.Shutdown()
defer server.Shutdown()
context := newTestContext()
// First, a test we expect to succeed
mdnsClient.SendQuery(successTestName, dns.TypeA, false, context.channel)
for resp := range context.channel {
context.checkResponse(t, true, resp)
}
if !context.receivedAddr.Equal(testAddr) || context.receivedCount != 1 {
t.Fatal("Unexpected result for", successTestName, context.receivedAddr, context.receivedCount)
}
// Now, a test we expect to time out with no responses
context = newTestContext()
mdnsClient.SendQuery("test2.weave.", dns.TypeA, false, context.channel)
for resp := range context.channel {
context.checkResponse(t, true, resp)
}
if context.receivedCount > 0 {
t.Fatal("Unexpected result for test2.weave", context.receivedAddr)
}
}
func TestParallelQuery(t *testing.T) {
log.Println("TestParallelQuery starting")
mdnsClient, server, _ := setup(t)
defer mdnsClient.Shutdown()
defer server.Shutdown()
context1 := newTestContext()
context2 := newTestContext()
go mdnsClient.SendQuery(successTestName, dns.TypeA, false, context1.channel)
go mdnsClient.SendQuery(successTestName, dns.TypeA, false, context2.channel)
timeout := time.After(2 * time.Second)
outerloop:
for context1.channel != nil || context2.channel != nil {
select {
case resp, ok := <-context1.channel:
context1.checkResponse(t, ok, resp)
case resp, ok := <-context2.channel:
context2.checkResponse(t, ok, resp)
case <-timeout:
break outerloop
}
}
if !context1.receivedAddr.Equal(testAddr) || !context2.receivedAddr.Equal(testAddr) || context1.receivedCount != 1 || context2.receivedCount != 1 {
t.Fatal("Unexpected result for", successTestName, context1.receivedAddr, context2.receivedAddr, context1.receivedCount, context2.receivedCount)
}
}
func TestAsLookup(t *testing.T) {
mdnsClient, server, _ := setup(t)
defer mdnsClient.Shutdown()
defer server.Shutdown()
ips, err := mdnsClient.LookupName(successTestName)
wt.AssertNoErr(t, err)
if !testAddr.Equal(ips[0].IP()) {
t.Fatalf("Returned address incorrect %s", ips)
}
ips, err = mdnsClient.LookupName("foo.example.com.")
wt.AssertErrorType(t, err, (*LookupError)(nil), "unknown hostname")
names, err := mdnsClient.LookupInaddr(testInAddr)
wt.AssertNoErr(t, err)
if !(successTestName == names[0].Name()) {
t.Fatalf("Expected name %s, got %s", successTestName, names)
}
}
-71
View File
@@ -1,71 +0,0 @@
package nameserver
import (
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
)
func mdnsLookup(client *MDNSClient, name string, qtype uint16, insistent bool) ([]ZoneRecord, error) {
var responses []*Response
channel := make(chan *Response)
client.SendQuery(name, qtype, insistent, channel)
for resp := range channel {
if err := resp.err; err != nil {
Debug.Printf("[mdns] Error for query type %s name %s: %s", dns.TypeToString[qtype], name, err)
return nil, err
}
Debug.Printf("[mdns] Got response name for %s-query about name '%s': name '%s', addr '%s'",
dns.TypeToString[qtype], name, resp.name, resp.addr)
if !insistent {
return []ZoneRecord{resp}, nil // non-background queries return the first response...
}
// add the response, avoiding duplicates
// TODO: replace this linear search by something better... (not a big deal as we don't expect long responses)
duplicate := false
for _, r := range responses {
if r.Equal(resp) {
duplicate = true
break
}
}
if !duplicate {
responses = append(responses, resp)
}
}
if len(responses) == 0 {
return nil, LookupError(name)
}
// convert []Response to []ZoneRecord
res := make([]ZoneRecord, len(responses))
for i, rr := range responses {
res[i] = ZoneRecord(rr)
}
return res, nil
}
// Perform a lookup for a name, returning either an IP address or an error
func (client *MDNSClient) LookupName(name string) ([]ZoneRecord, error) {
return mdnsLookup(client, name, dns.TypeA, false)
}
// Perform a lookup for an IP address, returning either a name or an error
func (client *MDNSClient) LookupInaddr(inaddr string) ([]ZoneRecord, error) {
return mdnsLookup(client, inaddr, dns.TypePTR, false)
}
// Perform lookup for a name, returning either a list of IP addresses or an error
// Insistent queries will wait up to `mDNSTimeout` milliseconds for responses
func (client *MDNSClient) InsistentLookupName(name string) ([]ZoneRecord, error) {
return mdnsLookup(client, name, dns.TypeA, true)
}
// Perform an insistent lookup for an IP address, returning either a list of names or an error
// Insistent queries will wait up to `mDNSTimeout` milliseconds for responses
func (client *MDNSClient) InsistentLookupInaddr(inaddr string) ([]ZoneRecord, error) {
return mdnsLookup(client, inaddr, dns.TypePTR, true)
}
-143
View File
@@ -1,143 +0,0 @@
package nameserver
import (
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
"net"
)
type MDNSServer struct {
localAddrs []net.Addr
sendconn *net.UDPConn
srv *dns.Server
zone Zone
running bool
}
// Create a new mDNS server
// Nothing will be done (including port bindings) until you `Start()` the server
func NewMDNSServer(zone Zone) (*MDNSServer, error) {
return &MDNSServer{zone: zone}, nil
}
// Return true if testaddr is a UDP address with IP matching my local i/f
func (s *MDNSServer) addrIsLocal(testaddr net.Addr) bool {
if udpaddr, ok := testaddr.(*net.UDPAddr); ok {
for _, localaddr := range s.localAddrs {
if ipnetlocal, ok := localaddr.(*net.IPNet); ok {
if ipnetlocal.IP.Equal(udpaddr.IP) {
return true
}
}
}
}
return false
}
// Start the mDNS server
func (s *MDNSServer) Start(ifi *net.Interface) (err error) {
// skip double initialization
if s.running {
return nil
}
// This is a bit of a kludge - per the RFC we should send responses from 5353, but that doesn't seem to work
s.sendconn, err = net.ListenUDP("udp4", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
if err != nil {
return err
}
conn, err := LinkLocalMulticastListener(ifi)
if err != nil {
return err
}
if ifi == nil {
s.localAddrs, err = net.InterfaceAddrs()
} else {
s.localAddrs, err = ifi.Addrs()
}
if err != nil {
return err
}
handleLocal := s.makeHandler(dns.TypeA,
func(zone ZoneLookup, r *dns.Msg, q *dns.Question) *dns.Msg {
if ips, err := zone.LookupName(q.Name); err == nil {
return makeAddressReply(r, q, ips)
}
return nil
})
handleReverse := s.makeHandler(dns.TypePTR,
func(zone ZoneLookup, r *dns.Msg, q *dns.Question) *dns.Msg {
if names, err := zone.LookupInaddr(q.Name); err == nil {
return makePTRReply(r, q, names)
}
return nil
})
mux := dns.NewServeMux()
mux.HandleFunc(s.zone.Domain(), handleLocal)
mux.HandleFunc(RDNSDomain, handleReverse)
s.srv = &dns.Server{
Listener: nil,
PacketConn: conn,
Handler: mux,
}
go s.srv.ActivateAndServe()
s.running = true
return err
}
// Stop the mDNS server
func (s *MDNSServer) Stop() error {
s.running = false
return s.srv.Shutdown()
}
func (s *MDNSServer) Zone() Zone {
return s.zone
}
type LookupFunc func(ZoneLookup, *dns.Msg, *dns.Question) *dns.Msg
func (s *MDNSServer) makeHandler(qtype uint16, lookup LookupFunc) dns.HandlerFunc {
return func(rw dns.ResponseWriter, r *dns.Msg) {
// Handle only questions, ignore answers. We might also ignore
// questions that arise locally (i.e., that come from an IP we
// think is local), but in the interest of avoiding
// complication, and easier testing, this is elided on the
// assumption that the client wouldn't ask if it already knew
// the answer, and if it does ask, it'll be happy to get an
// answer.
// TODO: use any Answer in the query for adding records in the Zone database...
if len(r.Answer) == 0 && len(r.Question) > 0 {
q := &r.Question[0]
if q.Qtype == qtype {
Debug.Printf("[mdns msgid %d] srv: trying to answer to mDNS query '%s'", r.MsgHdr.Id, q.Name)
if m := lookup(s.zone, r, q); m != nil {
Debug.Printf("[mdns msgid %d] srv: found local answer to mDNS query '%s'", r.MsgHdr.Id, q.Name)
if err := s.sendResponse(m); err != nil {
Warning.Printf("[mdns msgid %d] srv: error writing mDNS response to %v", r.MsgHdr.Id, s.sendconn)
} else {
Debug.Printf("[mdns msgid %d] srv: response sent: %d answers", r.MsgHdr.Id, len(m.Answer))
}
} else {
Debug.Printf("[mdns msgid %d] srv: no local answer for answering mDNS query '%s'",
r.MsgHdr.Id, q.Name)
}
}
}
}
}
func (s *MDNSServer) sendResponse(m *dns.Msg) error {
buf, err := m.Pack()
if err != nil {
return err
}
_, err = s.sendconn.WriteTo(buf, ipv4Addr)
return err
}
-120
View File
@@ -1,120 +0,0 @@
package nameserver
import (
"github.com/miekg/dns"
. "github.com/weaveworks/weave/common"
wt "github.com/weaveworks/weave/testing"
"net"
"testing"
"time"
)
func TestServerSimpleQuery(t *testing.T) {
var (
testRecord1 = Record{"test.weave.local.", net.ParseIP("10.20.20.10"), 0, 0, 0}
testRecord2 = Record{"test.weave.local.", net.ParseIP("10.20.20.20"), 0, 0, 0}
testInAddr1 = "10.20.20.10.in-addr.arpa."
)
InitDefaultLogging(testing.Verbose())
Info.Println("TestServerSimpleQuery starting")
mzone := newMockedZoneWithRecords([]ZoneRecord{testRecord1, testRecord2})
mdnsServer, err := NewMDNSServer(mzone)
wt.AssertNoErr(t, err)
err = mdnsServer.Start(nil)
wt.AssertNoErr(t, err)
defer mdnsServer.Stop()
var receivedAddrs []net.IP
receivedName := ""
recvChan := make(chan interface{})
receivedCount := 0
// Implement a minimal listener for responses
multicast, err := LinkLocalMulticastListener(nil)
wt.AssertNoErr(t, err)
handleMDNS := func(w dns.ResponseWriter, r *dns.Msg) {
// Only handle responses here
if len(r.Answer) > 0 {
t.Logf("Received %d answer(s)", len(r.Answer))
for _, answer := range r.Answer {
switch rr := answer.(type) {
case *dns.A:
t.Logf("... A:\n%+v", rr)
receivedAddrs = append(receivedAddrs, rr.A)
receivedCount++
case *dns.PTR:
t.Logf("... PTR:\n%+v", rr)
receivedName = rr.Ptr
receivedCount++
}
}
recvChan <- "ok"
}
}
sendQuery := func(name string, querytype uint16) {
receivedAddrs = make([]net.IP, 0)
receivedName = ""
receivedCount = 0
recvChan = make(chan interface{})
m := new(dns.Msg)
m.SetQuestion(name, querytype)
m.RecursionDesired = false
buf, err := m.Pack()
wt.AssertNoErr(t, err)
conn, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
wt.AssertNoErr(t, err)
Debug.Printf("Sending UDP packet to %s", ipv4Addr)
_, err = conn.WriteTo(buf, ipv4Addr)
wt.AssertNoErr(t, err)
Debug.Printf("Waiting for response")
select {
case <-recvChan:
return
case <-time.After(100 * time.Millisecond):
Debug.Printf("Timeout while waiting for response")
return
}
}
listener := &dns.Server{
Unsafe: true,
PacketConn: multicast,
Handler: dns.HandlerFunc(handleMDNS),
ReadTimeout: 100 * time.Millisecond}
go listener.ActivateAndServe()
defer listener.Shutdown()
time.Sleep(100 * time.Millisecond) // Allow for server to get going
Debug.Printf("Checking that we get 2 IPs fo name '%s' [A]", testRecord1.Name())
sendQuery(testRecord1.Name(), dns.TypeA)
if receivedCount != 2 {
t.Fatalf("Unexpected result count %d for %s", receivedCount, testRecord1.Name())
}
if !(receivedAddrs[0].Equal(testRecord1.IP()) || receivedAddrs[0].Equal(testRecord2.IP())) {
t.Fatalf("Unexpected result %s for %s", receivedAddrs, testRecord1.Name())
}
if !(receivedAddrs[1].Equal(testRecord1.IP()) || receivedAddrs[1].Equal(testRecord2.IP())) {
t.Fatalf("Unexpected result %s for %s", receivedAddrs, testRecord1.Name())
}
Debug.Printf("Checking that 'testfail.weave.' [A] gets no answers")
sendQuery("testfail.weave.", dns.TypeA)
if receivedCount != 0 {
t.Fatalf("Unexpected result count %d for testfail.weave", receivedCount)
}
Debug.Printf("Checking that '%s' [PTR] gets one name", testInAddr1)
sendQuery(testInAddr1, dns.TypePTR)
if receivedCount != 1 {
t.Fatalf("Expected an answer to %s, got %d answers", testInAddr1, receivedCount)
} else if !(testRecord1.Name() == receivedName) {
t.Fatalf("Expected answer %s to query for %s, got %s", testRecord1.Name(), testInAddr1, receivedName)
}
}
Loaded 100 of 454 files, more files were not shown because too many files have changed in this diff. Show more