From 679949f07945cd8481ee3231431b901d2961cfe0 Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Tue, 5 Mar 2024 10:04:27 -0800 Subject: [PATCH] [exporter/loadbalancing] Do not block resolver by the exporter shutdown --- exporter/loadbalancingexporter/loadbalancer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exporter/loadbalancingexporter/loadbalancer.go b/exporter/loadbalancingexporter/loadbalancer.go index a156ad9d9394..cccbc5c39245 100644 --- a/exporter/loadbalancingexporter/loadbalancer.go +++ b/exporter/loadbalancingexporter/loadbalancer.go @@ -148,7 +148,11 @@ func (lb *loadBalancer) removeExtraExporters(ctx context.Context, endpoints []st } for existing := range lb.exporters { if !endpointFound(existing, endpointsWithPort) { - _ = lb.exporters[existing].Shutdown(ctx) + exp := lb.exporters[existing] + // Shutdown the exporter asynchronously to avoid blocking the resolver + go func() { + _ = exp.Shutdown(ctx) + }() delete(lb.exporters, existing) } }