Merge pull request #47521 from squeed/release-1.7

Automatic merge from submit-queue (batch tested with PRs 47510, 47516, 47482, 47521, 47537)

cni: Don't try and map ports with an unset HostPort

The CNI Host function GetPodPortMappings also includes unmapped ports (this is apparently by design). This is normal, and the CNI network plugin invoker should not attempt to map these ports.

This matches the functionality in the kubenet hostport mapper.

Fixes: #47529
This commit is contained in:
Kubernetes Submit Queue 2017-06-14 20:32:49 -07:00 committed by GitHub
commit 877308bbe5

View File

@ -339,6 +339,9 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
}
portMappingsParam := make([]cniPortMapping, 0, len(portMappings))
for _, p := range portMappings {
if p.HostPort <= 0 {
continue
}
portMappingsParam = append(portMappingsParam, cniPortMapping{
HostPort: p.HostPort,
ContainerPort: p.ContainerPort,