aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-06-01 08:39:52 +0100
committerGravatar GitHub <noreply@github.com> 2019-06-01 08:39:52 +0100
commit3b3fb6f5835a673f96c458b14104165dec2fb9f2 (patch)
tree009c13d23ace5964dd512864a731f8a28afc7f42
parentadc021d6ff5d286072609a09ed88ce7ee7026934 (diff)
downloadcoredns-3b3fb6f5835a673f96c458b14104165dec2fb9f2.tar.gz
coredns-3b3fb6f5835a673f96c458b14104165dec2fb9f2.tar.zst
coredns-3b3fb6f5835a673f96c458b14104165dec2fb9f2.zip
plugin/kubernetes: skip deleting pods (#2853)
Don't add pods to our internal cache that are being deleted. This saves a field in the struct as well. Add (extra) comments about adding fields to the object/{Pod,Service,Endpoint} structs. Signed-off-by: Miek Gieben <miek@miek.nl>
-rw-r--r--plugin/kubernetes/kubernetes.go5
-rw-r--r--plugin/kubernetes/object/endpoint.go1
-rw-r--r--plugin/kubernetes/object/pod.go8
-rw-r--r--plugin/kubernetes/object/service.go1
4 files changed, 6 insertions, 9 deletions
diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go
index 1b8214415..f980fb4ee 100644
--- a/plugin/kubernetes/kubernetes.go
+++ b/plugin/kubernetes/kubernetes.go
@@ -372,11 +372,6 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
continue
}
- // exclude pods in the process of termination
- if p.Deleting {
- continue
- }
-
// check for matching ip and namespace
if ip == p.PodIP && match(namespace, p.Namespace) {
s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}
diff --git a/plugin/kubernetes/object/endpoint.go b/plugin/kubernetes/object/endpoint.go
index b8531f050..aa93b4ceb 100644
--- a/plugin/kubernetes/object/endpoint.go
+++ b/plugin/kubernetes/object/endpoint.go
@@ -7,6 +7,7 @@ import (
// Endpoints is a stripped down api.Endpoints with only the items we need for CoreDNS.
type Endpoints struct {
+ // Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string
Name string
Namespace string
diff --git a/plugin/kubernetes/object/pod.go b/plugin/kubernetes/object/pod.go
index 9f0ba48ad..072d8d56d 100644
--- a/plugin/kubernetes/object/pod.go
+++ b/plugin/kubernetes/object/pod.go
@@ -7,11 +7,11 @@ import (
// Pod is a stripped down api.Pod with only the items we need for CoreDNS.
type Pod struct {
+ // Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string
PodIP string
Name string
Namespace string
- Deleting bool
*Empty
}
@@ -29,9 +29,10 @@ func ToPod(obj interface{}) interface{} {
Namespace: pod.GetNamespace(),
Name: pod.GetName(),
}
+ // don't add pods that are being deleted.
t := pod.ObjectMeta.DeletionTimestamp
- if t != nil {
- p.Deleting = !(*t).Time.IsZero()
+ if t != nil && !(*t).Time.IsZero() {
+ return nil
}
*pod = api.Pod{}
@@ -48,7 +49,6 @@ func (p *Pod) DeepCopyObject() runtime.Object {
PodIP: p.PodIP,
Namespace: p.Namespace,
Name: p.Name,
- Deleting: p.Deleting,
}
return p1
}
diff --git a/plugin/kubernetes/object/service.go b/plugin/kubernetes/object/service.go
index af9a42b48..3c8304362 100644
--- a/plugin/kubernetes/object/service.go
+++ b/plugin/kubernetes/object/service.go
@@ -7,6 +7,7 @@ import (
// Service is a stripped down api.Service with only the items we need for CoreDNS.
type Service struct {
+ // Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string
Name string
Namespace string