Skip to content

Commit

Permalink
nil check for r.cc in r.onError, before calling r.cc.ReportError(err)
Browse files Browse the repository at this point in the history
  • Loading branch information
purnesh42H committed Dec 21, 2024
1 parent d11cf5f commit 533ddfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xds/internal/balancer/clusterresolver/e2e_test/eds_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions xds/internal/resolver/xds_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 533ddfe

Please sign in to comment.