Skip to content

Commit

Permalink
Revert "Use px/agent_status_diagnostics script within px cli to det…
Browse files Browse the repository at this point in the history
…ect missing kernel headers (#2065)"

This reverts commit 3c9c4bd.

Signed-off-by: Dom Del Nano <[email protected]>
  • Loading branch information
ddelnano committed Jan 16, 2025
1 parent a63b134 commit 0b8a3c5
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 329 deletions.
4 changes: 2 additions & 2 deletions src/pixie_cli/pkg/cmd/collect_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/spf13/viper"

"px.dev/pixie/src/pixie_cli/pkg/utils"
"px.dev/pixie/src/pixie_cli/pkg/vizier"
"px.dev/pixie/src/utils/shared/k8s"
)

func init() {
Expand All @@ -42,7 +42,7 @@ var CollectLogsCmd = &cobra.Command{
viper.BindPFlag("namespace", cmd.Flags().Lookup("namespace"))
},
Run: func(cmd *cobra.Command, args []string) {
c := vizier.NewLogCollector(mustCreateBundleReader(), viper.GetString("cloud_addr"))
c := k8s.NewLogCollector()
fName := fmt.Sprintf("pixie_logs_%s.zip", time.Now().Format("20060102150405"))
err := c.CollectPixieLogs(fName)
if err != nil {
Expand Down
83 changes: 64 additions & 19 deletions src/pixie_cli/pkg/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"errors"
"fmt"
"io"
"os"
"strings"
"time"
Expand Down Expand Up @@ -71,7 +72,6 @@ var BlockListedLabels = []string{
}

func init() {
DeployCmd.Flags().StringP("bundle", "b", "", "Path/URL to bundle file")
DeployCmd.Flags().StringP("extract_yaml", "e", "", "Directory to extract the Pixie yamls to")
DeployCmd.Flags().StringP("vizier_version", "v", "", "Pixie version to deploy")
DeployCmd.Flags().BoolP("check", "c", true, "Check whether the cluster can run Pixie")
Expand Down Expand Up @@ -106,7 +106,6 @@ var DeployCmd = &cobra.Command{
Use: "deploy",
Short: "Deploys Pixie on the current K8s cluster",
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlag("bundle", cmd.Flags().Lookup("bundle"))
viper.BindPFlag("extract_yaml", cmd.Flags().Lookup("extract_yaml"))
viper.BindPFlag("vizier_version", cmd.Flags().Lookup("vizier_version"))
viper.BindPFlag("check", cmd.Flags().Lookup("check"))
Expand Down Expand Up @@ -605,6 +604,61 @@ func deploy(cloudConn *grpc.ClientConn, clientset *kubernetes.Clientset, vzClien
return clusterID
}

func runSimpleHealthCheckScript(cloudAddr string, clusterID uuid.UUID) error {
v, err := vizier.ConnectionToVizierByID(cloudAddr, clusterID)
br := mustCreateBundleReader()
if err != nil {
return err
}
execScript := br.MustGetScript(script.AgentStatusScript)

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

resp, err := v.ExecuteScriptStream(ctx, execScript, nil)
if err != nil {
return err
}

// TODO(zasgar): Make this use the Null output. We can't right now
// because of fatal message on vizier failure.
errCh := make(chan error)
// Eat all responses.
go func() {
for {
select {
case <-ctx.Done():
if ctx.Err() != nil {
errCh <- ctx.Err()
return
}
errCh <- nil
return
case msg := <-resp:
if msg == nil {
errCh <- nil
return
}
if msg.Err != nil {
if msg.Err == io.EOF {
errCh <- nil
return
}
errCh <- msg.Err
return
}
if msg.Resp.Status != nil && msg.Resp.Status.Code != 0 {
errCh <- errors.New(msg.Resp.Status.Message)
}
// Eat messages.
}
}
}()

err = <-errCh
return err
}

func waitForHealthCheckTaskGenerator(cloudAddr string, clusterID uuid.UUID) func() error {
return func() error {
timeout := time.NewTimer(5 * time.Minute)
Expand All @@ -614,15 +668,10 @@ func waitForHealthCheckTaskGenerator(cloudAddr string, clusterID uuid.UUID) func
case <-timeout.C:
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`)")
default:
_, err := vizier.RunSimpleHealthCheckScript(mustCreateBundleReader(), cloudAddr, clusterID)
err := runSimpleHealthCheckScript(cloudAddr, clusterID)
if err == nil {
return nil
}
// The health check warning error indicates the cluster successfully deployed, but there are some warnings.
// Return the error to end the polling and show the warnings.
if _, ok := err.(*vizier.HealthCheckWarning); ok {
return err
}
time.Sleep(5 * time.Second)
}
}
Expand All @@ -642,17 +691,13 @@ func waitForHealthCheck(cloudAddr string, clusterID uuid.UUID, clientset *kubern
hc := utils.NewSerialTaskRunner(healthCheckJobs)
err := hc.RunAndMonitor()
if err != nil {
if _, ok := err.(*vizier.HealthCheckWarning); ok {
utils.WithError(err).Error("Pixie healthcheck detected the following warnings:")
} else {
_ = pxanalytics.Client().Enqueue(&analytics.Track{
UserId: pxconfig.Cfg().UniqueClientID,
Event: "Deploy Healthcheck Failed",
Properties: analytics.NewProperties().
Set("err", err.Error()),
})
utils.WithError(err).Fatal("Failed Pixie healthcheck")
}
_ = pxanalytics.Client().Enqueue(&analytics.Track{
UserId: pxconfig.Cfg().UniqueClientID,
Event: "Deploy Healthcheck Failed",
Properties: analytics.NewProperties().
Set("err", err.Error()),
})
utils.WithError(err).Fatal("Failed Pixie healthcheck")
}
_ = pxanalytics.Client().Enqueue(&analytics.Track{
UserId: pxconfig.Cfg().UniqueClientID,
Expand Down
5 changes: 3 additions & 2 deletions src/pixie_cli/pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ var RootCmd = &cobra.Command{

// Name a variable to store a slice of commands that don't require cloudAddr
var cmdsCloudAddrNotReqd = []*cobra.Command{
CollectLogsCmd,
VersionCmd,
}

Expand Down Expand Up @@ -244,7 +245,7 @@ func checkAuthForCmd(c *cobra.Command) {
os.Exit(1)
}
switch c {
case CollectLogsCmd, DeployCmd, UpdateCmd, GetCmd, DeployKeyCmd, APIKeyCmd:
case DeployCmd, UpdateCmd, GetCmd, DeployKeyCmd, APIKeyCmd:
utils.Errorf("These commands are unsupported in Direct Vizier mode.")
os.Exit(1)
default:
Expand All @@ -253,7 +254,7 @@ func checkAuthForCmd(c *cobra.Command) {
}

switch c {
case CollectLogsCmd, DeployCmd, UpdateCmd, RunCmd, LiveCmd, GetCmd, ScriptCmd, DeployKeyCmd, APIKeyCmd:
case DeployCmd, UpdateCmd, RunCmd, LiveCmd, GetCmd, ScriptCmd, DeployKeyCmd, APIKeyCmd:
authenticated := auth.IsAuthenticated(viper.GetString("cloud_addr"))
if !authenticated {
utils.Errorf("Failed to authenticate. Please retry `px auth login`.")
Expand Down
1 change: 0 additions & 1 deletion src/pixie_cli/pkg/vizier/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ go_library(
"data_formatter.go",
"errors.go",
"lister.go",
"logs.go",
"script.go",
"stream_adapter.go",
"utils.go",
Expand Down
144 changes: 0 additions & 144 deletions src/pixie_cli/pkg/vizier/logs.go

This file was deleted.

Loading

0 comments on commit 0b8a3c5

Please sign in to comment.