@@ -18,6 +18,7 @@ package service
18
18
19
19
import (
20
20
"context"
21
+ "errors"
21
22
"fmt"
22
23
"net"
23
24
"regexp"
@@ -41,7 +42,6 @@ import (
41
42
"k8s.io/apimachinery/pkg/watch"
42
43
clientset "k8s.io/client-go/kubernetes"
43
44
"k8s.io/client-go/tools/cache"
44
- "k8s.io/kubernetes/pkg/registry/core/service/portallocator"
45
45
"k8s.io/kubernetes/test/e2e/framework"
46
46
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
47
47
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
@@ -54,6 +54,9 @@ import (
54
54
// NodePortRange should match whatever the default/configured range is
55
55
var NodePortRange = utilnet.PortRange {Base : 30000 , Size : 2768 }
56
56
57
+ // It is copied from "k8s.io/kubernetes/pkg/registry/core/service/portallocator"
58
+ var errAllocated = errors .New ("provided port is already allocated" )
59
+
57
60
// TestJig is a test jig to help service testing.
58
61
type TestJig struct {
59
62
Client clientset.Interface
@@ -476,7 +479,7 @@ func (j *TestJig) ChangeServiceNodePort(initial int) (*v1.Service, error) {
476
479
service , err = j .UpdateService (func (s * v1.Service ) {
477
480
s .Spec .Ports [0 ].NodePort = int32 (newPort )
478
481
})
479
- if err != nil && strings .Contains (err .Error (), portallocator . ErrAllocated .Error ()) {
482
+ if err != nil && strings .Contains (err .Error (), errAllocated .Error ()) {
480
483
framework .Logf ("tried nodePort %d, but it is in use, will try another" , newPort )
481
484
continue
482
485
}
0 commit comments