Skip to content

Commit

Permalink
fix(coredns) Add FORMERR and NOTIMP in alternate default coredns conf (
Browse files Browse the repository at this point in the history
…#2756)

Currently when using the builtin DNS coreDNS would forward the NOTIMP
error from Envoy rather than fallingback to the original DNS

This makes sure that FORMERR and NOTIMP responses from Envoy
will be retried against the original DNS server

Signed-off-by: Charly Molter <charly.molter@konghq.com>
  • Loading branch information
lahabana authored Sep 13, 2021
1 parent 858034a commit c9bf4d1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/kuma-dp/pkg/dataplane/dnsserver/dnsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ type Opts struct {
Quit chan struct{}
}

// DefaultCoreFileTemplate defines the template to use to configure coreDNS to use the envoy dns filter.
const DefaultCoreFileTemplate = `.:{{ .CoreDNSPort }} {
forward . 127.0.0.1:{{ .EnvoyDNSPort }}
alternate NXDOMAIN,SERVFAIL,REFUSED . /etc/resolv.conf
# We want all requests to be sent to the Envoy DNS Filter, unsuccessful responses should be forwarded to the original DNS server.
# For example: requests other than A, AAAA and SRV will return NOTIMP when hitting the envoy filter and should be sent to the original DNS server.
# Codes from: https://github.com/miekg/dns/blob/master/msg.go#L138
alternate NOTIMP,FORMERR,NXDOMAIN,SERVFAIL,REFUSED . /etc/resolv.conf
prometheus localhost:{{ .PrometheusPort }}
errors
}
Expand Down
5 changes: 4 additions & 1 deletion app/kuma-dp/pkg/dataplane/dnsserver/dnsserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ var _ = Describe("DNS Server", func() {
// and
Expect(string(actual)).To(Equal(`.:16001 {
forward . 127.0.0.1:16002
alternate NXDOMAIN,SERVFAIL,REFUSED . /etc/resolv.conf
# We want all requests to be sent to the Envoy DNS Filter, unsuccessful responses should be forwarded to the original DNS server.
# For example: requests other than A, AAAA and SRV will return NOTIMP when hitting the envoy filter and should be sent to the original DNS server.
# Codes from: https://github.com/miekg/dns/blob/master/msg.go#L138
alternate NOTIMP,FORMERR,NXDOMAIN,SERVFAIL,REFUSED . /etc/resolv.conf
prometheus localhost:16003
errors
}
Expand Down
16 changes: 12 additions & 4 deletions app/kuma-dp/pkg/dataplane/envoy/envoy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -116,10 +117,17 @@ var _ = Describe("Envoy", func() {
// then
Expect(err).ToNot(HaveOccurred())
// and
Expect(strings.TrimSpace(buf.String())).To(Equal(
fmt.Sprintf("--config-path %s --drain-time-s 15 --disable-hot-restart --log-level off --bootstrap-version 2 --cpuset-threads",
expectedConfigFile)),
)
if runtime.GOOS == "linux" {
Expect(strings.TrimSpace(buf.String())).To(Equal(
fmt.Sprintf("--config-path %s --drain-time-s 15 --disable-hot-restart --log-level off --bootstrap-version 2 --cpuset-threads",
expectedConfigFile)),
)
} else {
Expect(strings.TrimSpace(buf.String())).To(Equal(
fmt.Sprintf("--config-path %s --drain-time-s 15 --disable-hot-restart --log-level off --bootstrap-version 2",
expectedConfigFile)),
)
}

By("verifying the contents Envoy config file")
// when
Expand Down
2 changes: 1 addition & 1 deletion pkg/xds/cache/cla/testdata/cla.get.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion pkg/xds/cache/cla/testdata/cla.get.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
]
}
]
}
}

0 comments on commit c9bf4d1

Please sign in to comment.