Skip to content

Commit

Permalink
proxycfg: ensure all of the watches are canceled if they are cancelab…
Browse files Browse the repository at this point in the history
…le (#11824)
  • Loading branch information
rboyer authored and hc-github-team-consul-core committed Dec 13, 2021
1 parent 70f0afb commit 76803dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/11824.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
proxycfg: ensure all of the watches are canceled if they are cancelable
```
10 changes: 8 additions & 2 deletions agent/proxycfg/connect_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,14 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u cache.UpdateEv
}

// Clean up data from services that were not in the update
for sn := range snap.ConnectProxy.WatchedUpstreams {
for sn, targets := range snap.ConnectProxy.WatchedUpstreams {
if upstream, ok := snap.ConnectProxy.UpstreamConfig[sn]; ok && upstream.Datacenter != "" && upstream.Datacenter != s.source.Datacenter {
continue
}
if _, ok := seenServices[sn]; !ok {
for _, cancelFn := range targets {
cancelFn()
}
delete(snap.ConnectProxy.WatchedUpstreams, sn)
}
}
Expand All @@ -289,11 +292,14 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u cache.UpdateEv
delete(snap.ConnectProxy.WatchedUpstreamEndpoints, sn)
}
}
for sn := range snap.ConnectProxy.WatchedGateways {
for sn, cancelMap := range snap.ConnectProxy.WatchedGateways {
if upstream, ok := snap.ConnectProxy.UpstreamConfig[sn]; ok && upstream.Datacenter != "" && upstream.Datacenter != s.source.Datacenter {
continue
}
if _, ok := seenServices[sn]; !ok {
for _, cancelFn := range cancelMap {
cancelFn()
}
delete(snap.ConnectProxy.WatchedGateways, sn)
}
}
Expand Down

0 comments on commit 76803dc

Please sign in to comment.