mirror of https://github.com/k3s-io/k3s
Cleanup iptables proxier
parent
2c2b5f7379
commit
37a6989c79
|
@ -652,12 +652,16 @@ func updateServiceMap(
|
|||
syncRequired = false
|
||||
staleServices = sets.NewString()
|
||||
|
||||
func() {
|
||||
changes.Lock()
|
||||
defer changes.Unlock()
|
||||
for _, change := range changes.items {
|
||||
mergeSyncRequired, existingPorts := serviceMap.mergeService(change.current)
|
||||
unmergeSyncRequired := serviceMap.unmergeService(change.previous, existingPorts, staleServices)
|
||||
syncRequired = syncRequired || mergeSyncRequired || unmergeSyncRequired
|
||||
}
|
||||
changes.items = make(map[types.NamespacedName]*serviceChange)
|
||||
}()
|
||||
|
||||
// TODO: If this will appear to be computationally expensive, consider
|
||||
// computing this incrementally similarly to serviceMap.
|
||||
|
@ -708,6 +712,10 @@ func updateEndpointsMap(
|
|||
hostname string) (syncRequired bool, hcEndpoints map[types.NamespacedName]int, staleSet map[endpointServicePair]bool) {
|
||||
syncRequired = false
|
||||
staleSet = make(map[endpointServicePair]bool)
|
||||
|
||||
func() {
|
||||
changes.Lock()
|
||||
defer changes.Unlock()
|
||||
for _, change := range changes.items {
|
||||
oldEndpointsMap := endpointsToEndpointsMap(change.previous, hostname)
|
||||
newEndpointsMap := endpointsToEndpointsMap(change.current, hostname)
|
||||
|
@ -719,6 +727,7 @@ func updateEndpointsMap(
|
|||
}
|
||||
}
|
||||
changes.items = make(map[types.NamespacedName]*endpointsChange)
|
||||
}()
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.ExternalTrafficLocalOnly) {
|
||||
return
|
||||
|
@ -914,10 +923,8 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
|
|||
}
|
||||
|
||||
// Figure out the new services we need to activate.
|
||||
proxier.serviceChanges.Lock()
|
||||
serviceSyncRequired, hcServices, staleServices := updateServiceMap(
|
||||
proxier.serviceMap, &proxier.serviceChanges)
|
||||
proxier.serviceChanges.Unlock()
|
||||
|
||||
// If this was called because of a services update, but nothing actionable has changed, skip it.
|
||||
if reason == syncReasonServices && !serviceSyncRequired {
|
||||
|
@ -925,10 +932,8 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) {
|
|||
return
|
||||
}
|
||||
|
||||
proxier.endpointsChanges.Lock()
|
||||
endpointsSyncRequired, hcEndpoints, staleEndpoints := updateEndpointsMap(
|
||||
proxier.endpointsMap, &proxier.endpointsChanges, proxier.hostname)
|
||||
proxier.endpointsChanges.Unlock()
|
||||
|
||||
// If this was called because of an endpoints update, but nothing actionable has changed, skip it.
|
||||
if reason == syncReasonEndpoints && !endpointsSyncRequired {
|
||||
|
|
Loading…
Reference in New Issue