Skip to content

Commit 2b04c19

Browse files
vihangmcopybaranaut
authored andcommitted
Remove direct mode handling in the golang API
Summary: As direct mode is now being removed, the golang APIs no longer needs to handle connecting to the viziers directly. Test Plan: The golang API should continue to be able to talk to vizier. Reviewers: michelle, zasgar, philkuz Reviewed By: philkuz JIRA Issues: PP-3338 Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D11076 GitOrigin-RevId: 2471b1e869949876acc15df0a18a106e116c3908
1 parent 0dd1197 commit 2b04c19

File tree

2 files changed

+9
-47
lines changed

2 files changed

+9
-47
lines changed

client.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"context"
2323
"crypto/tls"
2424
"fmt"
25-
"net/url"
2625
"strings"
2726

2827
"google.golang.org/grpc"
@@ -122,33 +121,8 @@ func (c *Client) cloudCtxWithMD(ctx context.Context) context.Context {
122121

123122
// NewVizierClient creates a new vizier client, for the passed in vizierID.
124123
func (c *Client) NewVizierClient(ctx context.Context, vizierID string) (*VizierClient, error) {
125-
vizier, err := c.GetVizierInfo(ctx, vizierID)
126-
if err != nil {
127-
return nil, err
128-
}
129-
124+
var err error
130125
vzConn := c.grpcConn
131-
if vizier.DirectAccess {
132-
connInfo, err := c.getConnectionInfo(ctx, vizierID)
133-
if err != nil {
134-
return nil, err
135-
}
136-
137-
c.bearerAuth = connInfo.Token
138-
parsedURL, err := url.Parse(connInfo.IPAddress)
139-
if err != nil {
140-
return nil, err
141-
}
142-
143-
tlsConfig := &tls.Config{InsecureSkipVerify: false}
144-
creds := credentials.NewTLS(tlsConfig)
145-
146-
conn, err := grpc.Dial(parsedURL.Host, grpc.WithTransportCredentials(creds))
147-
if err != nil {
148-
return nil, err
149-
}
150-
vzConn = conn
151-
}
152126

153127
var encOpts, decOpts *vizierpb.ExecuteScriptRequest_EncryptionOptions
154128
if c.useEncryption {

cloud.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ type VizierInfo struct {
4848
Status VizierStatus
4949
// Version of the installed vizier.
5050
Version string
51-
// DirectAccess says the cluster has direct access mode enabled. This means the data transfer will bypass the cloud.
52-
DirectAccess bool
5351
}
5452

5553
func clusterStatusToVizierStatus(status cloudpb.ClusterStatus) VizierStatus {
@@ -78,11 +76,10 @@ func (c *Client) ListViziers(ctx context.Context) ([]*VizierInfo, error) {
7876
viziers := make([]*VizierInfo, 0)
7977
for _, v := range res.Clusters {
8078
viziers = append(viziers, &VizierInfo{
81-
Name: v.ClusterName,
82-
ID: utils.ProtoToUUIDStr(v.ID),
83-
Version: v.VizierVersion,
84-
Status: clusterStatusToVizierStatus(v.Status),
85-
DirectAccess: !v.Config.PassthroughEnabled,
79+
Name: v.ClusterName,
80+
ID: utils.ProtoToUUIDStr(v.ID),
81+
Version: v.VizierVersion,
82+
Status: clusterStatusToVizierStatus(v.Status),
8683
})
8784
}
8885

@@ -106,22 +103,13 @@ func (c *Client) GetVizierInfo(ctx context.Context, clusterID string) (*VizierIn
106103
v := res.Clusters[0]
107104

108105
return &VizierInfo{
109-
Name: v.ClusterName,
110-
ID: utils.ProtoToUUIDStr(v.ID),
111-
Version: v.VizierVersion,
112-
Status: clusterStatusToVizierStatus(v.Status),
113-
DirectAccess: !v.Config.PassthroughEnabled,
106+
Name: v.ClusterName,
107+
ID: utils.ProtoToUUIDStr(v.ID),
108+
Version: v.VizierVersion,
109+
Status: clusterStatusToVizierStatus(v.Status),
114110
}, nil
115111
}
116112

117-
// getConnectionInfo gets the connection info for a cluster using direct mode.
118-
func (c *Client) getConnectionInfo(ctx context.Context, clusterID string) (*cloudpb.GetClusterConnectionInfoResponse, error) {
119-
req := &cloudpb.GetClusterConnectionInfoRequest{
120-
ID: utils.ProtoFromUUIDStrOrNil(clusterID),
121-
}
122-
return c.cmClient.GetClusterConnectionInfo(c.cloudCtxWithMD(ctx), req)
123-
}
124-
125113
// CreateDeployKey creates a new deploy key, with an optional description.
126114
func (c *Client) CreateDeployKey(ctx context.Context, desc string) (*cloudpb.DeploymentKey, error) {
127115
keyMgr := cloudpb.NewVizierDeploymentKeyManagerClient(c.grpcConn)

0 commit comments

Comments
 (0)