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 28, 2024
1 parent 52be3dc commit fbb07a5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 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
1 change: 1 addition & 0 deletions xds/internal/resolver/xds_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func init() {

rinternal.NewWRR = wrr.NewRandom
rinternal.NewXDSClient = func(name string) (xdsclient.XDSClient, func(), error) { return xdsClientPool.NewClient(name) }

}

type xdsResolverBuilder struct {
Expand Down
13 changes: 7 additions & 6 deletions xds/server_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ type ServingModeChangeArgs struct {
Err error
}

// BootstrapContentsForTesting returns a grpc.ServerOption with the default
// pool set with the provided bootstrap congiguration. It allows users to
// inject a bootstrap configuration to be used by only this server, instead of
// the global configuration from the environment variables.
// BootstrapContentsForTesting returns a grpc.ServerOption with a new pool set
// with the provided bootstrap configuration. It allows users to inject a
// bootstrap configuration to be used by only this server, instead of the
// global configuration from the environment variables.
//
// # Testing Only
//
Expand All @@ -72,8 +72,7 @@ type ServingModeChangeArgs struct {
//
// # Experimental
//
// Notice: This API is EXPERIMENTAL but kept for backward compatibility. Use
// `ClientPoolForTesting` to set the pool directly. It will be removed in
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release.
func BootstrapContentsForTesting(bootstrapContents []byte) grpc.ServerOption {
config, err := bootstrap.NewConfigForTesting(bootstrapContents)
Expand All @@ -92,6 +91,8 @@ func BootstrapContentsForTesting(bootstrapContents []byte) grpc.ServerOption {
// This function should ONLY be used for testing and may not work with some
// other features, including the CSDS service.
//
// # Experimental
//
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release.
func ClientPoolForTesting(pool *xdsclient.Pool) grpc.ServerOption {
Expand Down
8 changes: 2 additions & 6 deletions xds/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,14 @@ func (s) TestNewServer_Success(t *testing.T) {
desc: "without_xds_creds",
serverOpts: []grpc.ServerOption{
grpc.Creds(insecure.NewCredentials()),
func() grpc.ServerOption {
return BootstrapContentsForTesting(generateBootstrapContents(t, uuid.NewString(), nonExistentManagementServer))
}(),
BootstrapContentsForTesting(generateBootstrapContents(t, uuid.NewString(), nonExistentManagementServer)),
},
},
{
desc: "with_xds_creds",
serverOpts: []grpc.ServerOption{
grpc.Creds(xdsCreds),
func() grpc.ServerOption {
return BootstrapContentsForTesting(generateBootstrapContents(t, uuid.NewString(), nonExistentManagementServer))
}(),
BootstrapContentsForTesting(generateBootstrapContents(t, uuid.NewString(), nonExistentManagementServer)),
},
wantXDSCredsInUse: true,
},
Expand Down

0 comments on commit fbb07a5

Please sign in to comment.