aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/kubernetes')
-rw-r--r--plugin/kubernetes/handler.go28
-rw-r--r--plugin/kubernetes/kubernetes.go11
-rw-r--r--plugin/kubernetes/kubernetes_test.go3
-rw-r--r--plugin/kubernetes/reverse.go5
-rw-r--r--plugin/kubernetes/xfr.go2
5 files changed, 26 insertions, 23 deletions
diff --git a/plugin/kubernetes/handler.go b/plugin/kubernetes/handler.go
index 8952de45a..324e08da6 100644
--- a/plugin/kubernetes/handler.go
+++ b/plugin/kubernetes/handler.go
@@ -11,7 +11,7 @@ import (
// ServeDNS implements the plugin.Handler interface.
func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
- state := request.Request{W: w, Req: r, Context: ctx}
+ state := request.Request{W: w, Req: r}
qname := state.QName()
zone := plugin.Zones(k.Zones).Matches(qname)
@@ -29,24 +29,24 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
switch state.QType() {
case dns.TypeA:
- records, err = plugin.A(&k, zone, state, nil, plugin.Options{})
+ records, err = plugin.A(ctx, &k, zone, state, nil, plugin.Options{})
case dns.TypeAAAA:
- records, err = plugin.AAAA(&k, zone, state, nil, plugin.Options{})
+ records, err = plugin.AAAA(ctx, &k, zone, state, nil, plugin.Options{})
case dns.TypeTXT:
- records, err = plugin.TXT(&k, zone, state, plugin.Options{})
+ records, err = plugin.TXT(ctx, &k, zone, state, plugin.Options{})
case dns.TypeCNAME:
- records, err = plugin.CNAME(&k, zone, state, plugin.Options{})
+ records, err = plugin.CNAME(ctx, &k, zone, state, plugin.Options{})
case dns.TypePTR:
- records, err = plugin.PTR(&k, zone, state, plugin.Options{})
+ records, err = plugin.PTR(ctx, &k, zone, state, plugin.Options{})
case dns.TypeMX:
- records, extra, err = plugin.MX(&k, zone, state, plugin.Options{})
+ records, extra, err = plugin.MX(ctx, &k, zone, state, plugin.Options{})
case dns.TypeSRV:
- records, extra, err = plugin.SRV(&k, zone, state, plugin.Options{})
+ records, extra, err = plugin.SRV(ctx, &k, zone, state, plugin.Options{})
case dns.TypeSOA:
- records, err = plugin.SOA(&k, zone, state, plugin.Options{})
+ records, err = plugin.SOA(ctx, &k, zone, state, plugin.Options{})
case dns.TypeNS:
if state.Name() == zone {
- records, extra, err = plugin.NS(&k, zone, state, plugin.Options{})
+ records, extra, err = plugin.NS(ctx, &k, zone, state, plugin.Options{})
break
}
fallthrough
@@ -54,7 +54,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
k.Transfer(ctx, state)
default:
// Do a fake A lookup, so we can distinguish between NODATA and NXDOMAIN
- _, err = plugin.A(&k, zone, state, nil, plugin.Options{})
+ _, err = plugin.A(ctx, &k, zone, state, nil, plugin.Options{})
}
if k.IsNameError(err) {
@@ -63,16 +63,16 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
}
if !k.APIConn.HasSynced() {
// If we haven't synchronized with the kubernetes cluster, return server failure
- return plugin.BackendError(&k, zone, dns.RcodeServerFailure, state, nil /* err */, plugin.Options{})
+ return plugin.BackendError(ctx, &k, zone, dns.RcodeServerFailure, state, nil /* err */, plugin.Options{})
}
- return plugin.BackendError(&k, zone, dns.RcodeNameError, state, nil /* err */, plugin.Options{})
+ return plugin.BackendError(ctx, &k, zone, dns.RcodeNameError, state, nil /* err */, plugin.Options{})
}
if err != nil {
return dns.RcodeServerFailure, err
}
if len(records) == 0 {
- return plugin.BackendError(&k, zone, dns.RcodeSuccess, state, nil, plugin.Options{})
+ return plugin.BackendError(ctx, &k, zone, dns.RcodeSuccess, state, nil, plugin.Options{})
}
m := new(dns.Msg)
diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go
index 10f058c5a..df9d67060 100644
--- a/plugin/kubernetes/kubernetes.go
+++ b/plugin/kubernetes/kubernetes.go
@@ -2,6 +2,7 @@
package kubernetes
import (
+ "context"
"errors"
"fmt"
"net"
@@ -86,7 +87,7 @@ var (
)
// Services implements the ServiceBackend interface.
-func (k *Kubernetes) Services(state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) {
+func (k *Kubernetes) Services(ctx context.Context, state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) {
// We're looking again at types, which we've already done in ServeDNS, but there are some types k8s just can't answer.
switch state.QType() {
@@ -119,7 +120,7 @@ func (k *Kubernetes) Services(state request.Request, exact bool, opt plugin.Opti
return []msg.Service{svc}, nil
}
- s, e := k.Records(state, false)
+ s, e := k.Records(ctx, state, false)
// SRV for external services is not yet implemented, so remove those records.
@@ -141,8 +142,8 @@ func (k *Kubernetes) Services(state request.Request, exact bool, opt plugin.Opti
func (k *Kubernetes) primaryZone() string { return k.Zones[k.primaryZoneIndex] }
// Lookup implements the ServiceBackend interface.
-func (k *Kubernetes) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) {
- return k.Upstream.Lookup(state, name, typ)
+func (k *Kubernetes) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error) {
+ return k.Upstream.Lookup(ctx, state, name, typ)
}
// IsNameError implements the ServiceBackend interface.
@@ -236,7 +237,7 @@ func (k *Kubernetes) InitKubeCache() (err error) {
}
// Records looks up services in kubernetes.
-func (k *Kubernetes) Records(state request.Request, exact bool) ([]msg.Service, error) {
+func (k *Kubernetes) Records(ctx context.Context, state request.Request, exact bool) ([]msg.Service, error) {
r, e := parseRequest(state)
if e != nil {
return nil, e
diff --git a/plugin/kubernetes/kubernetes_test.go b/plugin/kubernetes/kubernetes_test.go
index 26f3747ee..6d078f67e 100644
--- a/plugin/kubernetes/kubernetes_test.go
+++ b/plugin/kubernetes/kubernetes_test.go
@@ -1,6 +1,7 @@
package kubernetes
import (
+ "context"
"testing"
"github.com/coredns/coredns/plugin"
@@ -281,7 +282,7 @@ func TestServices(t *testing.T) {
Req: &dns.Msg{Question: []dns.Question{{Name: test.qname, Qtype: test.qtype}}},
Zone: "interwebs.test.", // must match from k.Zones[0]
}
- svcs, e := k.Services(state, false, plugin.Options{})
+ svcs, e := k.Services(context.TODO(), state, false, plugin.Options{})
if e != nil {
t.Errorf("Test %d: got error '%v'", i, e)
continue
diff --git a/plugin/kubernetes/reverse.go b/plugin/kubernetes/reverse.go
index 5873bcbc8..12b67ff30 100644
--- a/plugin/kubernetes/reverse.go
+++ b/plugin/kubernetes/reverse.go
@@ -1,6 +1,7 @@
package kubernetes
import (
+ "context"
"strings"
"github.com/coredns/coredns/plugin"
@@ -10,11 +11,11 @@ import (
)
// Reverse implements the ServiceBackend interface.
-func (k *Kubernetes) Reverse(state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) {
+func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) {
ip := dnsutil.ExtractAddressFromReverse(state.Name())
if ip == "" {
- _, e := k.Records(state, exact)
+ _, e := k.Records(ctx, state, exact)
return nil, e
}
diff --git a/plugin/kubernetes/xfr.go b/plugin/kubernetes/xfr.go
index fb17544ad..7ea99fd8d 100644
--- a/plugin/kubernetes/xfr.go
+++ b/plugin/kubernetes/xfr.go
@@ -45,7 +45,7 @@ func (k *Kubernetes) Transfer(ctx context.Context, state request.Request) (int,
ch := make(chan *dns.Envelope)
tr := new(dns.Transfer)
- soa, err := plugin.SOA(k, state.Zone, state, plugin.Options{})
+ soa, err := plugin.SOA(ctx, k, state.Zone, state, plugin.Options{})
if err != nil {
return dns.RcodeServerFailure, nil
}