Merge pull request #911 from Random-Liu/sctp-support
Skip sctp protocol hostport mapping.
This commit is contained in:
commit
3e5eb0c7d5
@ -558,6 +558,9 @@ func toCNIPortMappings(criPortMappings []*runtime.PortMapping) []cni.PortMapping
|
||||
if mapping.HostPort <= 0 {
|
||||
continue
|
||||
}
|
||||
if mapping.Protocol != runtime.Protocol_TCP && mapping.Protocol != runtime.Protocol_UDP {
|
||||
continue
|
||||
}
|
||||
portMappings = append(portMappings, cni.PortMapping{
|
||||
HostPort: mapping.HostPort,
|
||||
ContainerPort: mapping.ContainerPort,
|
||||
|
@ -403,6 +403,30 @@ func TestToCNIPortMappings(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"CRI port mapping with unsupported protocol should be skipped": {
|
||||
criPortMappings: []*runtime.PortMapping{
|
||||
{
|
||||
Protocol: runtime.Protocol_SCTP,
|
||||
ContainerPort: 1234,
|
||||
HostPort: 5678,
|
||||
HostIp: "123.124.125.126",
|
||||
},
|
||||
{
|
||||
Protocol: runtime.Protocol_TCP,
|
||||
ContainerPort: 4321,
|
||||
HostPort: 8765,
|
||||
HostIp: "126.125.124.123",
|
||||
},
|
||||
},
|
||||
cniPortMappings: []cni.PortMapping{
|
||||
{
|
||||
HostPort: 8765,
|
||||
ContainerPort: 4321,
|
||||
Protocol: "tcp",
|
||||
HostIP: "126.125.124.123",
|
||||
},
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Logf("TestCase %q", desc)
|
||||
assert.Equal(t, test.cniPortMappings, toCNIPortMappings(test.criPortMappings))
|
||||
|
Loading…
Reference in New Issue
Block a user