address comments

This commit is contained in:
knight42 2020-06-13 09:30:20 +08:00
parent e0d125b046
commit 136849728c
No known key found for this signature in database
GPG Key ID: 1040B69865E7D86C
2 changed files with 24 additions and 2 deletions

View File

@ -140,7 +140,7 @@ func (c *Repair) runOnce() error {
case nil:
if stored.Has(port) {
// remove it from the old set, so we can find leaks
_ = stored.Release(port)
stored.Release(port)
} else {
// doesn't seem to be allocated
c.recorder.Eventf(svc, corev1.EventTypeWarning, "PortNotAllocated", "Port %d is not allocated; repairing", port)

View File

@ -223,6 +223,28 @@ func TestCollectServiceNodePorts(t *testing.T) {
},
expected: []int{111, 112, 113},
},
{
name: "duplicated nodePort with TCP protocol",
serviceSpec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{NodePort: 111, Protocol: corev1.ProtocolTCP},
{NodePort: 111, Protocol: corev1.ProtocolTCP},
{NodePort: 112, Protocol: corev1.ProtocolUDP},
},
},
expected: []int{111, 111, 112},
},
{
name: "duplicated nodePort with UDP protocol",
serviceSpec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{NodePort: 111, Protocol: corev1.ProtocolUDP},
{NodePort: 111, Protocol: corev1.ProtocolUDP},
{NodePort: 112, Protocol: corev1.ProtocolTCP},
},
},
expected: []int{111, 111, 112},
},
{
name: "duplicated nodePort with different protocol",
serviceSpec: corev1.ServiceSpec{
@ -257,7 +279,7 @@ func TestCollectServiceNodePorts(t *testing.T) {
expected: []int{111, 112},
},
{
name: "nodePort has same protocol with duplicated health check port",
name: "nodePort has same protocol as duplicated health check port",
serviceSpec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{NodePort: 111, Protocol: corev1.ProtocolUDP},