Skip to content

Commit 13a76ec

Browse files
vihangmcopybaranaut
authored andcommitted
Remove passthrough related stuff from the CLI
Summary: Now that direct mode is no longer supported, passthrough is the one and only mode. Remove some more dead code from the CLI that was used for switching between the two. Test Plan: Cli still builds and works as expected Reviewers: zasgar, michelle Reviewed By: michelle Signed-off-by: Vihang Mehta <vihang@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11747 GitOrigin-RevId: 2ae508a
1 parent 67edcd3 commit 13a76ec

9 files changed

Lines changed: 16 additions & 270 deletions

File tree

src/pixie_cli/pkg/cmd/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ go_library(
2323
"auth.go",
2424
"bindata.gen.go",
2525
"collect_logs.go",
26-
"config.go",
2726
"create_bundle.go",
2827
"create_cloud_certs.go",
2928
"debug.go",
@@ -70,7 +69,6 @@ go_library(
7069
"@com_github_dustin_go_humanize//:go-humanize",
7170
"@com_github_fatih_color//:color",
7271
"@com_github_gofrs_uuid//:uuid",
73-
"@com_github_gogo_protobuf//types",
7472
"@com_github_lestrrat_go_jwx//jwt",
7573
"@com_github_sirupsen_logrus//:logrus",
7674
"@com_github_spf13_cobra//:cobra",

src/pixie_cli/pkg/cmd/config.go

Lines changed: 0 additions & 143 deletions
This file was deleted.

src/pixie_cli/pkg/cmd/get.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,9 @@ var GetViziersCmd = &cobra.Command{
116116

117117
w := components.CreateStreamWriter(format, os.Stdout)
118118
defer w.Finish()
119-
w.SetHeader("viziers", []string{"ClusterName", "ID", "K8s Version", "Vizier Version", "Last Heartbeat", "Passthrough", "Status", "Status Message"})
119+
w.SetHeader("viziers", []string{"ClusterName", "ID", "K8s Version", "Vizier Version", "Last Heartbeat", "Status", "Status Message"})
120120

121121
for _, vz := range vzs {
122-
passthrough := false
123-
if vz.Config != nil {
124-
passthrough = vz.Config.PassthroughEnabled
125-
}
126122
var lastHeartbeat interface{}
127123
lastHeartbeat = vz.LastHeartbeatNs
128124
if format == "" || format == "table" {
@@ -147,7 +143,7 @@ var GetViziersCmd = &cobra.Command{
147143
}
148144
}
149145
_ = w.Write([]interface{}{vz.ClusterName, utils.UUIDFromProtoOrNil(vz.ID), vz.ClusterVersion, sb.String(),
150-
lastHeartbeat, passthrough, vz.Status, vz.StatusMessage})
146+
lastHeartbeat, vz.Status, vz.StatusMessage})
151147
}
152148
},
153149
}

