Merge pull request #900 from rade/762_dns_ipam

LGTM.  Closes #762.
This commit is contained in:
Bryan Boreham committed 2015-06-12 14:21:07 +01:00
commit 29c988d42f
4 files changed
+49 -43

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ Weave detects when a container has exited and releases its
automatically allocated addresses so they can be re-used. automatically allocated addresses so they can be re-used.
Automatic IP address assignment is available for the `run`, `start`, Automatic IP address assignment is available for the `run`, `start`,
`attach`, `detach`, `expose` and `hide` commands. `attach`, `detach`, `expose`, `hide` and `launch-dns` commands.
## <a name="initialisation"></a>Initialisation ## <a name="initialisation"></a>Initialisation
+42 -18
View File
@@ -3,35 +3,59 @@
. ./config.sh . ./config.sh
C1=10.2.3.78 C1=10.2.3.78
C2_1=10.2.3.34 C2=10.2.3.34
C2_2=10.2.3.35 C2a=10.2.3.35
C2_3=10.2.3.36 C2b=10.2.3.36
UNIVERSE=10.2.4.0/24 UNIVERSE=10.2.4.0/24
NAME2=seetwo.weave.local NAME2=seetwo.weave.local
NAME4=seefour.weave.local NAME4=seefour.weave.local
start_suite "Resolve names across hosts (with and without IPAM)" start() {
weave_on $HOST1 launch-dns $1 >/dev/null
weave_on $HOST2 launch-dns $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 -iprange $UNIVERSE weave_on $HOST1 launch -iprange $UNIVERSE
weave_on $HOST2 launch -iprange $UNIVERSE $HOST1 weave_on $HOST2 launch -iprange $UNIVERSE $HOST1
weave_on $HOST1 launch-dns 10.2.254.1/24 start_container $HOST2 $C2/24 --name=c2 -h $NAME2
weave_on $HOST2 launch-dns 10.2.254.2/24
start_container $HOST2 $C2_1/24 --name=c2 -h $NAME2
start_container $HOST2 --name=c4 -h $NAME4
weave_on $HOST2 dns-add $C2_2 c2 -h $NAME2
weave_on $HOST2 dns-add $C2_3 c2 -h $NAME2
start_container_with_dns $HOST1 $C1/24 --name=c1 start_container_with_dns $HOST1 $C1/24 --name=c1
start_container_with_dns $HOST1 --name=c3
# 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) C4=$(container_ip $HOST2 c4)
assert_dns_record $HOST1 c1 $NAME2 $C2_1 $C2_2 $C2_3
assert_dns_record $HOST1 c3 $NAME4 $C4 assert_dns_record $HOST1 c3 $NAME4 $C4
assert_raises "exec_on $HOST1 c1 getent hosts 8.8.8.8 | grep google"
assert_raises "exec_on $HOST1 c3 getent hosts 8.8.8.8 | grep google" assert_raises "exec_on $HOST1 c3 getent hosts 8.8.8.8 | grep google"
stop
end_suite end_suite
-18
View File
@@ -1,18 +0,0 @@
#! /bin/bash
. ./config.sh
C1=10.2.0.78
C2=10.2.0.34
NAME=seetwo.weave.local
start_suite "Repopulation on weaveDNS restart"
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
weave_on $HOST1 launch-dns 10.2.254.1/24
assert_dns_record $HOST1 c1 $NAME $C2
end_suite
+6 -6
View File
@@ -28,7 +28,7 @@ usage() {
echo "weave setup" echo "weave setup"
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]" echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..." echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
echo "weave launch-dns <cidr>" echo "weave launch-dns [<addr>]"
echo "weave launch-proxy [-D <endpoint>] [-H <endpoint>] [--with-dns] [--with-ipam]" echo "weave launch-proxy [-D <endpoint>] [-H <endpoint>] [--with-dns] [--with-ipam]"
echo "weave connect [--replace] [<peer> ...]" echo "weave connect [--replace] [<peer> ...]"
echo "weave forget <peer> ..." echo "weave forget <peer> ..."
@@ -1009,10 +1009,9 @@ case "$COMMAND" in
echo $CONTAINER echo $CONTAINER
;; ;;
launch-dns) launch-dns)
[ $# -gt 0 ] || usage collect_cidr_args "$@"
CIDR=$1 [ $CIDR_ARG_COUNT -lt 2 ] || usage
validate_cidr $CIDR shift $CIDR_ARG_COUNT
shift 1
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
create_bridge create_bridge
docker_bridge_ip docker_bridge_ip
@@ -1023,7 +1022,8 @@ case "$COMMAND" in
-p $DOCKER_BRIDGE_IP:53:53/udp \ -p $DOCKER_BRIDGE_IP:53:53/udp \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
$WEAVEDNS_DOCKER_ARGS $DNS_IMAGE -iface $CONTAINER_IFNAME "$@") $WEAVEDNS_DOCKER_ARGS $DNS_IMAGE -iface $CONTAINER_IFNAME "$@")
with_container_netns_or_die $DNS_CONTAINER attach $CIDR ipam_cidrs $DNS_CONTAINER $CIDR_ARGS
with_container_netns_or_die $DNS_CONTAINER attach $ALL_CIDRS
populate_dns populate_dns
echo $DNS_CONTAINER echo $DNS_CONTAINER
;; ;;