@@ -308,6 +308,7 @@ func startProcess(ctx context.Context, k8sClient kubernetes.Interface, cfg *rest
308
308
exec , err := getExecutor (k8sClient , cfg , podName , namespace , containerName , cmd , true , true )
309
309
310
310
if err != nil {
311
+ log .Println ("error in getting terminal executor " , "err: " , err )
311
312
return err
312
313
}
313
314
@@ -323,6 +324,7 @@ func startProcess(ctx context.Context, k8sClient kubernetes.Interface, cfg *rest
323
324
terminalSessions .SetTerminalSessionStartTime (sessionRequest .SessionId )
324
325
err = execWithStreamOptions (ctx , exec , streamOptions )
325
326
if err != nil {
327
+ log .Println ("error in terminal exec with stream opts: " , "err: " , err )
326
328
return err
327
329
}
328
330
return nil
@@ -506,7 +508,7 @@ func (impl *TerminalSessionHandlerImpl) GetTerminalSession(req *TerminalSessionR
506
508
namespace : req .Namespace ,
507
509
clusterId : strconv .Itoa (req .ClusterId ),
508
510
})
509
- config , client , err := impl .getClientConfig (req )
511
+ config , client , err := impl .getClientSetAndRestConfigForTerminalConn (req )
510
512
511
513
go func () {
512
514
err := impl .saveEphemeralContainerTerminalAccessAudit (req )
@@ -523,7 +525,7 @@ func (impl *TerminalSessionHandlerImpl) GetTerminalSession(req *TerminalSessionR
523
525
return http .StatusOK , & TerminalMessage {SessionID : sessionID }, nil
524
526
}
525
527
526
- func (impl * TerminalSessionHandlerImpl ) getClientConfig (req * TerminalSessionRequest ) (* rest.Config , * kubernetes.Clientset , error ) {
528
+ func (impl * TerminalSessionHandlerImpl ) getClientSetAndRestConfigForTerminalConn (req * TerminalSessionRequest ) (* rest.Config , * kubernetes.Clientset , error ) {
527
529
var clusterBean * cluster.ClusterBean
528
530
var clusterConfig * k8s.ClusterConfig
529
531
var restConfig * rest.Config
@@ -534,6 +536,13 @@ func (impl *TerminalSessionHandlerImpl) getClientConfig(req *TerminalSessionRequ
534
536
impl .logger .Errorw ("error in getting rest config" , "err" , err , "clusterId" , req .ClusterId , "externalArgoApplicationName" , req .ExternalArgoApplicationName )
535
537
return nil , nil , err
536
538
}
539
+
540
+ _ , clientSet , err := impl .k8sUtil .GetK8sConfigAndClientsByRestConfig (restConfig )
541
+ if err != nil {
542
+ impl .logger .Errorw ("error in clientSet" , "err" , err )
543
+ return nil , nil , err
544
+ }
545
+ return restConfig , clientSet , nil
537
546
} else {
538
547
if req .ClusterId != 0 {
539
548
clusterBean , err = impl .clusterService .FindById (req .ClusterId )
@@ -561,14 +570,22 @@ func (impl *TerminalSessionHandlerImpl) getClientConfig(req *TerminalSessionRequ
561
570
impl .logger .Errorw ("error in getting rest config by cluster" , "err" , err , "clusterName" , clusterConfig .ClusterName )
562
571
return nil , nil , err
563
572
}
573
+
574
+ _ , clientSet , err := impl .k8sUtil .GetK8sConfigAndClientsByRestConfig (restConfig )
575
+ if err != nil {
576
+ impl .logger .Errorw ("error in clientSet" , "err" , err )
577
+ return nil , nil , err
578
+ }
579
+
580
+ // we have to get the clientSet before setting the custom transport to nil
581
+ // we need re populate the tls config in the restConfig.
582
+ // rest config with custom transport will break spdy client
583
+ clusterConfig .PopulateTlsConfigurationsInto (restConfig )
584
+ restConfig .Transport = nil
585
+ return restConfig , clientSet , nil
564
586
}
565
- _ , clientSet , err := impl .k8sUtil .GetK8sConfigAndClientsByRestConfig (restConfig )
566
- if err != nil {
567
- impl .logger .Errorw ("error in clientSet" , "err" , err )
568
- return nil , nil , err
569
- }
570
- return restConfig , clientSet , nil
571
587
}
588
+
572
589
func (impl * TerminalSessionHandlerImpl ) AutoSelectShell (req * TerminalSessionRequest ) (string , error ) {
573
590
var err1 error
574
591
for _ , testShell := range validShells {
@@ -614,7 +631,7 @@ func getErrorMsg(err string) error {
614
631
}
615
632
616
633
func (impl * TerminalSessionHandlerImpl ) RunCmdInRemotePod (req * TerminalSessionRequest , cmds []string ) (* bytes.Buffer , * bytes.Buffer , error ) {
617
- config , client , err := impl .getClientConfig (req )
634
+ config , client , err := impl .getClientSetAndRestConfigForTerminalConn (req )
618
635
if err != nil {
619
636
impl .logger .Errorw ("error in fetching config" , "err" , err )
620
637
return nil , nil , err
0 commit comments