mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 07:13:53 +00:00
Merge pull request #129582 from aojea/service_nodeport
e2e services: avoid panic on service creation retry
This commit is contained in:
commit
5e220e4041
@ -1680,16 +1680,17 @@ var _ = common.SIGDescribe("Services", func() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
service := t.BuildServiceSpec()
|
var service *v1.Service
|
||||||
service.Spec.Type = v1.ServiceTypeNodePort
|
baseService := t.BuildServiceSpec()
|
||||||
|
baseService.Spec.Type = v1.ServiceTypeNodePort
|
||||||
numberOfRetries := 5
|
numberOfRetries := 5
|
||||||
ginkgo.By("creating service " + serviceName + " with type NodePort in namespace " + ns)
|
ginkgo.By("creating service " + serviceName + " with type NodePort in namespace " + ns)
|
||||||
var err error
|
var err error
|
||||||
for i := 0; i < numberOfRetries; i++ {
|
for i := 0; i < numberOfRetries; i++ {
|
||||||
port, err := e2eservice.GetUnusedStaticNodePort()
|
port, err := e2eservice.GetUnusedStaticNodePort()
|
||||||
framework.ExpectNoError(err, "Static node port allocator was not able to find a free nodeport.")
|
framework.ExpectNoError(err, "Static node port allocator was not able to find a free nodeport.")
|
||||||
service.Spec.Ports[0].NodePort = port
|
baseService.Spec.Ports[0].NodePort = port
|
||||||
service, err = t.CreateService(service)
|
service, err = t.CreateService(baseService)
|
||||||
// We will later delete this service and then recreate it with same nodeport. We need to ensure that
|
// We will later delete this service and then recreate it with same nodeport. We need to ensure that
|
||||||
// another e2e test doesn't start listening on our old nodeport and conflicts re-creation of service
|
// another e2e test doesn't start listening on our old nodeport and conflicts re-creation of service
|
||||||
// hence we use ReserveStaticNodePort.
|
// hence we use ReserveStaticNodePort.
|
||||||
|
Loading…
Reference in New Issue
Block a user