mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Check LoadBalancingRulePropertiesFormat for azure load balancers
This commit is contained in:
parent
86bd977151
commit
00dc6b5ed8
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -1255,13 +1256,30 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
|
|||||||
|
|
||||||
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule) bool {
|
func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule) bool {
|
||||||
for _, existingRule := range rules {
|
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 true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
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.
|
// 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.
|
// 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,
|
// We intentionally do not compare DestinationAddressPrefixes in consolidated case because reconcileSecurityRule has to consider the two rules equal,
|
||||||
|
Loading…
Reference in New Issue
Block a user