From c05e89d0e551c753407941abad4c479883f0629b Mon Sep 17 00:00:00 2001 From: Nick Sardo Date: Fri, 25 May 2018 16:09:16 -0700 Subject: [PATCH] Fix nodeport repair for ESIPP services --- .../core/service/portallocator/controller/repair.go | 5 +++++ .../service/portallocator/controller/repair_test.go | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/registry/core/service/portallocator/controller/repair.go b/pkg/registry/core/service/portallocator/controller/repair.go index 1e4dc685c3d..c1a4f0dadbd 100644 --- a/pkg/registry/core/service/portallocator/controller/repair.go +++ b/pkg/registry/core/service/portallocator/controller/repair.go @@ -204,5 +204,10 @@ func collectServiceNodePorts(service *api.Service) []int { servicePorts = append(servicePorts, int(servicePort.NodePort)) } } + + if service.Spec.HealthCheckNodePort != 0 { + servicePorts = append(servicePorts, int(service.Spec.HealthCheckNodePort)) + } + return servicePorts } diff --git a/pkg/registry/core/service/portallocator/controller/repair_test.go b/pkg/registry/core/service/portallocator/controller/repair_test.go index 151c791cc39..48c41aa989a 100644 --- a/pkg/registry/core/service/portallocator/controller/repair_test.go +++ b/pkg/registry/core/service/portallocator/controller/repair_test.go @@ -164,6 +164,12 @@ func TestRepairWithExisting(t *testing.T) { Ports: []api.ServicePort{{NodePort: 111}}, }, }, + &api.Service{ + ObjectMeta: metav1.ObjectMeta{Namespace: "six", Name: "six"}, + Spec: api.ServiceSpec{ + HealthCheckNodePort: 144, + }, + }, ) registry := &mockRangeRegistry{ @@ -183,10 +189,10 @@ func TestRepairWithExisting(t *testing.T) { if err != nil { t.Fatal(err) } - if !after.Has(111) || !after.Has(122) || !after.Has(133) { + if !after.Has(111) || !after.Has(122) || !after.Has(133) || !after.Has(144) { t.Errorf("unexpected portallocator state: %#v", after) } - if free := after.Free(); free != 98 { + if free := after.Free(); free != 97 { t.Errorf("unexpected portallocator state: %d free", free) } }