src/pixie_cli/pkg/cmd/root.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func init() {
6464
RootCmd.AddCommand(RunCmd)
6565
RootCmd.AddCommand(LiveCmd)
6666
RootCmd.AddCommand(GetCmd)
67-
RootCmd.AddCommand(ConfigCmd)
6867
RootCmd.AddCommand(ScriptCmd)
6968
RootCmd.AddCommand(CreateBundle)
7069
RootCmd.AddCommand(DeployKeyCmd)
@@ -180,7 +179,7 @@ var RootCmd = &cobra.Command{
180179

181180
func checkAuthForCmd(c *cobra.Command) {
182181
switch c {
183-
case DeployCmd, UpdateCmd, RunCmd, LiveCmd, GetCmd, ConfigCmd, ScriptCmd, DeployKeyCmd, APIKeyCmd:
182+
case DeployCmd, UpdateCmd, RunCmd, LiveCmd, GetCmd, ScriptCmd, DeployKeyCmd, APIKeyCmd:
184183
authenticated := auth.IsAuthenticated(viper.GetString("cloud_addr"))
185184
if !authenticated {
186185
utils.Errorf("Failed to authenticate. Please retry `px auth login`.")

src/pixie_cli/pkg/vizier/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ go_library(
5353
"@io_k8s_client_go//rest",
5454
"@org_golang_google_grpc//:go_default_library",
5555
"@org_golang_google_grpc//codes",
56-
"@org_golang_google_grpc//metadata",
5756
"@org_golang_google_grpc//status",
5857
"@org_golang_x_sync//errgroup",
5958
],

src/pixie_cli/pkg/vizier/client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@
1919
package vizier
2020

2121
import (
22-
"context"
23-
"fmt"
2422
"strings"
2523

2624
"google.golang.org/grpc"
27-
"google.golang.org/grpc/metadata"
2825

2926
"px.dev/pixie/src/api/proto/cloudpb"
3027
"px.dev/pixie/src/shared/services"
3128
)
3229

33-
func ctxWithTokenCreds(ctx context.Context, token string) context.Context {
34-
return metadata.AppendToOutgoingContext(ctx, "authorization", fmt.Sprintf("bearer %s", token))
35-
}
36-
3730
func newVizierClusterInfoClient(cloudAddr string) (cloudpb.VizierClusterInfoClient, error) {
3831
isInternal := strings.ContainsAny(cloudAddr, "cluster.local")
3932

src/pixie_cli/pkg/vizier/connector.go

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,28 @@ import (
4646

4747
const (
4848
dialTimeout = 5 * time.Second
49-
// We need an extra long retryTimeout because in passthrough mode the query broker takes a while to receive the cancel message from the ptproxy.
49+
// We need an extra long retryTimeout because in passthrough mode the query broker
50+
// takes a while to receive the cancel message from the ptproxy.
5051
retryTimeout = 30 * time.Second
5152
sleepBetweenRetries = 1 * time.Second
5253
)
5354

5455
// Connector is an interface to Vizier.
5556
type Connector struct {
5657
// The ID of the vizier.
57-
id uuid.UUID
58-
conn *grpc.ClientConn
59-
vz vizierpb.VizierServiceClient
60-
vzDebug vizierpb.VizierDebugServiceClient
61-
vzToken string
62-
passthroughEnabled bool
63-
cloudAddr string
58+
id uuid.UUID
59+
conn *grpc.ClientConn
60+
vz vizierpb.VizierServiceClient
61+
vzDebug vizierpb.VizierDebugServiceClient
62+
cloudAddr string
6463
}
6564

6665
// NewConnector returns a new connector.
67-
func NewConnector(cloudAddr string, vzInfo *cloudpb.ClusterInfo, conn *ConnectionInfo) (*Connector, error) {
66+
func NewConnector(cloudAddr string, vzInfo *cloudpb.ClusterInfo) (*Connector, error) {
6867
c := &Connector{
6968
id: utils.UUIDFromProtoOrNil(vzInfo.ID),
7069
}
7170
c.cloudAddr = cloudAddr
72-
if vzInfo.Config != nil {
73-
c.passthroughEnabled = vzInfo.Config.PassthroughEnabled
74-
}
7571

7672
err := c.connect(cloudAddr)
7773
if err != nil {
@@ -113,11 +109,6 @@ func (c *Connector) connect(addr string) error {
113109
return nil
114110
}
115111

116-
// PassthroughMode returns true if passthrough mode is enabled.
117-
func (c *Connector) PassthroughMode() bool {
118-
return c.passthroughEnabled
119-
}
120-
121112
func lookupVariable(variable string, computedArgs []script.Arg) (string, error) {
122113
for _, arg := range computedArgs {
123114
if arg.Name == variable {
@@ -235,24 +226,6 @@ func checkForJWTExpired(s *status.Status) bool {
235226
return s.Code() == codes.Unauthenticated && strings.Contains(s.Message(), "invalid auth token")
236227
}
237228

238-
func (c *Connector) getNewVzConnInfo() error {
239-
if c.passthroughEnabled {
240-
return nil
241-
}
242-
243-
l, err := NewLister(c.cloudAddr)
244-
if err != nil {
245-
return err
246-
}
247-
248-
vzConn, err := l.GetVizierConnection(c.id)
249-
if err != nil {
250-
return err
251-
}
252-
c.vzToken = vzConn.Token
253-
return nil
254-
}
255-
256229
type streamState struct {
257230
resp vizierpb.VizierService_ExecuteScriptClient
258231
lastSuccessfulRetry time.Time
@@ -280,10 +253,6 @@ func (c *Connector) handleStream(ctx context.Context, state *streamState, first
280253
}
281254
return retry
282255
} else if checkForJWTExpired(s) {
283-
if err := c.getNewVzConnInfo(); err != nil {
284-
cliUtils.Errorf("Failed to renew auth token with error: %s", err.Error())
285-
return doNotRetry
286-
}
287256
if state.firstErr == nil {
288257
state.firstErr = s.Err()
289258
}
@@ -336,14 +305,7 @@ func (c *Connector) ExecuteScriptStream(ctx context.Context, script *script.Exec
336305
QueryName: scriptName,
337306
}
338307

339-
getAuthCtx := func(ctx context.Context) context.Context {
340-
if c.passthroughEnabled {
341-
return auth.CtxWithCreds(ctx)
342-
}
343-
return ctxWithTokenCreds(ctx, c.vzToken)
344-
}
345-
346-
resp, err := c.vz.ExecuteScript(getAuthCtx(ctx), reqPB)
308+
resp, err := c.vz.ExecuteScript(auth.CtxWithCreds(ctx), reqPB)
347309
if err != nil {
348310
return nil, err
349311
}
@@ -369,7 +331,7 @@ func (c *Connector) ExecuteScriptStream(ctx context.Context, script *script.Exec
369331
}
370332
return
371333
}
372-
s.resp, err = c.restartConnAndResumeExecute(getAuthCtx(ctx), s.queryID)
334+
s.resp, err = c.restartConnAndResumeExecute(auth.CtxWithCreds(ctx), s.queryID)
373335
if err != nil {
374336
continue
375337
}
@@ -393,12 +355,7 @@ func (c *Connector) DebugLogRequest(ctx context.Context, podName string, prev bo
393355
Previous: prev,
394356
Container: container,
395357
}
396-
if c.passthroughEnabled {
397-
ctx = auth.CtxWithCreds(ctx)
398-
} else {
399-
ctx = ctxWithTokenCreds(ctx, c.vzToken)
400-
}
401-
358+
ctx = auth.CtxWithCreds(ctx)
402359
resp, err := c.vzDebug.DebugLog(ctx, reqPB)
403360
if err != nil {
404361
return nil, err
@@ -450,12 +407,7 @@ func (c *Connector) DebugPodsRequest(ctx context.Context) (chan *DebugPodsRespon
450407
reqPB := &vizierpb.DebugPodsRequest{
451408
ClusterID: c.id.String(),
452409
}
453-
if c.passthroughEnabled {
454-
ctx = auth.CtxWithCreds(ctx)
455-
} else {
456-
ctx = ctxWithTokenCreds(ctx, c.vzToken)
457-
}
458-
410+
ctx = auth.CtxWithCreds(ctx)
459411
resp, err := c.vzDebug.DebugPods(ctx, reqPB)
460412
if err != nil {
461413
return nil, err

0 commit comments

Comments
 (0)