diff options
author | 2023-03-24 20:52:44 +0800 | |
---|---|---|
committer | 2023-03-24 08:52:44 -0400 | |
commit | 47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b (patch) | |
tree | fd93da074caa38ae954a8d8bacd241aefc401124 /plugin/k8s_external/external.go | |
parent | 48c40ae1cd4e0c0a2b6aaf0141c7111822ac7cd3 (diff) | |
download | coredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.tar.gz coredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.tar.zst coredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.zip |
plugin/k8s_extenral: Supports fallthrough option (#5959)
* Add fallthrough option to k8s_external plugin to allow transitioning control to the next plugin if the domain is not found
* Exit on start up if required plugin is not present.
Signed-off-by: vanceli <vanceli@tencent.com>
---------
Signed-off-by: vanceli <vanceli@tencent.com>
Co-authored-by: vanceli <vanceli@tencent.com>
Diffstat (limited to 'plugin/k8s_external/external.go')
-rw-r--r-- | plugin/k8s_external/external.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugin/k8s_external/external.go b/plugin/k8s_external/external.go index 2cbf88555..e56784ad7 100644 --- a/plugin/k8s_external/external.go +++ b/plugin/k8s_external/external.go @@ -16,6 +16,7 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/etcd/msg" + "github.com/coredns/coredns/plugin/pkg/fall" "github.com/coredns/coredns/plugin/pkg/upstream" "github.com/coredns/coredns/request" @@ -39,6 +40,7 @@ type Externaler interface { type External struct { Next plugin.Handler Zones []string + Fall fall.F hostmaster string apex string @@ -68,10 +70,6 @@ func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r) } - if e.externalFunc == nil { - return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r) - } - state.Zone = zone for _, z := range e.Zones { // TODO(miek): save this in the External struct. @@ -93,6 +91,10 @@ func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms m.Authoritative = true if len(svc) == 0 { + if e.Fall.Through(state.Name()) && rcode == dns.RcodeNameError { + return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r) + } + m.Rcode = rcode m.Ns = []dns.RR{e.soa(state)} w.WriteMsg(m) |