Skip to content

Commit 7410371

Browse files
committed
Update handling of missing kernel headers to better reflect warning status
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 1c39c87 commit 7410371

5 files changed

Lines changed: 47 additions & 27 deletions

File tree

src/pixie_cli/pkg/cmd/deploy.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ func waitForHealthCheckTaskGenerator(cloudAddr string, clusterID uuid.UUID) func
620620
}
621621
// The health check warning error indicates the cluster successfully deployed, but there are some warnings.
622622
// Return the error to end the polling and show the warnings.
623-
if _, ok := err.(*vizier.HealthCheckWarning); ok {
623+
if _, ok := err.(*components.UIWarning); ok {
624624
return err
625625
}
626626
time.Sleep(5 * time.Second)
@@ -642,15 +642,13 @@ func waitForHealthCheck(cloudAddr string, clusterID uuid.UUID, clientset *kubern
642642
hc := utils.NewSerialTaskRunner(healthCheckJobs)
643643
err := hc.RunAndMonitor()
644644
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-
})
645+
_ = pxanalytics.Client().Enqueue(&analytics.Track{
646+
UserId: pxconfig.Cfg().UniqueClientID,
647+
Event: "Deploy Healthcheck Failed",
648+
Properties: analytics.NewProperties().
649+
Set("err", err.Error()),
650+
})
651+
if _, ok := err.(*components.UIWarning); !ok {
654652
utils.WithError(err).Fatal("Failed Pixie healthcheck")
655653
}
656654
}

src/pixie_cli/pkg/components/spinner.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func (d *statusDecorator) Decor(stat *decor.Statistics) string {
108108
return ""
109109
}
110110
if d.err != nil {
111+
if _, ok := d.err.(*UIWarning); ok {
112+
return StatusWarn(d.width)
113+
}
111114
return StatusErr(d.width)
112115
}
113116
return StatusOK(d.width)
@@ -136,6 +139,9 @@ func (d *errorViewDecorator) Decor(stat *decor.Statistics) string {
136139
if d.err == nil {
137140
return ""
138141
}
142+
if _, ok := d.err.(*UIWarning); ok {
143+
return color.YellowString(fmt.Sprintf(" WARN: %s", d.err.Error()))
144+
}
139145
return color.RedString(fmt.Sprintf(" ERR: %s", d.err.Error()))
140146
}
141147

src/pixie_cli/pkg/components/status.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,26 @@ import (
2525
)
2626

2727
var (
28-
statusOK = "\u2714"
29-
statusErr = "\u2715"
28+
statusOK = "\u2714"
29+
statusErr = "\u2715"
30+
statusWarn = "\u26a0"
3031
)
3132

33+
// UIWarning is a wrapper type that marks errors as warnings for UI display.
34+
// Errors wrapped in UIWarning will be displayed with yellow warning colors
35+
// instead of red error colors in the spinner table.
36+
type UIWarning struct {
37+
Err error
38+
}
39+
40+
func (w UIWarning) Error() string {
41+
return w.Err.Error()
42+
}
43+
44+
func (w UIWarning) Unwrap() error {
45+
return w.Err
46+
}
47+
3248
func computePadding(s string, pad int) (int, int) {
3349
var padS, padE int
3450
pad -= len([]rune(s))
@@ -55,3 +71,9 @@ func StatusErr(pad int) string {
5571
padS, padE := computePadding(statusErr, pad)
5672
return strings.Repeat(" ", padS) + color.RedString(statusErr) + strings.Repeat(" ", padE)
5773
}
74+
75+
// StatusWarn prints out the default Warn symbol, center padded to the size specified.
76+
func StatusWarn(pad int) string {
77+
padS, padE := computePadding(statusWarn, pad)
78+
return strings.Repeat(" ", padS) + color.YellowString(statusWarn) + strings.Repeat(" ", padE)
79+
}

src/pixie_cli/pkg/vizier/logs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"k8s.io/client-go/kubernetes"
3131
"k8s.io/client-go/rest"
3232

33+
"px.dev/pixie/src/pixie_cli/pkg/components"
3334
"px.dev/pixie/src/utils/script"
3435
"px.dev/pixie/src/utils/shared/k8s"
3536
)
@@ -132,7 +133,7 @@ func (c *LogCollector) CollectPixieLogs(fName string) error {
132133
outputCh, err := RunSimpleHealthCheckScript(c.br, c.cloudAddr, clusterID)
133134
if err != nil {
134135
entry := log.WithError(err)
135-
if _, ok := err.(*HealthCheckWarning); ok {
136+
if _, ok := err.(*components.UIWarning); ok {
136137
entry.Warn("healthcheck script detected the following warnings:")
137138
} else {
138139
entry.Warn("failed to run healthcheck script")

src/pixie_cli/pkg/vizier/script.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ import (
4444
)
4545

4646
const (
47-
equalityThreshold = 0.01
48-
headersInstalledPercColumn = "headers_installed_percent" // must match the column in px/agent_status_diagnostics
47+
equalityThreshold = 0.01
48+
headersInstalledPercColumn = "headers_installed_percent" // must match the column in px/agent_status_diagnostics
49+
missingKernelHeadersMsg = "Detected missing kernel headers on your cluster's nodes. This may cause issues with the Pixie agent. Please see https://px.dev/kernel-headers for more details."
50+
missingKernelHeadersSuspectedMsg = "Detected missing kernel headers on your cluster's nodes. This may cause issues with the Pixie agent. Please see https://px.dev/kernel-headers for more details. If you are using a distro kernel, this is expected and can be ignored."
4951
)
5052

5153
type taskWrapper struct {
@@ -266,16 +268,8 @@ func RunScript(ctx context.Context, conns []*Connector, execScript *script.Execu
266268
return mergedResponses, nil
267269
}
268270

269-
type HealthCheckWarning struct {
270-
message string
271-
}
272-
273-
func (h *HealthCheckWarning) Error() string {
274-
return h.message
275-
}
276-
277271
func newHealthCheckWarning(message string) error {
278-
return &HealthCheckWarning{message}
272+
return &components.UIWarning{Err: fmt.Errorf("%s", message)}
279273
}
280274

281275
func evaluateHealthCheckResult(output string) error {
@@ -289,12 +283,11 @@ func evaluateHealthCheckResult(output string) error {
289283
switch t := v.(type) {
290284
case float64:
291285
if math.Abs(1.0-t) > equalityThreshold {
292-
msg := "Detected missing kernel headers on your cluster's nodes. This may cause issues with the Pixie agent. Please install kernel headers on all nodes."
293-
return newHealthCheckWarning(msg)
286+
return &components.UIWarning{Err: fmt.Errorf("%s", missingKernelHeadersMsg)}
294287
}
295288
}
296289
} else {
297-
return newHealthCheckWarning("Unable to detect if the cluster's nodes have the distro kernel headers installed (vizier too old to perform this check). Please ensure that the kernel headers are installed on all nodes.")
290+
return &components.UIWarning{Err: fmt.Errorf("%s", missingKernelHeadersSuspectedMsg)}
298291
}
299292
return nil
300293
}

0 commit comments

Comments
 (0)