Skip to content

Commit

Permalink
Merge pull request #1446 from jluhrsen/OCPBUGS-1661
Browse files Browse the repository at this point in the history
UPSTREAM: 113799: tests: network: Prefer internal IPs first
  • Loading branch information
openshift-merge-robot authored Feb 21, 2023
2 parents 8564fb8 + 25af2bb commit 518f3ed
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/e2e/framework/network/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func EndpointsUseHostNetwork(config *NetworkingTestConfig) {
config.EndpointsHostNetwork = true
}

// PreferExternalAddresses prefer node External Addresses for the tests
func PreferExternalAddresses(config *NetworkingTestConfig) {
config.PreferExternalAddresses = true
}

// NewNetworkingTestConfig creates and sets up a new test config helper.
func NewNetworkingTestConfig(f *framework.Framework, setters ...Option) *NetworkingTestConfig {
// default options
Expand Down Expand Up @@ -205,6 +210,8 @@ type NetworkingTestConfig struct {
// The kubernetes namespace within which all resources for this
// config are created
Namespace string
// Whether to prefer node External Addresses for the tests
PreferExternalAddresses bool
}

// NetexecDialResponse represents the response returned by the `netexec` subcommand of `agnhost`
Expand Down Expand Up @@ -817,13 +824,17 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) {
family = v1.IPv6Protocol
secondaryFamily = v1.IPv4Protocol
}
// Get Node IPs from the cluster, ExternalIPs take precedence
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, family)
if config.PreferExternalAddresses {
// Get Node IPs from the cluster, ExternalIPs take precedence
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, family)
}
if config.NodeIP == "" {
config.NodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, family)
}
if config.DualStackEnabled {
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, secondaryFamily)
if config.PreferExternalAddresses {
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeExternalIP, secondaryFamily)
}
if config.SecondaryNodeIP == "" {
config.SecondaryNodeIP = e2enode.FirstAddressByTypeAndFamily(nodeList, v1.NodeInternalIP, secondaryFamily)
}
Expand Down

0 comments on commit 518f3ed

Please sign in to comment.