Skip to content

Commit 1368497

Browse files
committed
address comments
1 parent e0d125b commit 1368497

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pkg/registry/core/service/portallocator/controller/repair.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (c *Repair) runOnce() error {
140140
case nil:
141141
if stored.Has(port) {
142142
// remove it from the old set, so we can find leaks
143-
_ = stored.Release(port)
143+
stored.Release(port)
144144
} else {
145145
// doesn't seem to be allocated
146146
c.recorder.Eventf(svc, corev1.EventTypeWarning, "PortNotAllocated", "Port %d is not allocated; repairing", port)

pkg/registry/core/service/portallocator/controller/repair_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ func TestCollectServiceNodePorts(t *testing.T) {
223223
},
224224
expected: []int{111, 112, 113},
225225
},
226+
{
227+
name: "duplicated nodePort with TCP protocol",
228+
serviceSpec: corev1.ServiceSpec{
229+
Ports: []corev1.ServicePort{
230+
{NodePort: 111, Protocol: corev1.ProtocolTCP},
231+
{NodePort: 111, Protocol: corev1.ProtocolTCP},
232+
{NodePort: 112, Protocol: corev1.ProtocolUDP},
233+
},
234+
},
235+
expected: []int{111, 111, 112},
236+
},
237+
{
238+
name: "duplicated nodePort with UDP protocol",
239+
serviceSpec: corev1.ServiceSpec{
240+
Ports: []corev1.ServicePort{
241+
{NodePort: 111, Protocol: corev1.ProtocolUDP},
242+
{NodePort: 111, Protocol: corev1.ProtocolUDP},
243+
{NodePort: 112, Protocol: corev1.ProtocolTCP},
244+
},
245+
},
246+
expected: []int{111, 111, 112},
247+
},
226248
{
227249
name: "duplicated nodePort with different protocol",
228250
serviceSpec: corev1.ServiceSpec{
@@ -257,7 +279,7 @@ func TestCollectServiceNodePorts(t *testing.T) {
257279
expected: []int{111, 112},
258280
},
259281
{
260-
name: "nodePort has same protocol with duplicated health check port",
282+
name: "nodePort has same protocol as duplicated health check port",
261283
serviceSpec: corev1.ServiceSpec{
262284
Ports: []corev1.ServicePort{
263285
{NodePort: 111, Protocol: corev1.ProtocolUDP},

0 commit comments

Comments
 (0)