diff --git a/test/260_dns_removal_test.sh b/test/260_dns_removal_test.sh new file mode 100755 index 00000000..3816a474 --- /dev/null +++ b/test/260_dns_removal_test.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +. ./config.sh + +C1=10.2.0.67 +C2=10.2.0.43 +NAME=seetwo.weave.local + +DOPTS="--name=c2 -h $NAME" + +check() { + assert_dns_record $HOST1 c1 $NAME $C2 + docker_on $HOST1 rm -f c2 >/dev/null + assert_no_dns_record $HOST1 c1 $NAME +} + +start_suite "Automatic DNS record removal on container death" + +weave_on $HOST1 launch-dns 10.2.254.1/24 --no-cache +start_container_with_dns $HOST1 $C1/24 --name=c1 + +start_container $HOST1 $C2/24 $DOPTS +check + +docker_on $HOST1 run $DOPTS -dt $SMALL_IMAGE /bin/sh +weave_on $HOST1 attach $C2/24 c2 +check + +docker_on $HOST1 create $DOPTS -t $SMALL_IMAGE /bin/sh +weave_on $HOST1 start $C2/24 c2 +check + +end_suite diff --git a/weave b/weave index 92f0212b..40f8e2a9 100755 --- a/weave +++ b/weave @@ -1048,12 +1048,13 @@ case "$COMMAND" in collect_cidr_args "$@" shift $CIDR_COUNT [ $# -eq 1 ] || usage - CONTAINER=$(docker start $1) + RES=$(docker start $1) + CONTAINER=$(container_id $1) create_bridge get_ipam_cidr $CONTAINER with_container_netns_or_die $CONTAINER attach $CIDR_ARGS when_dns_running with_container_fqdn $CONTAINER put_dns_fqdn $CIDR_ARGS - echo $CONTAINER + echo $RES ;; attach) collect_cidr_args "$@"