mirror of https://github.com/k3s-io/k3s
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 #53568pull/6/head
parent
6e2249b784
commit
81ff1f87f0
|
@ -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() {
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue