mirror of https://github.com/linkerd/linkerd2.git
Fix destination staleness issue when adding EndpointSlices (#12427)
When updating the portPublisher's address set when a new EndpointSlice creation event is received, its addresses where getting overwritten with stale data whenever its IDs already existed in the current pp's address set. There can be pathological cases in single-stack where this can be a problem. For example when ES get recycled but the deletion event is not caught for some reason, when the addition event is received its Address data will be overwritten by the old stale entry. ## Other Changes - Remove overriding `newAddressSet.LocalTrafficPolicy` as that is already taken care inside `pp.endpointSliceToAddresses(slice)`. - When there are no Add events to send, return early without updating state nor updating metrics.
This commit is contained in:
parent
9882212964
commit
4fccf3e9ec
|
@ -795,15 +795,18 @@ func (pp *portPublisher) updateEndpoints(endpoints *corev1.Endpoints) {
|
|||
func (pp *portPublisher) addEndpointSlice(slice *discovery.EndpointSlice) {
|
||||
newAddressSet := pp.endpointSliceToAddresses(slice)
|
||||
for id, addr := range pp.addresses.Addresses {
|
||||
newAddressSet.Addresses[id] = addr
|
||||
newAddressSet.LocalTrafficPolicy = pp.localTrafficPolicy
|
||||
if _, ok := newAddressSet.Addresses[id]; !ok {
|
||||
newAddressSet.Addresses[id] = addr
|
||||
}
|
||||
}
|
||||
|
||||
add, _ := diffAddresses(pp.addresses, newAddressSet)
|
||||
if len(add.Addresses) > 0 {
|
||||
for _, listener := range pp.listeners {
|
||||
listener.Add(add)
|
||||
}
|
||||
if len(add.Addresses) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, listener := range pp.listeners {
|
||||
listener.Add(add)
|
||||
}
|
||||
|
||||
pp.addresses = newAddressSet
|
||||
|
|
Loading…
Reference in New Issue