diff --git a/agent/proxycfg/upstreams.go b/agent/proxycfg/upstreams.go index e5bcc098ec..ae9c660ff7 100644 --- a/agent/proxycfg/upstreams.go +++ b/agent/proxycfg/upstreams.go @@ -43,6 +43,14 @@ func (s *handlerUpstreams) handleUpdateUpstreams(ctx context.Context, u cache.Up return fmt.Errorf("invalid type for response: %T", u.Result) } svc := strings.TrimPrefix(u.CorrelationID, "discovery-chain:") + + explicit := snap.ConnectProxy.UpstreamConfig[svc].HasLocalPortOrSocket() + if _, implicit := snap.ConnectProxy.IntentionUpstreams[svc]; !implicit && !explicit { + // Discovery chain is not associated with a known explicit or implicit upstream so it is skipped. + // The associated watch was likely cancelled. + return nil + } + upstreamsSnapshot.DiscoveryChain[svc] = resp.Chain if err := s.resetWatchesFromChain(ctx, svc, resp.Chain, upstreamsSnapshot); err != nil {