Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: remove support for v2 Transport API #6013

Merged
merged 7 commits into from Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion admin/test/utils.go
Expand Up @@ -55,7 +55,6 @@ type ExpectedStatusCodes struct {
func RunRegisterTests(t *testing.T, ec ExpectedStatusCodes) {
nodeID := uuid.New().String()
bootstrapCleanup, err := bootstrap.CreateFile(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: "no.need.for.a.server",
})
Expand Down
21 changes: 1 addition & 20 deletions internal/testutils/xds/bootstrap/bootstrap.go
Expand Up @@ -30,20 +30,8 @@ import (

var logger = grpclog.Component("internal/xds")

// TransportAPI refers to the API version for xDS transport protocol.
type TransportAPI int

const (
// TransportV2 refers to the v2 xDS transport protocol.
TransportV2 TransportAPI = iota
// TransportV3 refers to the v3 xDS transport protocol.
TransportV3
)

// Options wraps the parameters used to generate bootstrap configuration.
type Options struct {
// Version is the xDS transport protocol version.
Version TransportAPI
// NodeID is the node identifier of the gRPC client/server node in the
// proxyless service mesh.
NodeID string
Expand Down Expand Up @@ -119,14 +107,7 @@ func Contents(opts Options) ([]byte, error) {
ClientDefaultListenerResourceNameTemplate: opts.ClientDefaultListenerResourceNameTemplate,
ServerListenerResourceNameTemplate: opts.ServerListenerResourceNameTemplate,
}
switch opts.Version {
case TransportV2:
// TODO: Add any v2 specific fields.
case TransportV3:
cfg.XdsServers[0].ServerFeatures = append(cfg.XdsServers[0].ServerFeatures, "xds_v3")
default:
return nil, fmt.Errorf("unsupported xDS transport protocol version: %v", opts.Version)
}
cfg.XdsServers[0].ServerFeatures = append(cfg.XdsServers[0].ServerFeatures, "xds_v3")

auths := make(map[string]authority)
if envconfig.XDSFederation {
Expand Down
1 change: 0 additions & 1 deletion internal/testutils/xds/e2e/setup_management_server.go
Expand Up @@ -79,7 +79,6 @@ func SetupManagementServer(t *testing.T, opts ManagementServerOptions) (*Managem
// Create a bootstrap file in a temporary directory.
nodeID := uuid.New().String()
bootstrapContents, err := bootstrap.Contents(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: server.Address,
CertificateProviders: cpc,
Expand Down
2 changes: 0 additions & 2 deletions test/xds/xds_client_federation_test.go
Expand Up @@ -74,7 +74,6 @@ func (s) TestClientSideFederation(t *testing.T) {
// Create a bootstrap file in a temporary directory.
nodeID := uuid.New().String()
bootstrapContents, err := bootstrap.Contents(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: serverDefaultAuth.Address,
ServerListenerResourceNameTemplate: e2e.ServerListenerResourceNameTemplate,
Expand Down Expand Up @@ -220,7 +219,6 @@ func (s) TestFederation_UnknownAuthorityInReceivedResponse(t *testing.T) {

nodeID := uuid.New().String()
bootstrapContents, err := bootstrap.Contents(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: mgmtServer.Address,
ServerListenerResourceNameTemplate: e2e.ServerListenerResourceNameTemplate,
Expand Down
36 changes: 1 addition & 35 deletions xds/csds/csds.go
Expand Up @@ -29,7 +29,6 @@ import (
"io"
"sync"

"github.com/golang/protobuf/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
internalgrpclog "google.golang.org/grpc/internal/grpclog"
Expand All @@ -39,8 +38,6 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

v3adminpb "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
v3statusgrpc "github.com/envoyproxy/go-control-plane/envoy/service/status/v3"
v3statuspb "github.com/envoyproxy/go-control-plane/envoy/service/status/v3"
)
Expand Down Expand Up @@ -126,7 +123,7 @@ func (s *ClientStatusDiscoveryServer) buildClientStatusRespForReq(req *v3statusp
ret := &v3statuspb.ClientStatusResponse{
Config: []*v3statuspb.ClientConfig{
{
Node: nodeProtoToV3(s.xdsClient.BootstrapConfig().XDSServer.NodeProto, s.logger),
Node: s.xdsClient.BootstrapConfig().NodeProto,
GenericXdsConfigs: dumpToGenericXdsConfig(dump),
},
},
Expand All @@ -141,37 +138,6 @@ func (s *ClientStatusDiscoveryServer) Close() {
}
}

// nodeProtoToV3 converts the given proto into a v3.Node. n is from bootstrap
// config, it can be either v2.Node or v3.Node.
//
// If n is already a v3.Node, return it.
// If n is v2.Node, marshal and unmarshal it to v3.
// Otherwise, return nil.
//
// The default case (not v2 or v3) is nil, instead of error, because the
// resources in the response are more important than the node. The worst case is
// that the user will receive no Node info, but will still get resources.
func nodeProtoToV3(n proto.Message, logger *internalgrpclog.PrefixLogger) *v3corepb.Node {
var node *v3corepb.Node
switch nn := n.(type) {
case *v3corepb.Node:
node = nn
case *v2corepb.Node:
v2, err := proto.Marshal(nn)
if err != nil {
logger.Warningf("Failed to marshal node (%v): %v", n, err)
break
}
node = new(v3corepb.Node)
if err := proto.Unmarshal(v2, node); err != nil {
logger.Warningf("Failed to unmarshal node (%v): %v", v2, err)
}
default:
logger.Warningf("node from bootstrap is %#v, only v2.Node and v3.Node are supported", nn)
}
return node
}

func dumpToGenericXdsConfig(dump map[string]map[string]xdsresource.UpdateWithMD) []*v3statuspb.ClientConfig_GenericXdsConfig {
var ret []*v3statuspb.ClientConfig_GenericXdsConfig
for typeURL, updates := range dump {
Expand Down
1 change: 0 additions & 1 deletion xds/csds/csds_e2e_test.go
Expand Up @@ -125,7 +125,6 @@ func (s) TestCSDS(t *testing.T) {

// Create a bootstrap file in a temporary directory.
bootstrapCleanup, err := bootstrap.CreateFile(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: mgmtServer.Address,
})
Expand Down
92 changes: 0 additions & 92 deletions xds/csds/csds_test.go

This file was deleted.

8 changes: 3 additions & 5 deletions xds/googledirectpath/googlec2p.go
Expand Up @@ -41,7 +41,6 @@ import (
_ "google.golang.org/grpc/xds" // To register xds resolvers and balancers.
"google.golang.org/grpc/xds/internal/xdsclient"
"google.golang.org/grpc/xds/internal/xdsclient/bootstrap"
"google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version"
"google.golang.org/protobuf/types/known/structpb"

v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
Expand Down Expand Up @@ -118,10 +117,8 @@ func (c2pResolverBuilder) Build(t resolver.Target, cc resolver.ClientConn, opts
balancerName = tdURL
}
serverConfig := &bootstrap.ServerConfig{
ServerURI: balancerName,
Creds: grpc.WithCredentialsBundle(google.NewDefaultCredentials()),
TransportAPI: version.TransportV3,
NodeProto: newNode(<-zoneCh, <-ipv6CapableCh),
ServerURI: balancerName,
Creds: grpc.WithCredentialsBundle(google.NewDefaultCredentials()),
}
config := &bootstrap.Config{
XDSServer: serverConfig,
Expand All @@ -131,6 +128,7 @@ func (c2pResolverBuilder) Build(t resolver.Target, cc resolver.ClientConn, opts
XDSServer: serverConfig,
},
},
NodeProto: newNode(<-zoneCh, <-ipv6CapableCh),
}

// Create singleton xds client with this config. The xds client will be
Expand Down
6 changes: 2 additions & 4 deletions xds/googledirectpath/googlec2p_test.go
Expand Up @@ -32,7 +32,6 @@ import (
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/xds/internal/xdsclient"
"google.golang.org/grpc/xds/internal/xdsclient/bootstrap"
"google.golang.org/grpc/xds/internal/xdsclient/xdsresource/version"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/structpb"

Expand Down Expand Up @@ -214,9 +213,7 @@ func TestBuildXDS(t *testing.T) {
}
}
serverConfig := &bootstrap.ServerConfig{
ServerURI: tdURL,
TransportAPI: version.TransportV3,
NodeProto: wantNode,
ServerURI: tdURL,
}
wantConfig := &bootstrap.Config{
XDSServer: serverConfig,
Expand All @@ -226,6 +223,7 @@ func TestBuildXDS(t *testing.T) {
XDSServer: serverConfig,
},
},
NodeProto: wantNode,
}
if tt.tdURI != "" {
wantConfig.XDSServer.ServerURI = tt.tdURI
Expand Down
1 change: 0 additions & 1 deletion xds/internal/httpfilter/fault/fault_test.go
Expand Up @@ -106,7 +106,6 @@ func clientSetup(t *testing.T) (*e2e.ManagementServer, string, uint32, func()) {

// Create a bootstrap file in a temporary directory.
bootstrapCleanup, err := bootstrap.CreateFile(bootstrap.Options{
Version: bootstrap.TransportV3,
NodeID: nodeID,
ServerURI: fs.Address,
ServerListenerResourceNameTemplate: "grpc/server",
Expand Down