From 427b6d29028b96a5314e6941245c7f2b0f523dcf Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Thu, 21 Apr 2016 15:49:29 +0100 Subject: [PATCH] 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. --- test/100_cross_hosts_2_test.sh | 2 ++ weave | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/100_cross_hosts_2_test.sh b/test/100_cross_hosts_2_test.sh index 0eab1027..bc6b0a40 100755 --- a/test/100_cross_hosts_2_test.sh +++ b/test/100_cross_hosts_2_test.sh @@ -30,6 +30,8 @@ assert_raises "exec_on $HOST1 c5 $PING $C6" # check that restart retains the same IP, and reclaims it in IPAM weave_on $HOST2 restart c6 assert_raises "exec_on $HOST1 c5 $PING $C6" +# check that restart does not create any additional DNS entry +assert "weave_on $HOST2 report -f \"{{len .DNS.Entries}}\"" "6" sleep 31 # past the IPAM timeout start_container $HOST2 net:$SUBNET_2 --name=c7 C7=$(container_ip $HOST2 c7) diff --git a/weave b/weave index 5cbd0a0f..53ca7ec0 100755 --- a/weave +++ b/weave @@ -2179,8 +2179,8 @@ EOF for CIDR in $ALL_CIDRS ; do call_weave PUT /ip/$CONTAINER/$CIDR?check-alive=true done - with_container_netns_or_die $1 attach $ALL_CIDRS - when_weave_running with_container_fqdn $1 put_dns_fqdn $ALL_CIDRS + with_container_netns_or_die $CONTAINER attach $ALL_CIDRS + when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS echo $RES ;; dns-add)