From a5e286ac4e1ce203c0c67b77f4042b3cf8c46ba8 Mon Sep 17 00:00:00 2001 From: Chris O'Haver Date: Mon, 4 May 2020 04:17:26 -0400 Subject: plugin/kubernetes: Don't panic with metadata enabled and pods mode not verified (#3869) * prevent panic in podWithIP Signed-off-by: Chris O'Haver * add unit test, correct existing unit test Signed-off-by: Chris O'Haver * unit tests make more sense this way Signed-off-by: Chris O'Haver --- plugin/kubernetes/autopath.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugin/kubernetes/autopath.go') 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 -- cgit v1.2.3