mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #75490 from yastij/azure-lb-idle-timeout
skip idleTimeout erros when deleting azure LB
This commit is contained in:
commit
3adae6ce2f
@ -604,7 +604,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName)
|
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName)
|
||||||
|
|
||||||
lbIdleTimeout, err := getIdleTimeout(service)
|
lbIdleTimeout, err := getIdleTimeout(service)
|
||||||
if err != nil {
|
if wantLb && err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +789,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
if az.serviceOwnsRule(service, *existingRule.Name) {
|
if az.serviceOwnsRule(service, *existingRule.Name) {
|
||||||
keepRule := false
|
keepRule := false
|
||||||
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
||||||
if findRule(expectedRules, existingRule) {
|
if findRule(expectedRules, existingRule, wantLb) {
|
||||||
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - keeping", serviceName, wantLb, *existingRule.Name)
|
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - keeping", serviceName, wantLb, *existingRule.Name)
|
||||||
keepRule = true
|
keepRule = true
|
||||||
}
|
}
|
||||||
@ -803,7 +803,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
// update rules: add needed
|
// update rules: add needed
|
||||||
for _, expectedRule := range expectedRules {
|
for _, expectedRule := range expectedRules {
|
||||||
foundRule := false
|
foundRule := false
|
||||||
if findRule(updatedRules, expectedRule) {
|
if findRule(updatedRules, expectedRule, wantLb) {
|
||||||
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - already exists", serviceName, wantLb, *expectedRule.Name)
|
klog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - already exists", serviceName, wantLb, *expectedRule.Name)
|
||||||
foundRule = true
|
foundRule = true
|
||||||
}
|
}
|
||||||
@ -1474,10 +1474,10 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule) bool {
|
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule, wantLB bool) bool {
|
||||||
for _, existingRule := range rules {
|
for _, existingRule := range rules {
|
||||||
if strings.EqualFold(to.String(existingRule.Name), to.String(rule.Name)) &&
|
if strings.EqualFold(to.String(existingRule.Name), to.String(rule.Name)) &&
|
||||||
equalLoadBalancingRulePropertiesFormat(existingRule.LoadBalancingRulePropertiesFormat, rule.LoadBalancingRulePropertiesFormat) {
|
equalLoadBalancingRulePropertiesFormat(existingRule.LoadBalancingRulePropertiesFormat, rule.LoadBalancingRulePropertiesFormat, wantLB) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1486,19 +1486,23 @@ func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule)
|
|||||||
|
|
||||||
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
|
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
|
||||||
// Note: only fields used in reconcileLoadBalancer are considered.
|
// Note: only fields used in reconcileLoadBalancer are considered.
|
||||||
func equalLoadBalancingRulePropertiesFormat(s, t *network.LoadBalancingRulePropertiesFormat) bool {
|
func equalLoadBalancingRulePropertiesFormat(s *network.LoadBalancingRulePropertiesFormat, t *network.LoadBalancingRulePropertiesFormat, wantLB bool) bool {
|
||||||
if s == nil || t == nil {
|
if s == nil || t == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return reflect.DeepEqual(s.Protocol, t.Protocol) &&
|
properties := reflect.DeepEqual(s.Protocol, t.Protocol) &&
|
||||||
reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
|
reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
|
||||||
reflect.DeepEqual(s.BackendAddressPool, t.BackendAddressPool) &&
|
reflect.DeepEqual(s.BackendAddressPool, t.BackendAddressPool) &&
|
||||||
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) &&
|
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) &&
|
||||||
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) &&
|
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) &&
|
||||||
reflect.DeepEqual(s.BackendPort, t.BackendPort) &&
|
reflect.DeepEqual(s.BackendPort, t.BackendPort) &&
|
||||||
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP) &&
|
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP)
|
||||||
reflect.DeepEqual(s.IdleTimeoutInMinutes, t.IdleTimeoutInMinutes)
|
|
||||||
|
if wantLB {
|
||||||
|
return properties && reflect.DeepEqual(s.IdleTimeoutInMinutes, t.IdleTimeoutInMinutes)
|
||||||
|
}
|
||||||
|
return properties
|
||||||
}
|
}
|
||||||
|
|
||||||
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
|
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
|
||||||
|
@ -210,7 +210,7 @@ func TestFindRule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
findResult := findRule(test.existingRule, test.curRule)
|
findResult := findRule(test.existingRule, test.curRule, true)
|
||||||
assert.Equal(t, test.expected, findResult, fmt.Sprintf("TestCase[%d]: %s", i, test.msg))
|
assert.Equal(t, test.expected, findResult, fmt.Sprintf("TestCase[%d]: %s", i, test.msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user