-
Notifications
You must be signed in to change notification settings - Fork 225
CORS-4174: Azure: Add Ingress LB IPs to Infra CR when in-cluster DNS is enabled #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,6 +237,29 @@ func TestSetDefaultPublishingStrategySetsPlatformDefaults(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| makeDefaultAzurePlatformStatus = func(platform configv1.PlatformType) *configv1.PlatformStatus { | ||
| return &configv1.PlatformStatus{ | ||
| Type: platform, | ||
| Azure: &configv1.AzurePlatformStatus{ | ||
| CloudLoadBalancerConfig: &configv1.CloudLoadBalancerConfig{ | ||
| DNSType: configv1.PlatformDefaultDNSType, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| makeBYODNSAzurePlatformStatus = func(platform configv1.PlatformType) *configv1.PlatformStatus { | ||
| return &configv1.PlatformStatus{ | ||
| Type: platform, | ||
| Azure: &configv1.AzurePlatformStatus{ | ||
| CloudLoadBalancerConfig: &configv1.CloudLoadBalancerConfig{ | ||
| DNSType: configv1.ClusterHostedDNSType, | ||
| ClusterHosted: &configv1.CloudLoadBalancerIPs{}, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| ingressConfigWithDefaultClassicLB = &configv1.Ingress{ | ||
| Spec: configv1.IngressSpec{ | ||
| LoadBalancer: configv1.LoadBalancer{ | ||
|
|
@@ -320,6 +343,18 @@ func TestSetDefaultPublishingStrategySetsPlatformDefaults(t *testing.T) { | |
| expectedIC: ingressControllerWithLoadBalancerUnmanagedDNS, | ||
| domainMatchesBaseDomain: true, | ||
| }, | ||
| { | ||
| name: "Azure", | ||
| platformStatus: makeDefaultAzurePlatformStatus(configv1.AzurePlatformType), | ||
| expectedIC: ingressControllerWithLoadBalancer, | ||
| domainMatchesBaseDomain: true, | ||
| }, | ||
| { | ||
| name: "Azure With BYO DNS", | ||
| platformStatus: makeBYODNSAzurePlatformStatus(configv1.AzurePlatformType), | ||
| expectedIC: ingressControllerWithLoadBalancerUnmanagedDNS, | ||
| domainMatchesBaseDomain: true, | ||
| }, | ||
| { | ||
| name: "GCP", | ||
| platformStatus: makeDefaultGCPPlatformStatus(configv1.GCPPlatformType), | ||
|
|
@@ -1617,7 +1652,10 @@ func Test_IsProxyProtocolNeeded(t *testing.T) { | |
|
|
||
| func Test_computeUpdatedInfraFromService(t *testing.T) { | ||
| var ( | ||
| IngressLBIP = configv1.IP("196.78.125.4") | ||
| IngressLBIP = configv1.IP("196.78.125.4") | ||
| nonePlatform = configv1.PlatformStatus{ | ||
| Type: configv1.NonePlatformType, | ||
| } | ||
| awsPlatform = configv1.PlatformStatus{ | ||
| Type: configv1.AWSPlatformType, | ||
| } | ||
|
|
@@ -1645,6 +1683,27 @@ func Test_computeUpdatedInfraFromService(t *testing.T) { | |
| azurePlatform = configv1.PlatformStatus{ | ||
| Type: configv1.AzurePlatformType, | ||
| } | ||
| azurePlatformWithDNSType = configv1.PlatformStatus{ | ||
| Type: configv1.AzurePlatformType, | ||
| Azure: &configv1.AzurePlatformStatus{ | ||
| CloudLoadBalancerConfig: &configv1.CloudLoadBalancerConfig{ | ||
| DNSType: configv1.ClusterHostedDNSType, | ||
| }, | ||
| }, | ||
| } | ||
| azurePlatformWithLBIP = configv1.PlatformStatus{ | ||
| Type: configv1.AzurePlatformType, | ||
| Azure: &configv1.AzurePlatformStatus{ | ||
| CloudLoadBalancerConfig: &configv1.CloudLoadBalancerConfig{ | ||
| DNSType: configv1.ClusterHostedDNSType, | ||
| ClusterHosted: &configv1.CloudLoadBalancerIPs{ | ||
| IngressLoadBalancerIPs: []configv1.IP{ | ||
| IngressLBIP, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| gcpPlatform = configv1.PlatformStatus{ | ||
| Type: configv1.GCPPlatformType, | ||
| } | ||
|
|
@@ -1701,7 +1760,7 @@ func Test_computeUpdatedInfraFromService(t *testing.T) { | |
| }, | ||
| { | ||
| description: "unsupported platform should not cause an error", | ||
| platform: &azurePlatform, | ||
| platform: &nonePlatform, | ||
| ingresses: []corev1.LoadBalancerIngress{}, | ||
| expectUpdated: false, | ||
| expectError: false, | ||
|
|
@@ -1782,6 +1841,44 @@ func Test_computeUpdatedInfraFromService(t *testing.T) { | |
| expectUpdated: true, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| description: "azure platform without DNSType set", | ||
| platform: &azurePlatform, | ||
| ingresses: []corev1.LoadBalancerIngress{}, | ||
| expectUpdated: false, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| description: "azure platform with DNSType and no LB IP", | ||
| platform: &azurePlatformWithDNSType, | ||
| ingresses: []corev1.LoadBalancerIngress{}, | ||
| expectUpdated: false, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| description: "azure platform with DNSType and no LB IP in infra config, service has 1 IP", | ||
| platform: &azurePlatformWithDNSType, | ||
| ingresses: ingresses, | ||
| expectedLBIPs: []configv1.IP{IngressLBIP}, | ||
| expectUpdated: true, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| description: "azure platform with no change to LB IPs", | ||
| platform: &azurePlatformWithLBIP, | ||
| ingresses: ingresses, | ||
| expectedLBIPs: []configv1.IP{IngressLBIP}, | ||
| expectUpdated: false, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| description: "azure platform with DNSType and LB IP", | ||
| platform: &azurePlatformWithLBIP, | ||
| ingresses: ingressesWithMultipleIPs, | ||
| expectedLBIPs: []configv1.IP{IngressLBIP, configv1.IP("10.10.10.4")}, | ||
| expectUpdated: true, | ||
| expectError: false, | ||
| }, | ||
|
Comment on lines
+1852
to
+1881
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another case to consider is where the infra config status has an IP address and the service status does not—the expected behavior is that the infra config status be updated with an empty list of IP addresses, right? {
description: "azure platform with DNSType and 1 LB IP in infra config, service has none",
platform: &azurePlatformWithLBIP,
ingresses: []corev1.LoadBalancerIngress{},
expectedLBIPs: []configv1.IP{},
expectUpdated: true,
expectError: false,
},By the way, the test runner should make a copy of the test input in case the test mutates it: diff --git a/pkg/operator/controller/ingress/controller_test.go b/pkg/operator/controller/ingress/controller_test.go
index 434f7509c..c4364846a 100644
--- a/pkg/operator/controller/ingress/controller_test.go
+++ b/pkg/operator/controller/ingress/controller_test.go
@@ -1787,7 +1787,7 @@ func Test_computeUpdatedInfraFromService(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
infraConfig := &configv1.Infrastructure{
Status: configv1.InfrastructureStatus{
- PlatformStatus: tc.platform,
+ PlatformStatus: tc.platform.DeepCopy(),
},
}
service := &corev1.Service{}If you add the |
||
| } | ||
| for _, tc := range testCases { | ||
| t.Run(tc.description, func(t *testing.T) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about refactoring the logic for updating the
CloudLoadBalancerConfig?We can leave that for a follow-up PR if you prefer.