mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
Drop e2enode.PickIP(), fix its one caller
This returned a randomly-selected IP from across all nodes, preferring ExternalIP but falling back to an InternalIP. But it was only called from one place, which was connecting from inside the cluster and thus wanted an InternalIP anyway.
This commit is contained in:
@@ -294,19 +294,6 @@ func CollectAddresses(nodes *v1.NodeList, addressType v1.NodeAddressType) []stri
|
||||
return ips
|
||||
}
|
||||
|
||||
// PickIP picks one public node IP
|
||||
func PickIP(ctx context.Context, c clientset.Interface) (string, error) {
|
||||
publicIps, err := GetPublicIps(ctx, c)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("get node public IPs error: %w", err)
|
||||
}
|
||||
if len(publicIps) == 0 {
|
||||
return "", fmt.Errorf("got unexpected number (%d) of public IPs", len(publicIps))
|
||||
}
|
||||
ip := publicIps[0]
|
||||
return ip, nil
|
||||
}
|
||||
|
||||
// GetPublicIps returns a public IP list of nodes.
|
||||
func GetPublicIps(ctx context.Context, c clientset.Interface) ([]string, error) {
|
||||
nodes, err := GetReadySchedulableNodes(ctx, c)
|
||||
|
||||
@@ -54,8 +54,6 @@ var _ = sigDescribe("Services", skipUnlessWindows(func() {
|
||||
ns := f.Namespace.Name
|
||||
|
||||
jig := e2eservice.NewTestJig(cs, ns, serviceName)
|
||||
nodeIP, err := e2enode.PickIP(ctx, jig.Client)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("creating service " + serviceName + " with type=NodePort in namespace " + ns)
|
||||
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
|
||||
@@ -63,6 +61,11 @@ var _ = sigDescribe("Services", skipUnlessWindows(func() {
|
||||
})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
node, err := e2enode.GetRandomReadySchedulableNode(ctx, jig.Client)
|
||||
framework.ExpectNoError(err)
|
||||
ips := e2enode.GetAddressesByTypeAndFamily(node, v1.NodeInternalIP, svc.Spec.IPFamilies[0])
|
||||
gomega.Expect(ips).NotTo(gomega.BeEmpty())
|
||||
nodeIP := ips[0]
|
||||
nodePort := int(svc.Spec.Ports[0].NodePort)
|
||||
|
||||
ginkgo.By("creating Pod to be part of service " + serviceName)
|
||||
|
||||
Reference in New Issue
Block a user