Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to not cancel Trust Bundle watch when another upstream is available #21867

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion agent/proxycfg/connect_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,12 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u UpdateEvent, s
}

seenUpstreams := make(map[UpstreamID]struct{})
seenPeers := make(map[string]struct{})
for _, svc := range resp.Services {
uid := NewUpstreamIDFromServiceName(svc)

seenUpstreams[uid] = struct{}{}
seenPeers[uid.Peer] = struct{}{}

cfgMap := make(map[string]interface{})
u, ok := snap.ConnectProxy.UpstreamConfig[uid]
Expand Down Expand Up @@ -496,7 +498,11 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u UpdateEvent, s
targetUID := NewUpstreamIDFromTargetID(targetID)
if targetUID.Peer != "" {
snap.ConnectProxy.PeerUpstreamEndpoints.CancelWatch(targetUID)
snap.ConnectProxy.UpstreamPeerTrustBundles.CancelWatch(targetUID.Peer)
// Only cancel watch if the peer is not seen,
// otherwise keep it as it's used by another service on the same peer
if _, ok := seenPeers[targetUID.Peer]; !ok {
snap.ConnectProxy.UpstreamPeerTrustBundles.CancelWatch(targetUID.Peer)
}
}
}
delete(snap.ConnectProxy.WatchedUpstreams, uid)
Expand Down
Loading