Fix service's nodePort already allocated

Signed-off-by: carlory <baofa.fan@daocloud.io>
This commit is contained in:
carlory 2025-01-08 19:35:41 +08:00
parent 14dafc30c9
commit 8eb31f8aa1

View File

@ -1703,7 +1703,7 @@ var _ = common.SIGDescribe("Services", func() {
}
break
}
if apierrors.IsConflict(err) {
if apierrors.IsInvalid(err) {
framework.Logf("node port %d is already allocated to other service, retrying ... : %v", port, err)
continue
}
@ -3979,7 +3979,7 @@ var _ = common.SIGDescribe("Services", func() {
}
break
}
if apierrors.IsConflict(err) {
if apierrors.IsInvalid(err) {
framework.Logf("node port %d is already allocated to other service, retrying ... : %v", port, err)
continue
}
@ -3987,7 +3987,12 @@ var _ = common.SIGDescribe("Services", func() {
}
defer e2eservice.ReleaseStaticNodePort(svc.Spec.HealthCheckNodePort)
ginkgo.DeferCleanup(func(ctx context.Context) {
err := cs.CoreV1().Services(namespace).Delete(ctx, serviceName, metav1.DeleteOptions{})
framework.ExpectNoError(err, "failed to delete service: %s in namespace: %s", serviceName, namespace)
e2eservice.ReleaseStaticNodePort(svc.Spec.HealthCheckNodePort)
})
nodePortStr := fmt.Sprintf("%d", svc.Spec.Ports[0].NodePort)
hcNodePortStr := fmt.Sprintf("%d", svc.Spec.HealthCheckNodePort)
framework.Logf("NodePort is %s, HealthCheckNodePort is %s", nodePortStr, hcNodePortStr)