Skip to content

Commit

Permalink
Merge pull request #2001 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1991-to-release-1.24

[release-1.24] fix: Ignore privateIPAllocationMethod when comparing frontend config
  • Loading branch information
k8s-ci-robot committed Jul 12, 2022
2 parents 3b12056 + 33e375c commit ba5858d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
5 changes: 1 addition & 4 deletions pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,10 +1276,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 @@ -1644,14 +1644,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 @@ -1684,18 +1685,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 @@ -1717,12 +1735,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

0 comments on commit ba5858d

Please sign in to comment.