Skip to content

Commit

Permalink
Merge pull request #2424 from threefoldtech/main_zui_errors
Browse files Browse the repository at this point in the history
push the integrity error to zui
  • Loading branch information
Omarabdul3ziz authored Sep 26, 2024
2 parents 0e077bb + 84e6232 commit f5a711d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions cmds/modules/provisiond/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func integrityChecks(ctx context.Context, rootDir string) error {
// runChecks starts provisiond with the special flag `--integrity` which runs some
// checks and return an error if checks did not pass.
// if an error is received the db files are cleaned
func runChecks(ctx context.Context, rootDir string) error {
func runChecks(ctx context.Context, rootDir string, cl zbus.Client) error {
log.Info().Msg("run integrity checks")
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
Expand All @@ -111,6 +111,13 @@ func runChecks(ctx context.Context, rootDir string) error {

log.Error().Str("stderr", buf.String()).Err(err).Msg("integrity check failed, resetting rrd db")

zui := stubs.NewZUIStub(cl)
if er := zui.PushErrors(ctx, "integrity", []string{
fmt.Sprintf("integrity check failed, resetting rrd db stderr=%s: %v", buf.String(), err),
}); er != nil {
log.Error().Err(er).Msg("failed to push errors to zui")
}

// other error, we can try to clean up and continue
return os.RemoveAll(filepath.Join(rootDir, metricsStorageDB))
}
Expand All @@ -122,6 +129,15 @@ func action(cli *cli.Context) error {
integrity bool = cli.Bool("integrity")
)

server, err := zbus.NewRedisServer(serverName, msgBrokerCon, 1)
if err != nil {
return errors.Wrap(err, "failed to connect to message broker")
}
cl, err := zbus.NewRedisClient(msgBrokerCon)
if err != nil {
return errors.Wrap(err, "fail to connect to message broker server")
}

ctx, _ := utils.WithSignal(context.Background())

if integrity {
Expand All @@ -133,7 +149,7 @@ func action(cli *cli.Context) error {
})

// run integrityChecks
if err := runChecks(ctx, rootDir); err != nil {
if err := runChecks(ctx, rootDir, cl); err != nil {
return errors.Wrap(err, "error running integrity checks")
}

Expand Down Expand Up @@ -161,15 +177,6 @@ func action(cli *cli.Context) error {
select {}
}

server, err := zbus.NewRedisServer(serverName, msgBrokerCon, 1)
if err != nil {
return errors.Wrap(err, "failed to connect to message broker")
}
cl, err := zbus.NewRedisClient(msgBrokerCon)
if err != nil {
return errors.Wrap(err, "fail to connect to message broker server")
}

identity := stubs.NewIdentityManagerStub(cl)
sk := ed25519.PrivateKey(identity.PrivateKey(ctx))

Expand Down

0 comments on commit f5a711d

Please sign in to comment.