Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1358 from weaveworks/1357-dns-reverse-tombstone
Browse files Browse the repository at this point in the history
Make reverse dns lookups honor tombstones.
  • Loading branch information
tomwilkie committed Aug 27, 2015
2 parents f5918a3 + 914c884 commit 42b64f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nameserver/nameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (n *Nameserver) ReverseLookup(ip address.Address) (string, error) {
defer n.RUnlock()

match, err := n.entries.first(func(e *Entry) bool {
return e.Addr == ip
return e.Tombstone == 0 && e.Addr == ip
})
if err != nil {
return "", err
Expand Down
23 changes: 23 additions & 0 deletions test/265_dns_reverse_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash

. ./config.sh

IP=10.2.0.67

start_suite "Reverse DNS test"

weave_on $HOST1 launch
start_container_with_dns $HOST1 --name=c1

# We try names in alphabetical order; this is because the
# nameserver keeps entries sorted by hostname then address,
# so by starting with acontainer then trying bcontainer,
# we're guaranteed to have to ignore a tombstone to get the
# right result.
for name in acontainer bcontainer ccontainer; do
start_container $HOST1 $IP/24 --name=$name
assert_dns_record $HOST1 c1 $name.weave.local $IP
rm_containers $HOST1 $name
done

end_suite
6 changes: 3 additions & 3 deletions test/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ container_ip() {

# assert_dns_record <host> <container> <name> [<ip> ...]
assert_dns_record() {
host=$1
container=$2
name=$3
local host=$1
local container=$2
local name=$3
shift 3
exp_ips_regex=$(echo "$@" | sed -e 's/ /\\\|/g')

Expand Down

0 comments on commit 42b64f8

Please sign in to comment.