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:
parent
5347bc38e7
commit
a5e286ac4e
2 changed files with 37 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue