Skip to content

Commit

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

[release-1.23] fix: Ignore privateIPAllocationMethod when comparing frontend config
  • Loading branch information
k8s-ci-robot committed Jul 11, 2022
2 parents eb5d8b7 + a63adec commit 4d8eaf0
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 @@ -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

0 comments on commit 4d8eaf0

Please sign in to comment.