@@ -46,32 +46,28 @@ import (
4646
4747const (
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.
5556type 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-
121112func 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-
256229type 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