kubenet: Update empty ip check

The previous check was incorrect because the `IP.String` method returns
`<nil>` and other non-empty-strings on error conditions.
This commit is contained in:
Euan Kemp 2016-05-27 10:15:16 -07:00
parent c4b8959a75
commit 93487867ac

View File

@ -317,7 +317,7 @@ func (plugin *kubenetNetworkPlugin) SetUpPod(namespace string, name string, id k
if err != nil { if err != nil {
return err return err
} }
if res.IP4 == nil || res.IP4.IP.IP.String() == "" { if res.IP4 == nil || len(res.IP4.IP.IP) != net.IPv4len {
return fmt.Errorf("CNI plugin reported no IPv4 address for container %v.", id) return fmt.Errorf("CNI plugin reported no IPv4 address for container %v.", id)
} }
plugin.podIPs[id] = res.IP4.IP.IP.String() plugin.podIPs[id] = res.IP4.IP.IP.String()