Skip to content

Commit 97a38e0

Browse files
authored
Merge pull request #21 from threefoldtech/main-sync-zos3
sync with zos3
2 parents a287850 + 2c85edf commit 97a38e0

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

cmds/modules/provisiond/main.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func integrityChecks(ctx context.Context, rootDir string) error {
9191
// runChecks starts provisiond with the special flag `--integrity` which runs some
9292
// checks and return an error if checks did not pass.
9393
// if an error is received the db files are cleaned
94-
func runChecks(ctx context.Context, rootDir string) error {
94+
func runChecks(ctx context.Context, rootDir string, cl zbus.Client) error {
9595
log.Info().Msg("run integrity checks")
9696
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
9797
defer cancel()
@@ -110,6 +110,13 @@ func runChecks(ctx context.Context, rootDir string) error {
110110

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

113+
zui := stubs.NewZUIStub(cl)
114+
if er := zui.PushErrors(ctx, "integrity", []string{
115+
fmt.Sprintf("integrity check failed, resetting rrd db stderr=%s: %v", buf.String(), err),
116+
}); er != nil {
117+
log.Error().Err(er).Msg("failed to push errors to zui")
118+
}
119+
113120
// other error, we can try to clean up and continue
114121
return os.RemoveAll(filepath.Join(rootDir, metricsStorageDB))
115122
}
@@ -121,6 +128,14 @@ func action(cli *cli.Context) error {
121128
integrity bool = cli.Bool("integrity")
122129
)
123130

131+
server, err := zbus.NewRedisServer(serverName, msgBrokerCon, 1)
132+
if err != nil {
133+
return errors.Wrap(err, "failed to connect to message broker")
134+
}
135+
cl, err := zbus.NewRedisClient(msgBrokerCon)
136+
if err != nil {
137+
return errors.Wrap(err, "fail to connect to message broker server")
138+
}
124139
ctx, _ := utils.WithSignal(context.Background())
125140

126141
if integrity {
@@ -132,7 +147,7 @@ func action(cli *cli.Context) error {
132147
})
133148

134149
// run integrityChecks
135-
if err := runChecks(ctx, rootDir); err != nil {
150+
if err := runChecks(ctx, rootDir, cl); err != nil {
136151
return errors.Wrap(err, "error running integrity checks")
137152
}
138153

@@ -160,15 +175,6 @@ func action(cli *cli.Context) error {
160175
select {}
161176
}
162177

163-
server, err := zbus.NewRedisServer(serverName, msgBrokerCon, 1)
164-
if err != nil {
165-
return errors.Wrap(err, "failed to connect to message broker")
166-
}
167-
cl, err := zbus.NewRedisClient(msgBrokerCon)
168-
if err != nil {
169-
return errors.Wrap(err, "fail to connect to message broker server")
170-
}
171-
172178
identity := stubs.NewIdentityManagerStub(cl)
173179
sk := ed25519.PrivateKey(identity.PrivateKey(ctx))
174180

pkg/registrar/registrar.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const (
2323
InProgress RegistrationState = "InProgress"
2424
Done RegistrationState = "Done"
2525

26-
monitorAccountEvery = 30 * time.Minute
26+
monitorAccountEvery = 30 * time.Minute
27+
updateNodeInfoInterval = 24 * time.Hour
2728
)
2829

2930
var (
@@ -146,6 +147,9 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen
146147
if err := r.reActivate(ctx, cl, env); err != nil {
147148
log.Error().Err(err).Msg("failed to reactivate account")
148149
}
150+
case <-time.After(updateNodeInfoInterval):
151+
log.Info().Msg("update interval passed, re-register")
152+
register()
149153
case <-addressesUpdate:
150154
log.Info().Msg("zos address has changed, re-register")
151155
register()

0 commit comments

Comments
 (0)