Re-work logic in shouldSyncUpdatedNode

This commit is contained in:
Alexander Constantinescu 2023-04-16 00:06:17 +02:00
parent 6e541a6da7
commit d3c103edce

View File

@ -660,15 +660,10 @@ func nodeNames(nodes []*v1.Node) sets.String {
} }
func shouldSyncUpdatedNode(oldNode, newNode *v1.Node) bool { func shouldSyncUpdatedNode(oldNode, newNode *v1.Node) bool {
if utilfeature.DefaultFeatureGate.Enabled(features.StableLoadBalancerNodeSet) {
// Only Nodes with changes to the label
// "node.kubernetes.io/exclude-from-external-load-balancers" will
// trigger a load balancer re-sync.
return respectsPredicates(oldNode, nodeIncludedPredicate) != respectsPredicates(newNode, nodeIncludedPredicate)
}
// Evaluate the individual node exclusion predicate before evaluating the // Evaluate the individual node exclusion predicate before evaluating the
// compounded result of all predicates. We don't sync ETP=local services // compounded result of all predicates. We don't sync changes on the
// for changes on the readiness condition, hence if a node remains NotReady // readiness condition for eTP:Local services or when
// StableLoadBalancerNodeSet is enabled, hence if a node remains NotReady
// and a user adds the exclusion label we will need to sync as to make sure // and a user adds the exclusion label we will need to sync as to make sure
// this change is reflected correctly on ETP=local services. The sync // this change is reflected correctly on ETP=local services. The sync
// function compares lastSyncedNodes with the new (existing) set of nodes // function compares lastSyncedNodes with the new (existing) set of nodes
@ -679,8 +674,11 @@ func shouldSyncUpdatedNode(oldNode, newNode *v1.Node) bool {
if respectsPredicates(oldNode, nodeIncludedPredicate) != respectsPredicates(newNode, nodeIncludedPredicate) { if respectsPredicates(oldNode, nodeIncludedPredicate) != respectsPredicates(newNode, nodeIncludedPredicate) {
return true return true
} }
if !utilfeature.DefaultFeatureGate.Enabled(features.StableLoadBalancerNodeSet) {
return respectsPredicates(oldNode, allNodePredicates...) != respectsPredicates(newNode, allNodePredicates...) return respectsPredicates(oldNode, allNodePredicates...) != respectsPredicates(newNode, allNodePredicates...)
} }
return false
}
// syncNodes handles updating the hosts pointed to by all load // syncNodes handles updating the hosts pointed to by all load
// balancers whenever the set of nodes in the cluster changes. // balancers whenever the set of nodes in the cluster changes.