Cancel upstream watches when the discovery chain has been removed

This commit is contained in:
Kyle Havlovitz 2022-07-20 14:26:52 -07:00
parent 31318d7049
commit 0be7d923dc
1 changed files with 10 additions and 0 deletions

View File

@ -148,6 +148,16 @@ func (s *handlerIngressGateway) handleUpdate(ctx context.Context, u UpdateEvent,
for uid, cancelFn := range snap.IngressGateway.WatchedDiscoveryChains {
if _, ok := watchedSvcs[uid]; !ok {
for targetID, cancelUpstreamFn := range snap.IngressGateway.WatchedUpstreams[uid] {
s.logger.Debug("stopping watch of target",
"upstream", uid,
"target", targetID,
)
delete(snap.IngressGateway.WatchedUpstreams[uid], targetID)
delete(snap.IngressGateway.WatchedUpstreamEndpoints[uid], targetID)
cancelUpstreamFn()
}
cancelFn()
delete(snap.IngressGateway.WatchedDiscoveryChains, uid)
}