Skip to content

Commit

Permalink
Review comments #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Jul 8, 2020
1 parent 028f1f9 commit 46b957a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 9 additions & 9 deletions xds/internal/client/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ func NewConfig() (*Config, error) {
for k, v := range jsonData {
switch k {
case "node":
// We unconditionally convert the JSON into a v3.Node proto which
// does not contain the deprecated field "build_version" from the
// v2.Node proto. We expect this to succeed because we do not expect
// the bootstrap file to contain the "build_version" field.
// We unconditionally convert the JSON into a v3.Node proto. The v3
// proto does not contain the deprecated field "build_version" from
// the v2 proto. We do not expect the bootstrap file to contain the
// "build_version" field. In any case, the unmarshal will succeed
// because we have set the `AllowUnknownFields` option on the
// unmarshaler.
n := &v3corepb.Node{}
if err := m.Unmarshal(bytes.NewReader(v), n); err != nil {
return nil, fmt.Errorf("xds: jsonpb.Unmarshal(%v) for field %q failed during bootstrap: %v", string(v), k, err)
Expand Down Expand Up @@ -220,9 +222,9 @@ func NewConfig() (*Config, error) {
// file are populated here.
func (c *Config) updateNodeProto() error {
if c.TransportAPI == version.TransportV3 {
v3 := &v3corepb.Node{}
if c.NodeProto != nil {
v3 = c.NodeProto.(*v3corepb.Node)
v3, _ := c.NodeProto.(*v3corepb.Node)
if v3 == nil {
v3 = &v3corepb.Node{}
}
v3.UserAgentName = gRPCUserAgentName
v3.UserAgentVersionType = &v3corepb.Node_UserAgentVersion{UserAgentVersion: grpc.Version}
Expand All @@ -246,8 +248,6 @@ func (c *Config) updateNodeProto() error {
// BuildVersion is deprecated, and is replaced by user_agent_name and
// user_agent_version. But the management servers are still using the old
// field, so we will keep both set.
// API version for xDS transport protocol. This describes the xDS gRPC/REST
// endpoint and version of [Delta]DiscoveryRequest/Response used on the wire.
v2.BuildVersion = gRPCVersion
v2.UserAgentName = gRPCUserAgentName
v2.UserAgentVersionType = &v2corepb.Node_UserAgentVersion{UserAgentVersion: grpc.Version}
Expand Down
3 changes: 3 additions & 0 deletions xds/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func New(opts Options) (*Client, error) {

if opts.Config.TransportAPI == version.TransportV2 {
c.v2c = newXDSV2Client(c, cc, opts.Config.NodeProto.(*corepb.Node), backoff.DefaultExponential.Backoff, c.logger)
} else {
// TODO(easwars): Remove this once v3Client is ready.
return nil, errors.New("xds v3 client is not yet supported")
}

c.logger.Infof("Created")
Expand Down

0 comments on commit 46b957a

Please sign in to comment.