From 81ff1f87f0b79e70b876d798ee0de18d9861a11b Mon Sep 17 00:00:00 2001 From: Dane LeBlanc Date: Sun, 8 Oct 2017 10:53:19 -0400 Subject: [PATCH] Fallback to internal addrs in e2e tests when no external addrs available This change modifies the way that config.NodeIP is selected at the start of e2e Networking tests such that if no external addresses are available from the cloud provider (e.g. either no cloud provider being used [baremetal or VMs], or the provider doesn't have external IPs configured), then one of the internal addresses is used. Without this change, the e2e service-related Networking tests would always panic when config.ExternalAddrs[0] is accessed and the slice is empty. This change eliminates the panic, and in some setups, the fallback choice of using an internal address will provide the necessary connectivity for the e2e Networking tests to access each node. fixes #53568 --- test/e2e/framework/networking_utils.go | 7 ++++++- test/e2e/network/networking.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/e2e/framework/networking_utils.go b/test/e2e/framework/networking_utils.go index 87f69f1a43..6c0e232c36 100644 --- a/test/e2e/framework/networking_utils.go +++ b/test/e2e/framework/networking_utils.go @@ -511,7 +511,12 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) { } } config.ClusterIP = config.NodePortService.Spec.ClusterIP - config.NodeIP = config.ExternalAddrs[0] + if len(config.ExternalAddrs) != 0 { + config.NodeIP = config.ExternalAddrs[0] + } else { + internalAddrs := NodeAddresses(nodeList, v1.NodeInternalIP) + config.NodeIP = internalAddrs[0] + } } func (config *NetworkingTestConfig) cleanup() { diff --git a/test/e2e/network/networking.go b/test/e2e/network/networking.go index 926e1c61c7..49635f82e0 100644 --- a/test/e2e/network/networking.go +++ b/test/e2e/network/networking.go @@ -105,7 +105,7 @@ var _ = SIGDescribe("Networking", func() { By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterHttpPort)) config.DialFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, 0, config.EndpointHostnames()) - By(fmt.Sprintf("dialing(http) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.ExternalAddrs[0], config.NodeHttpPort)) + By(fmt.Sprintf("dialing(http) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.NodeIP, config.NodeHttpPort)) config.DialFromTestContainer("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, 0, config.EndpointHostnames()) }) @@ -114,7 +114,7 @@ var _ = SIGDescribe("Networking", func() { By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterUdpPort)) config.DialFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, 0, config.EndpointHostnames()) - By(fmt.Sprintf("dialing(udp) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.ExternalAddrs[0], config.NodeUdpPort)) + By(fmt.Sprintf("dialing(udp) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.NodeIP, config.NodeUdpPort)) config.DialFromTestContainer("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, 0, config.EndpointHostnames()) })