@@ -22,6 +22,7 @@ import (
22
22
"context"
23
23
"errors"
24
24
"fmt"
25
+ "io"
25
26
"os"
26
27
"strings"
27
28
"time"
@@ -71,7 +72,6 @@ var BlockListedLabels = []string{
71
72
}
72
73
73
74
func init () {
74
- DeployCmd .Flags ().StringP ("bundle" , "b" , "" , "Path/URL to bundle file" )
75
75
DeployCmd .Flags ().StringP ("extract_yaml" , "e" , "" , "Directory to extract the Pixie yamls to" )
76
76
DeployCmd .Flags ().StringP ("vizier_version" , "v" , "" , "Pixie version to deploy" )
77
77
DeployCmd .Flags ().BoolP ("check" , "c" , true , "Check whether the cluster can run Pixie" )
@@ -106,7 +106,6 @@ var DeployCmd = &cobra.Command{
106
106
Use : "deploy" ,
107
107
Short : "Deploys Pixie on the current K8s cluster" ,
108
108
PreRun : func (cmd * cobra.Command , args []string ) {
109
- viper .BindPFlag ("bundle" , cmd .Flags ().Lookup ("bundle" ))
110
109
viper .BindPFlag ("extract_yaml" , cmd .Flags ().Lookup ("extract_yaml" ))
111
110
viper .BindPFlag ("vizier_version" , cmd .Flags ().Lookup ("vizier_version" ))
112
111
viper .BindPFlag ("check" , cmd .Flags ().Lookup ("check" ))
@@ -605,6 +604,61 @@ func deploy(cloudConn *grpc.ClientConn, clientset *kubernetes.Clientset, vzClien
605
604
return clusterID
606
605
}
607
606
607
+ func runSimpleHealthCheckScript (cloudAddr string , clusterID uuid.UUID ) error {
608
+ v , err := vizier .ConnectionToVizierByID (cloudAddr , clusterID )
609
+ br := mustCreateBundleReader ()
610
+ if err != nil {
611
+ return err
612
+ }
613
+ execScript := br .MustGetScript (script .AgentStatusScript )
614
+
615
+ ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
616
+ defer cancel ()
617
+
618
+ resp , err := v .ExecuteScriptStream (ctx , execScript , nil )
619
+ if err != nil {
620
+ return err
621
+ }
622
+
623
+ // TODO(zasgar): Make this use the Null output. We can't right now
624
+ // because of fatal message on vizier failure.
625
+ errCh := make (chan error )
626
+ // Eat all responses.
627
+ go func () {
628
+ for {
629
+ select {
630
+ case <- ctx .Done ():
631
+ if ctx .Err () != nil {
632
+ errCh <- ctx .Err ()
633
+ return
634
+ }
635
+ errCh <- nil
636
+ return
637
+ case msg := <- resp :
638
+ if msg == nil {
639
+ errCh <- nil
640
+ return
641
+ }
642
+ if msg .Err != nil {
643
+ if msg .Err == io .EOF {
644
+ errCh <- nil
645
+ return
646
+ }
647
+ errCh <- msg .Err
648
+ return
649
+ }
650
+ if msg .Resp .Status != nil && msg .Resp .Status .Code != 0 {
651
+ errCh <- errors .New (msg .Resp .Status .Message )
652
+ }
653
+ // Eat messages.
654
+ }
655
+ }
656
+ }()
657
+
658
+ err = <- errCh
659
+ return err
660
+ }
661
+
608
662
func waitForHealthCheckTaskGenerator (cloudAddr string , clusterID uuid.UUID ) func () error {
609
663
return func () error {
610
664
timeout := time .NewTimer (5 * time .Minute )
@@ -614,15 +668,10 @@ func waitForHealthCheckTaskGenerator(cloudAddr string, clusterID uuid.UUID) func
614
668
case <- timeout .C :
615
669
return errors .New ("timeout waiting for healthcheck (it is possible that Pixie stabilized after the healthcheck timeout. To check if Pixie successfully deployed, run `px debug pods`)" )
616
670
default :
617
- _ , err := vizier . RunSimpleHealthCheckScript ( mustCreateBundleReader (), cloudAddr , clusterID )
671
+ err := runSimpleHealthCheckScript ( cloudAddr , clusterID )
618
672
if err == nil {
619
673
return nil
620
674
}
621
- // The health check warning error indicates the cluster successfully deployed, but there are some warnings.
622
- // Return the error to end the polling and show the warnings.
623
- if _ , ok := err .(* vizier.HealthCheckWarning ); ok {
624
- return err
625
- }
626
675
time .Sleep (5 * time .Second )
627
676
}
628
677
}
@@ -642,17 +691,13 @@ func waitForHealthCheck(cloudAddr string, clusterID uuid.UUID, clientset *kubern
642
691
hc := utils .NewSerialTaskRunner (healthCheckJobs )
643
692
err := hc .RunAndMonitor ()
644
693
if err != nil {
645
- if _ , ok := err .(* vizier.HealthCheckWarning ); ok {
646
- utils .WithError (err ).Error ("Pixie healthcheck detected the following warnings:" )
647
- } else {
648
- _ = pxanalytics .Client ().Enqueue (& analytics.Track {
649
- UserId : pxconfig .Cfg ().UniqueClientID ,
650
- Event : "Deploy Healthcheck Failed" ,
651
- Properties : analytics .NewProperties ().
652
- Set ("err" , err .Error ()),
653
- })
654
- utils .WithError (err ).Fatal ("Failed Pixie healthcheck" )
655
- }
694
+ _ = pxanalytics .Client ().Enqueue (& analytics.Track {
695
+ UserId : pxconfig .Cfg ().UniqueClientID ,
696
+ Event : "Deploy Healthcheck Failed" ,
697
+ Properties : analytics .NewProperties ().
698
+ Set ("err" , err .Error ()),
699
+ })
700
+ utils .WithError (err ).Fatal ("Failed Pixie healthcheck" )
656
701
}
657
702
_ = pxanalytics .Client ().Enqueue (& analytics.Track {
658
703
UserId : pxconfig .Cfg ().UniqueClientID ,
0 commit comments