Skip to content

Commit

Permalink
transport/grpc: don't reassign ClientSettings.Endpoint (#557)
Browse files Browse the repository at this point in the history
dial is called multiple times when connection pooling is used,
and reassigning o.Endpoint multiple times generated endpoints like:
pubsub.mtls.mtls.googleapis.com
  • Loading branch information
broady authored Jun 25, 2020
1 parent 87b58b7 commit 00ea0da
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions transport/grpc/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C
grpcOpts = append(grpcOpts, timeoutDialerOption)
}

// NOTE(cbro): this is used only by the nightly mtls_smoketest and should
// not otherwise be used. It will be removed or renamed at some point.
if os.Getenv("GOOGLE_API_USE_MTLS") == "always" {
o.Endpoint = generateDefaultMtlsEndpoint(o.Endpoint)
}

return grpc.DialContext(ctx, o.Endpoint, grpcOpts...)
}

Expand Down Expand Up @@ -300,6 +294,13 @@ func processAndValidateOpts(opts []option.ClientOption) (*internal.DialSettings,
if err := o.Validate(); err != nil {
return nil, err
}

// NOTE(cbro): this is used only by the nightly mtls_smoketest and should
// not otherwise be used. It will be removed or renamed at some point.
if os.Getenv("GOOGLE_API_USE_MTLS") == "always" {
o.Endpoint = generateDefaultMtlsEndpoint(o.Endpoint)
}

return &o, nil
}

Expand Down

0 comments on commit 00ea0da

Please sign in to comment.