Skip to content
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

[release-1.23] fix: Ignore privateIPAllocationMethod when comparing frontend config #2002

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,7 @@ func (az *Cloud) isFrontendIPChanged(clusterName string, config network.Frontend
return true, nil
}
}
if loadBalancerIP == "" {
return config.PrivateIPAllocationMethod == network.IPAllocationMethodStatic, nil
}
return config.PrivateIPAllocationMethod != network.IPAllocationMethodStatic || !strings.EqualFold(loadBalancerIP, to.String(config.PrivateIPAddress)), nil
return loadBalancerIP != "" && !strings.EqualFold(loadBalancerIP, to.String(config.PrivateIPAddress)), nil
}
pipName, _, err := az.determinePublicIPName(clusterName, service, pips)
if err != nil {
Expand Down
40 changes: 27 additions & 13 deletions pkg/provider/azure_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1643,14 +1643,15 @@ func TestIsFrontendIPChanged(t *testing.T) {
desc: "isFrontendIPChanged shall return false if the service is internal, no loadBalancerIP is given, " +
"subnetName == nil and config.PrivateIPAllocationMethod == network.Static",
config: network.FrontendIPConfiguration{
Name: to.StringPtr("atest1-name"),
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PrivateIPAllocationMethod: network.IPAllocationMethod("static"),
},
},
service: getInternalTestService("test1", 80),
expectedFlag: true,
expectedError: false,
lbFrontendIPConfigName: "btest1-name",
service: getInternalTestService("test1", 80),
expectedFlag: false,
expectedError: false,
},
{
desc: "isFrontendIPChanged shall return false if the service is internal, no loadBalancerIP is given, " +
Expand Down Expand Up @@ -1683,18 +1684,35 @@ func TestIsFrontendIPChanged(t *testing.T) {
expectedError: false,
},
{
desc: "isFrontendIPChanged shall return true if the service is internal, subnet == nil, " +
"loadBalancerIP != '' and config.PrivateIPAllocationMethod != 'static'",
desc: "isFrontendIPChanged shall return false if the service is internal, subnet == nil, " +
"loadBalancerIP == config.PrivateIPAddress and config.PrivateIPAllocationMethod != 'static'",
config: network.FrontendIPConfiguration{
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PrivateIPAllocationMethod: network.IPAllocationMethod("dynamic"),
PrivateIPAddress: to.StringPtr("1.1.1.1"),
},
},
lbFrontendIPConfigName: "btest1-name",
service: getInternalTestService("test1", 80),
loadBalancerIP: "1.1.1.1",
expectedFlag: true,
expectedFlag: false,
expectedError: false,
},
{
desc: "isFrontendIPChanged shall return false if the service is internal, subnet == nil, " +
"loadBalancerIP == config.PrivateIPAddress and config.PrivateIPAllocationMethod == 'static'",
config: network.FrontendIPConfiguration{
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PrivateIPAllocationMethod: network.IPAllocationMethod("static"),
PrivateIPAddress: to.StringPtr("1.1.1.1"),
},
},
lbFrontendIPConfigName: "btest1-name",
service: getInternalTestService("test1", 80),
loadBalancerIP: "1.1.1.1",
expectedFlag: false,
expectedError: false,
},
{
Expand All @@ -1716,12 +1734,8 @@ func TestIsFrontendIPChanged(t *testing.T) {
{
desc: "isFrontendIPChanged shall return false if config.PublicIPAddress == nil",
config: network.FrontendIPConfiguration{
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{
ID: to.StringPtr("pip"),
},
},
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{},
},
lbFrontendIPConfigName: "btest1-name",
service: getTestService("test1", v1.ProtocolTCP, nil, false, 80),
Expand Down