Skip to content

Commit 9213b66

Browse files
authored
Merge pull request #10 from threefoldtech/update-disks-error-messages
Update disks error messages
2 parents 9347af9 + f38c317 commit 9213b66

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

cmds/modules/powerd/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var Module cli.Command = cli.Command{
3737
func action(cli *cli.Context) error {
3838
var (
3939
msgBrokerCon string = cli.String("broker")
40+
powerdLabel string = "powerd"
4041
)
4142

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

55+
zui := stubs.NewZUIStub(cl)
56+
// empty out zui errors for powerd
57+
if zuiErr := zui.PushErrors(cli.Context, powerdLabel, []string{}); zuiErr != nil {
58+
log.Info().Err(zuiErr).Send()
59+
}
60+
5461
identity := stubs.NewIdentityManagerStub(cl)
5562
register := stubs.NewRegistrarStub(cl)
5663

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

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

cmds/modules/zui/header.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"github.com/gizak/termui/v3/widgets"
1111
"github.com/pkg/errors"
12+
13+
"github.com/rs/zerolog/log"
1214
"github.com/threefoldtech/zbus"
1315
"github.com/threefoldtech/zos/pkg/app"
1416
"github.com/threefoldtech/zos/pkg/environment"
@@ -54,6 +56,14 @@ func headerRenderer(ctx context.Context, c zbus.Client, h *widgets.Paragraph, r
5456
}
5557

5658
go func() {
59+
registrarLable := "registrar"
60+
zui := stubs.NewZUIStub(c)
61+
62+
// empty out zui errors for registrar
63+
if zuiErr := zui.PushErrors(ctx, registrarLable, []string{}); zuiErr != nil {
64+
log.Info().Err(zuiErr).Send()
65+
}
66+
5767
farmID, _ := identity.FarmID(ctx)
5868
for version := range ch {
5969
var name string
@@ -69,15 +79,18 @@ func headerRenderer(ctx context.Context, c zbus.Client, h *widgets.Paragraph, r
6979
if isInProgressError(err) {
7080
nodeID = green(err.Error())
7181
} else {
72-
nodeID = red(err.Error())
82+
nodeID = red(fmt.Sprintf("%d (unregistered)", node))
83+
if zuiErr := zui.PushErrors(ctx, registrarLable, []string{err.Error()}); zuiErr != nil {
84+
log.Info().Err(zuiErr).Send()
85+
}
7386
}
7487
} else {
7588
nodeID = green(fmt.Sprint(node))
7689
}
7790

7891
cache := green("OK")
7992
if app.CheckFlag(app.LimitedCache) {
80-
cache = red("no ssd disks detected")
93+
cache = red("no ssd disks detected, running on hdd-only mode")
8194
} else if app.CheckFlag(app.ReadonlyCache) {
8295
cache = red("cache is read-only")
8396
}

0 commit comments

Comments
 (0)