Skip to content

Commit afaec4c

Browse files
authored
Merge pull request #2394 from threefoldtech/limit-healthcheck-retries
limit healthcheck retries
2 parents 2468196 + 397d5d5 commit afaec4c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/perf/healthcheck/ntp.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"time"
99

10+
"github.com/cenkalti/backoff/v3"
1011
"github.com/pkg/errors"
1112
"github.com/rs/zerolog/log"
1213
"github.com/threefoldtech/zos/pkg/zinit"
@@ -17,8 +18,13 @@ const acceptableSkew = 10 * time.Minute
1718
func RunNTPCheck(ctx context.Context) {
1819
go func() {
1920
for {
20-
if err := ntpCheck(); err != nil {
21+
exp := backoff.NewExponentialBackOff()
22+
retryNotify := func(err error, d time.Duration) {
2123
log.Error().Err(err).Msg("failed to run ntp check")
24+
}
25+
26+
if err := backoff.RetryNotify(ntpCheck, backoff.WithContext(exp, ctx), retryNotify); err != nil {
27+
log.Error().Err(err).Send()
2228
continue
2329
}
2430

0 commit comments

Comments
 (0)