From 533ddfe440c55212a242c3dbfed6265a68af13d2 Mon Sep 17 00:00:00 2001 From: Purnesh Dixit Date: Sun, 22 Dec 2024 03:48:19 +0530 Subject: [PATCH] nil check for r.cc in r.onError, before calling r.cc.ReportError(err) --- .../balancer/clusterresolver/e2e_test/eds_impl_test.go | 10 +++++++--- xds/internal/resolver/xds_resolver.go | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xds/internal/balancer/clusterresolver/e2e_test/eds_impl_test.go b/xds/internal/balancer/clusterresolver/e2e_test/eds_impl_test.go index 54cedc85fed2..49a49bbef7f6 100644 --- a/xds/internal/balancer/clusterresolver/e2e_test/eds_impl_test.go +++ b/xds/internal/balancer/clusterresolver/e2e_test/eds_impl_test.go @@ -1272,6 +1272,11 @@ func (s) TestEDS_EndpointWithMultipleAddresses(t *testing.T) { // Create bootstrap configuration pointing to the above management server. nodeID := uuid.New().String() bootstrapContents := e2e.DefaultBootstrapContents(t, nodeID, mgmtServer.Address) + config, err := bootstrap.NewConfigForTesting(bootstrapContents) + if err != nil { + t.Fatalf("Failed to create an bootstrap config from contents: %v, %v", bootstrapContents, err) + } + pool := xdsclient.NewPool(config) // Create xDS resources for consumption by the test. We start off with a // single backend in a single EDS locality. @@ -1288,9 +1293,8 @@ func (s) TestEDS_EndpointWithMultipleAddresses(t *testing.T) { // Create an xDS client talking to the above management server, configured // with a short watch expiry timeout. - xdsClient, close, err := xdsclient.NewForTesting(xdsclient.OptionsForTesting{ - Name: t.Name(), - Contents: bootstrapContents, + xdsClient, close, err := pool.NewClientForTesting(xdsclient.OptionsForTesting{ + Name: t.Name(), }) if err != nil { t.Fatalf("Failed to create an xDS client: %v", err) diff --git a/xds/internal/resolver/xds_resolver.go b/xds/internal/resolver/xds_resolver.go index a8a2c40fa288..4d38b4919668 100644 --- a/xds/internal/resolver/xds_resolver.go +++ b/xds/internal/resolver/xds_resolver.go @@ -460,6 +460,10 @@ func (r *xdsResolver) applyRouteConfigUpdate(update xdsresource.RouteConfigUpdat // // Only executed in the context of a serializer callback. func (r *xdsResolver) onError(err error) { + if r.cc == nil { + r.logger.Warningf("Resolver closed, dropping error: %v", err) + return + } r.cc.ReportError(err) }