diff --git a/agent/proxycfg/upstreams.go b/agent/proxycfg/upstreams.go index 65705fe25..a25cb62f6 100644 --- a/agent/proxycfg/upstreams.go +++ b/agent/proxycfg/upstreams.go @@ -47,8 +47,9 @@ func (s *handlerUpstreams) handleUpdateUpstreams(ctx context.Context, u cache.Up switch snap.Kind { case structs.ServiceKindIngressGateway: if _, ok := snap.IngressGateway.UpstreamsSet[svc]; !ok { - // Discovery chain is not associated with a known explicit or implicit upstream so it is skipped. + // Discovery chain is not associated with a known explicit or implicit upstream so it is purged/skipped. // The associated watch was likely cancelled. + delete(upstreamsSnapshot.DiscoveryChain, svc) s.logger.Trace("discovery-chain watch fired for unknown upstream", "upstream", svc) return nil } @@ -56,8 +57,9 @@ func (s *handlerUpstreams) handleUpdateUpstreams(ctx context.Context, u cache.Up case structs.ServiceKindConnectProxy: 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. + // Discovery chain is not associated with a known explicit or implicit upstream so it is purged/skipped. // The associated watch was likely cancelled. + delete(upstreamsSnapshot.DiscoveryChain, svc) s.logger.Trace("discovery-chain watch fired for unknown upstream", "upstream", svc) return nil }