From 475a374822a86fdb4d1956482cfaf69477c113e3 Mon Sep 17 00:00:00 2001 From: Matt Matejczyk Date: Tue, 3 Sep 2019 16:45:09 +0200 Subject: [PATCH] Update NodeSSHHosts to support clusters with some public nodes This is to support the setup where we have private nodes and one additional heapster node with public IP. We plan to use this setup in our scale tests. Ref. https://github.com/kubernetes/kubernetes/issues/76374 --- test/e2e/framework/ssh/ssh.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/e2e/framework/ssh/ssh.go b/test/e2e/framework/ssh/ssh.go index c6a10df2e6c..8a017f84da2 100644 --- a/test/e2e/framework/ssh/ssh.go +++ b/test/e2e/framework/ssh/ssh.go @@ -105,17 +105,13 @@ func NodeSSHHosts(c clientset.Interface) ([]string, error) { nodelist := waitListSchedulableNodesOrDie(c) hosts := nodeAddresses(nodelist, v1.NodeExternalIP) - // If ExternalIPs aren't set, assume the test programs can reach the - // InternalIP. Simplified exception logic here assumes that the hosts will - // either all have ExternalIP or none will. Simplifies handling here and - // should be adequate since the setting of the external IPs is provider - // specific: they should either all have them or none of them will. - if len(hosts) == 0 { + // If ExternalIPs aren't available for all nodes, try falling back to the InternalIPs. + if len(hosts) < len(nodelist.Items) { e2elog.Logf("No external IP address on nodes, falling back to internal IPs") hosts = nodeAddresses(nodelist, v1.NodeInternalIP) } - // Error if any node didn't have an external/internal IP. + // Error if neither External nor Internal IPs weren't available for all nodes. if len(hosts) != len(nodelist.Items) { return hosts, fmt.Errorf( "only found %d IPs on nodes, but found %d nodes. Nodelist: %v",