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.
This commit is contained in:
Tom Wilkie committed 2015-07-14 16:00:38 +00:00
1 parent 01f7201a9e
commit 8b061fd555
32 files changed
+1528 -329

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ NAME=seetwo.weave.local
start_suite "Resolve names on a single host"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
+35
View File
@@ -0,0 +1,35 @@
#! /bin/bash
. ./config.sh
C1=10.2.3.78
C2=10.2.3.34
C2a=10.2.3.35
C2b=10.2.3.36
UNIVERSE=10.2.4.0/24
NAME2=seetwo.weave.local
NAME4=seefour.weave.local
start_suite "Resolve names across hosts"
weave_on $HOST1 launch --ipalloc-range $UNIVERSE
weave_on $HOST2 launch --ipalloc-range $UNIVERSE $HOST1
start_container $HOST2 $C2/24 --name=c2 -h $NAME2
start_container_with_dns $HOST1 $C1/24 --name=c1
assert_dns_record $HOST1 c1 $NAME2 $C2
# resolution for names mapped to multiple addresses
weave_on $HOST2 dns-add $C2a c2 -h $NAME2
weave_on $HOST2 dns-add $C2b c2 -h $NAME2
assert_dns_record $HOST1 c1 $NAME2 $C2 $C2a $C2b
# resolution when containers addresses come from IPAM
start_container $HOST2 --name=c4 -h $NAME4
start_container_with_dns $HOST1 --name=c3
C4=$(container_ip $HOST2 c4)
assert_dns_record $HOST1 c3 $NAME4 $C4
assert_raises "exec_on $HOST1 c3 getent hosts 8.8.8.8 | grep google"
end_suite
-61
View File
@@ -1,61 +0,0 @@
#! /bin/bash
. ./config.sh
C1=10.2.3.78
C2=10.2.3.34
C2a=10.2.3.35
C2b=10.2.3.36
UNIVERSE=10.2.4.0/24
NAME2=seetwo.weave.local
NAME4=seefour.weave.local
start() {
launch_dns_on $HOST1 $1 >/dev/null
launch_dns_on $HOST2 $2 >/dev/null
}
stop() {
weave_on $HOST1 stop-dns
weave_on $HOST2 stop-dns
}
check() {
start $1 $2
assert_dns_record $HOST1 c1 $NAME2 $C2
assert_raises "exec_on $HOST1 c1 getent hosts 8.8.8.8 | grep google"
stop
}
start_suite "Resolve names across hosts (with and without IPAM), and repopulate on restart"
weave_on $HOST1 launch-router --ipalloc-range $UNIVERSE
weave_on $HOST2 launch-router --ipalloc-range $UNIVERSE $HOST1
start_container $HOST2 $C2/24 --name=c2 -h $NAME2
start_container_with_dns $HOST1 $C1/24 --name=c1
# resolution when DNS is launched with various ways of obtaining an IP
# NB: this also tests re-population on DNS restart
check ip:10.2.254.1/24 ip:10.2.254.2/24
check net:10.2.4.128/25 net:10.2.4.128/25
check net:default net:default
check
start 10.2.254.1/24 10.2.254.2/24
# resolution for names mapped to multiple addresses
weave_on $HOST2 dns-add $C2a c2 -h $NAME2
weave_on $HOST2 dns-add $C2b c2 -h $NAME2
assert_dns_record $HOST1 c1 $NAME2 $C2 $C2a $C2b
# resolution when containers addresses come from IPAM
start_container $HOST2 --name=c4 -h $NAME4
start_container_with_dns $HOST1 --name=c3
C4=$(container_ip $HOST2 c4)
assert_dns_record $HOST1 c3 $NAME4 $C4
assert_raises "exec_on $HOST1 c3 getent hosts 8.8.8.8 | grep google"
stop
end_suite
+14 -1
View File
@@ -9,7 +9,20 @@ NAME=seetwo.$DOMAIN
start_suite "Resolve names in custom domain"
launch_dns_on $HOST1 10.2.254.1/24 --domain $DOMAIN.
# Check with a trailing dot on domain
weave_on $HOST1 launch --dns-domain $DOMAIN.
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
assert_dns_record $HOST1 c1 $NAME $C2
rm_containers $HOST1 c1
rm_containers $HOST1 c2
weave_on $HOST1 stop
# Check without a trailing dot on domain
weave_on $HOST1 launch --dns-domain $DOMAIN
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
+1 -1
View File
@@ -11,7 +11,7 @@ NAME=seeone.$DOMAIN
start_suite "Resolve unqualified names"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch
start_container $HOST1 $C1/24 --name=c1 -h $NAME
start_container_with_dns $HOST1 $C2/24 --name=c2 -h seetwo.$DOMAIN
+1 -1
View File
@@ -10,7 +10,7 @@ NAME3=seethree.weave.local
start_suite "Add and remove names on a single host"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch
start_container $HOST1 --without-dns $C2/24 --name=c2
start_container_with_dns $HOST1 $C1/24 --name=c1
+25
View File
@@ -0,0 +1,25 @@
#! /bin/bash
. ./config.sh
C1=10.2.0.78
C2=10.2.0.34
NAME=seetwo.weave.local
start_suite "Restart Weave, check for repopulation"
weave_on $HOST1 launch
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
assert_dns_record $HOST1 c1 $NAME $C2
assert_raises "exec_on $HOST1 c1 dig MX $NAME | grep -q 'status: NXDOMAIN'"
weave_on $HOST1 stop
weave_on $HOST1 launch
assert_dns_record $HOST1 c1 $NAME $C2
assert_raises "exec_on $HOST1 c1 dig MX $NAME | grep -q 'status: NXDOMAIN'"
end_suite
+1 -1
View File
@@ -16,7 +16,7 @@ check() {
start_suite "Automatic DNS record removal on container death"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch
start_container_with_dns $HOST1 $C1/24 --name=c1
start_container $HOST1 $C2/24 $DOPTS
+2 -9
View File
@@ -20,19 +20,12 @@ assert_resolution() {
start_suite "With or without DNS test"
# Assert behaviour without weaveDNS running
weave_on $HOST1 launch-router
start_container $HOST1 $TARGET_IP/24 --name c2 -h $TARGET
DNS_IP=$(weave_on $HOST1 docker-bridge-ip)
# Assert behaviour without weaveDNS running
assert_no_resolution --without-dns
assert_no_resolution
assert_no_resolution --with-dns
weave_on $HOST1 launch-dns 10.2.254.1/24 $WEAVEDNS_ARGS
start_container $HOST1 $TARGET_IP/24 --name c2 -h $TARGET
# Assert behaviour with weaveDNS running
assert_no_resolution --without-dns
assert_resolution
assert_resolution --with-dns
+1 -1
View File
@@ -4,7 +4,7 @@
start_suite "Resolve a non-weave address"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch-router
start_container_with_dns $HOST1 10.2.1.5/24 --name=c1
+23
View File
@@ -0,0 +1,23 @@
#! /bin/bash
. ./config.sh
NAME=seetwo.weave.local
N=50
start_suite "Add $N dns entries and check we get the right response."
weave_on $HOST1 launch
CID=$(start_container_with_dns $HOST1 10.2.1.0/24 --name=c0)
IPS=""
for i in $(seq $N); do
IPS="$IPS 10.2.1.$i"
done
weave_on $HOST1 dns-add $IPS $CID -h $NAME
assert_dns_record $HOST1 c0 $NAME $IPS
assert_raises "exec_on $HOST1 c0 dig MX $NAME | grep -q 'status: NXDOMAIN'"
end_suite
-1
View File
@@ -74,7 +74,6 @@ start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr argume
# lowest available address in the subnet
weave_on $HOST1 launch-router --ipalloc-range 10.2.3.0/24
launch_dns_on $HOST1 10.254.254.254/24
# Run container with three cidrs
CID=$(start_container $HOST1 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 --name=multicidr -h $NAME | cut -b 1-12)
+1 -1
View File
@@ -37,7 +37,7 @@ weave_on $HOST1 launch-proxy
assert_no_resolution
# Assert behaviour with weaveDNS running
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch-router
boot_containers
assert_dns_record $HOST1 c1 $C2_NAME $C2
assert_dns_record $HOST1 c2 $C1_NAME $C1
+1 -2
View File
@@ -15,8 +15,7 @@ start_container() {
start_suite "Resolve unqualified names"
weave_on $HOST1 launch-dns 10.2.254.1/24
weave_on $HOST1 launch-proxy
weave_on $HOST1 launch
start_container -e WEAVE_CIDR=$C1/24 --name=c1 -h $NAME
start_container -e WEAVE_CIDR=$C2/24 --name=c2 -h seetwo.$DOMAIN
+1 -2
View File
@@ -8,8 +8,7 @@ NAME=seetwo.weave.local
start_suite "Proxy restart reattaches networking to containers"
launch_dns_on $HOST1 10.2.254.1/24
weave_on $HOST1 launch-proxy --with-dns
weave_on $HOST1 launch
proxy docker_on $HOST1 run -e WEAVE_CIDR=$C2/24 -dt --name=c2 -h $NAME $SMALL_IMAGE /bin/sh
proxy docker_on $HOST1 run -e WEAVE_CIDR=$C1/24 -dt --name=c1 $DNS_IMAGE /bin/sh
-6
View File
@@ -133,12 +133,6 @@ exec_on() {
docker -H tcp://$host:$DOCKER_PORT exec $container "$@"
}
launch_dns_on() {
host=$1
shift 1
weave_on $host launch-dns $@ $WEAVEDNS_ARGS
}
start_container() {
host=$1
shift 1