Skip to content

Commit f457179

Browse files
committed
skip idleTimeout erros when deleting azure LB
1 parent a4f2590 commit f457179

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

pkg/cloudprovider/providers/azure/azure_loadbalancer.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
604604
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName)
605605

606606
lbIdleTimeout, err := getIdleTimeout(service)
607-
if err != nil {
607+
if wantLb && err != nil {
608608
return nil, err
609609
}
610610

@@ -789,7 +789,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
789789
if az.serviceOwnsRule(service, *existingRule.Name) {
790790
keepRule := false
791791
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
792-
if findRule(expectedRules, existingRule) {
792+
if findRule(expectedRules, existingRule, wantLb) {
793793
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - keeping", serviceName, wantLb, *existingRule.Name)
794794
keepRule = true
795795
}
@@ -803,7 +803,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
803803
// update rules: add needed
804804
for _, expectedRule := range expectedRules {
805805
foundRule := false
806-
if findRule(updatedRules, expectedRule) {
806+
if findRule(updatedRules, expectedRule, wantLb) {
807807
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - already exists", serviceName, wantLb, *expectedRule.Name)
808808
foundRule = true
809809
}
@@ -1476,10 +1476,10 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
14761476
return false
14771477
}
14781478

1479-
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule) bool {
1479+
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule, wantLB bool) bool {
14801480
for _, existingRule := range rules {
14811481
if strings.EqualFold(to.String(existingRule.Name), to.String(rule.Name)) &&
1482-
equalLoadBalancingRulePropertiesFormat(existingRule.LoadBalancingRulePropertiesFormat, rule.LoadBalancingRulePropertiesFormat) {
1482+
equalLoadBalancingRulePropertiesFormat(existingRule.LoadBalancingRulePropertiesFormat, rule.LoadBalancingRulePropertiesFormat, wantLB) {
14831483
return true
14841484
}
14851485
}
@@ -1488,19 +1488,23 @@ func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule)
14881488

14891489
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
14901490
// Note: only fields used in reconcileLoadBalancer are considered.
1491-
func equalLoadBalancingRulePropertiesFormat(s, t *network.LoadBalancingRulePropertiesFormat) bool {
1491+
func equalLoadBalancingRulePropertiesFormat(s *network.LoadBalancingRulePropertiesFormat, t *network.LoadBalancingRulePropertiesFormat, wantLB bool) bool {
14921492
if s == nil || t == nil {
14931493
return false
14941494
}
14951495

1496-
return reflect.DeepEqual(s.Protocol, t.Protocol) &&
1496+
properties := reflect.DeepEqual(s.Protocol, t.Protocol) &&
14971497
reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
14981498
reflect.DeepEqual(s.BackendAddressPool, t.BackendAddressPool) &&
14991499
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) &&
15001500
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) &&
15011501
reflect.DeepEqual(s.BackendPort, t.BackendPort) &&
1502-
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP) &&
1503-
reflect.DeepEqual(s.IdleTimeoutInMinutes, t.IdleTimeoutInMinutes)
1502+
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP)
1503+
1504+
if wantLB {
1505+
return properties && reflect.DeepEqual(s.IdleTimeoutInMinutes, t.IdleTimeoutInMinutes)
1506+
}
1507+
return properties
15041508
}
15051509

15061510
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.

pkg/cloudprovider/providers/azure/azure_loadbalancer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func TestFindRule(t *testing.T) {
210210
}
211211

212212
for i, test := range tests {
213-
findResult := findRule(test.existingRule, test.curRule)
213+
findResult := findRule(test.existingRule, test.curRule, true)
214214
assert.Equal(t, test.expected, findResult, fmt.Sprintf("TestCase[%d]: %s", i, test.msg))
215215
}
216216
}

0 commit comments

Comments
 (0)