Skip to content

Commit 5e220e4

Browse files
authored
Merge pull request kubernetes#129582 from aojea/service_nodeport
e2e services: avoid panic on service creation retry
2 parents 36d316e + 17030f1 commit 5e220e4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/e2e/network/service.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,16 +1680,17 @@ var _ = common.SIGDescribe("Services", func() {
16801680
}
16811681
}()
16821682

1683-
service := t.BuildServiceSpec()
1684-
service.Spec.Type = v1.ServiceTypeNodePort
1683+
var service *v1.Service
1684+
baseService := t.BuildServiceSpec()
1685+
baseService.Spec.Type = v1.ServiceTypeNodePort
16851686
numberOfRetries := 5
16861687
ginkgo.By("creating service " + serviceName + " with type NodePort in namespace " + ns)
16871688
var err error
16881689
for i := 0; i < numberOfRetries; i++ {
16891690
port, err := e2eservice.GetUnusedStaticNodePort()
16901691
framework.ExpectNoError(err, "Static node port allocator was not able to find a free nodeport.")
1691-
service.Spec.Ports[0].NodePort = port
1692-
service, err = t.CreateService(service)
1692+
baseService.Spec.Ports[0].NodePort = port
1693+
service, err = t.CreateService(baseService)
16931694
// We will later delete this service and then recreate it with same nodeport. We need to ensure that
16941695
// another e2e test doesn't start listening on our old nodeport and conflicts re-creation of service
16951696
// hence we use ReserveStaticNodePort.

0 commit comments

Comments
 (0)