mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user