aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/autopath.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2020-05-04 04:17:26 -0400
committerGravatar GitHub <noreply@github.com> 2020-05-04 10:17:26 +0200
commita5e286ac4e1ce203c0c67b77f4042b3cf8c46ba8 (patch)
tree378c8f6249b34eeb05c563422f8b6c4215a446a0 /plugin/kubernetes/autopath.go
parent5347bc38e733a0ff084aafe7713d24903596f440 (diff)
downloadcoredns-a5e286ac4e1ce203c0c67b77f4042b3cf8c46ba8.tar.gz
coredns-a5e286ac4e1ce203c0c67b77f4042b3cf8c46ba8.tar.zst
coredns-a5e286ac4e1ce203c0c67b77f4042b3cf8c46ba8.zip
plugin/kubernetes: Don't panic with metadata enabled and pods mode not verified (#3869)
* prevent panic in podWithIP Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add unit test, correct existing unit test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * unit tests make more sense this way Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/kubernetes/autopath.go')
-rw-r--r--plugin/kubernetes/autopath.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/plugin/kubernetes/autopath.go b/plugin/kubernetes/autopath.go
index 33bf401f5..6bca35d39 100644
--- a/plugin/kubernetes/autopath.go
+++ b/plugin/kubernetes/autopath.go
@@ -51,6 +51,9 @@ func (k *Kubernetes) AutoPath(state request.Request) []string {
// podWithIP return the api.Pod for source IP. It returns nil if nothing can be found.
func (k *Kubernetes) podWithIP(ip string) *object.Pod {
+ if k.podMode != podModeVerified {
+ return nil
+ }
ps := k.APIConn.PodIndex(ip)
if len(ps) == 0 {
return nil