Commit 3b3fb6f5 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

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: default avatarMiek Gieben <miek@miek.nl>
parent adc021d6
...@@ -372,11 +372,6 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, ...@@ -372,11 +372,6 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
continue continue
} }
// exclude pods in the process of termination
if p.Deleting {
continue
}
// check for matching ip and namespace // check for matching ip and namespace
if ip == p.PodIP && match(namespace, p.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} s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
// Endpoints is a stripped down api.Endpoints with only the items we need for CoreDNS. // Endpoints is a stripped down api.Endpoints with only the items we need for CoreDNS.
type Endpoints struct { type Endpoints struct {
// Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string Version string
Name string Name string
Namespace string Namespace string
......
...@@ -7,11 +7,11 @@ import ( ...@@ -7,11 +7,11 @@ import (
// Pod is a stripped down api.Pod with only the items we need for CoreDNS. // Pod is a stripped down api.Pod with only the items we need for CoreDNS.
type Pod struct { type Pod struct {
// Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string Version string
PodIP string PodIP string
Name string Name string
Namespace string Namespace string
Deleting bool
*Empty *Empty
} }
...@@ -29,9 +29,10 @@ func ToPod(obj interface{}) interface{} { ...@@ -29,9 +29,10 @@ func ToPod(obj interface{}) interface{} {
Namespace: pod.GetNamespace(), Namespace: pod.GetNamespace(),
Name: pod.GetName(), Name: pod.GetName(),
} }
// don't add pods that are being deleted.
t := pod.ObjectMeta.DeletionTimestamp t := pod.ObjectMeta.DeletionTimestamp
if t != nil { if t != nil && !(*t).Time.IsZero() {
p.Deleting = !(*t).Time.IsZero() return nil
} }
*pod = api.Pod{} *pod = api.Pod{}
...@@ -48,7 +49,6 @@ func (p *Pod) DeepCopyObject() runtime.Object { ...@@ -48,7 +49,6 @@ func (p *Pod) DeepCopyObject() runtime.Object {
PodIP: p.PodIP, PodIP: p.PodIP,
Namespace: p.Namespace, Namespace: p.Namespace,
Name: p.Name, Name: p.Name,
Deleting: p.Deleting,
} }
return p1 return p1
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
// Service is a stripped down api.Service with only the items we need for CoreDNS. // Service is a stripped down api.Service with only the items we need for CoreDNS.
type Service struct { type Service struct {
// Don't add new fields to this struct without talking to the CoreDNS maintainers.
Version string Version string
Name string Name string
Namespace string Namespace string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment