@@ -22,6 +22,7 @@ import (
2222 "context"
2323 "errors"
2424 "fmt"
25+ "io"
2526 "os"
2627 "strings"
2728 "time"
@@ -71,7 +72,6 @@ var BlockListedLabels = []string{
7172}
7273
7374func init () {
74- DeployCmd .Flags ().StringP ("bundle" , "b" , "" , "Path/URL to bundle file" )
7575 DeployCmd .Flags ().StringP ("extract_yaml" , "e" , "" , "Directory to extract the Pixie yamls to" )
7676 DeployCmd .Flags ().StringP ("vizier_version" , "v" , "" , "Pixie version to deploy" )
7777 DeployCmd .Flags ().BoolP ("check" , "c" , true , "Check whether the cluster can run Pixie" )
@@ -106,7 +106,6 @@ var DeployCmd = &cobra.Command{
106106 Use : "deploy" ,
107107 Short : "Deploys Pixie on the current K8s cluster" ,
108108 PreRun : func (cmd * cobra.Command , args []string ) {
109- viper .BindPFlag ("bundle" , cmd .Flags ().Lookup ("bundle" ))
110109 viper .BindPFlag ("extract_yaml" , cmd .Flags ().Lookup ("extract_yaml" ))
111110 viper .BindPFlag ("vizier_version" , cmd .Flags ().Lookup ("vizier_version" ))
112111 viper .BindPFlag ("check" , cmd .Flags ().Lookup ("check" ))
@@ -605,6 +604,61 @@ func deploy(cloudConn *grpc.ClientConn, clientset *kubernetes.Clientset, vzClien
605604 return clusterID
606605}
607606
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+
608662func waitForHealthCheckTaskGenerator (cloudAddr string , clusterID uuid.UUID ) func () error {
609663 return func () error {
610664 timeout := time .NewTimer (5 * time .Minute )
@@ -614,15 +668,10 @@ func waitForHealthCheckTaskGenerator(cloudAddr string, clusterID uuid.UUID) func
614668 case <- timeout .C :
615669 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`)" )
616670 default :
617- _ , err := vizier . RunSimpleHealthCheckScript ( mustCreateBundleReader (), cloudAddr , clusterID )
671+ err := runSimpleHealthCheckScript ( cloudAddr , clusterID )
618672 if err == nil {
619673 return nil
620674 }
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- }
626675 time .Sleep (5 * time .Second )
627676 }
628677 }
@@ -642,17 +691,13 @@ func waitForHealthCheck(cloudAddr string, clusterID uuid.UUID, clientset *kubern
642691 hc := utils .NewSerialTaskRunner (healthCheckJobs )
643692 err := hc .RunAndMonitor ()
644693 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" )
656701 }
657702 _ = pxanalytics .Client ().Enqueue (& analytics.Track {
658703 UserId : pxconfig .Cfg ().UniqueClientID ,
0 commit comments