mirror of https://github.com/k3s-io/k3s
Check LoadBalancingRulePropertiesFormat for azure load balancers
parent
86bd977151
commit
00dc6b5ed8
|
@ -20,6 +20,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -1255,13 +1256,30 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
|
|||
|
||||
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule) bool {
|
||||
for _, existingRule := range rules {
|
||||
if strings.EqualFold(*existingRule.Name, *rule.Name) {
|
||||
if strings.EqualFold(*existingRule.Name, *rule.Name) &&
|
||||
equalLoadBalancingRulePropertiesFormat(existingRule.LoadBalancingRulePropertiesFormat, rule.LoadBalancingRulePropertiesFormat) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
|
||||
// Note: only fields used in reconcileLoadBalancer are considered.
|
||||
func equalLoadBalancingRulePropertiesFormat(s, t *network.LoadBalancingRulePropertiesFormat) bool {
|
||||
if s == nil || t == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return reflect.DeepEqual(s.Protocol, t.Protocol) &&
|
||||
reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
|
||||
reflect.DeepEqual(s.BackendAddressPool, t.BackendAddressPool) &&
|
||||
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) &&
|
||||
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) &&
|
||||
reflect.DeepEqual(s.BackendPort, t.BackendPort) &&
|
||||
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP)
|
||||
}
|
||||
|
||||
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
|
||||
// Note that it compares rule's DestinationAddressPrefix only when it's not consolidated rule as such rule does not have DestinationAddressPrefix defined.
|
||||
// We intentionally do not compare DestinationAddressPrefixes in consolidated case because reconcileSecurityRule has to consider the two rules equal,
|
||||
|
|
Loading…
Reference in New Issue