Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update disks error messages #10

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmds/modules/powerd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var Module cli.Command = cli.Command{
func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
powerdLabel string = "powerd"
)

ctx, _ := utils.WithSignal(cli.Context)
Expand All @@ -51,16 +52,28 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "failed to connect to message broker server")
}

zui := stubs.NewZUIStub(cl)
// empty out zui errors for powerd
if zuiErr := zui.PushErrors(cli.Context, powerdLabel, []string{}); zuiErr != nil {
log.Info().Err(zuiErr).Send()
}

identity := stubs.NewIdentityManagerStub(cl)
register := stubs.NewRegistrarStub(cl)

nodeID, err := register.NodeID(ctx)
if err != nil {
if zuiErr := zui.PushErrors(cli.Context, powerdLabel, []string{err.Error()}); zuiErr != nil {
log.Info().Err(zuiErr).Send()
}
return errors.Wrap(err, "failed to get node id")
}

twinID, err := register.TwinID(ctx)
if err != nil {
if zuiErr := zui.PushErrors(cli.Context, powerdLabel, []string{err.Error()}); zuiErr != nil {
log.Info().Err(zuiErr).Send()
}
return errors.Wrap(err, "failed to get twin id")
}

Expand Down
17 changes: 15 additions & 2 deletions cmds/modules/zui/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"github.com/gizak/termui/v3/widgets"
"github.com/pkg/errors"

"github.com/rs/zerolog/log"
"github.com/threefoldtech/zbus"
"github.com/threefoldtech/zos/pkg/app"
"github.com/threefoldtech/zos/pkg/environment"
Expand Down Expand Up @@ -54,6 +56,14 @@ func headerRenderer(ctx context.Context, c zbus.Client, h *widgets.Paragraph, r
}

go func() {
registrarLable := "registrar"
zui := stubs.NewZUIStub(c)

// empty out zui errors for registrar
if zuiErr := zui.PushErrors(ctx, registrarLable, []string{}); zuiErr != nil {
log.Info().Err(zuiErr).Send()
}

farmID, _ := identity.FarmID(ctx)
for version := range ch {
var name string
Expand All @@ -69,15 +79,18 @@ func headerRenderer(ctx context.Context, c zbus.Client, h *widgets.Paragraph, r
if isInProgressError(err) {
nodeID = green(err.Error())
} else {
nodeID = red(err.Error())
nodeID = red(fmt.Sprintf("%d (unregistered)", node))
if zuiErr := zui.PushErrors(ctx, registrarLable, []string{err.Error()}); zuiErr != nil {
log.Info().Err(zuiErr).Send()
}
}
} else {
nodeID = green(fmt.Sprint(node))
}

cache := green("OK")
if app.CheckFlag(app.LimitedCache) {
cache = red("no ssd disks detected")
cache = red("no ssd disks detected, running on hdd-only mode")
} else if app.CheckFlag(app.ReadonlyCache) {
cache = red("cache is read-only")
}
Expand Down
Loading