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

limit healthcheck retries #2394

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from 1 commit
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: 12 additions & 1 deletion pkg/perf/healthcheck/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"time"

"github.com/cenkalti/backoff/v3"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/threefoldtech/zos/pkg/zinit"
Expand All @@ -17,8 +18,18 @@ const acceptableSkew = 10 * time.Minute
func RunNTPCheck(ctx context.Context) {
go func() {
for {
if err := ntpCheck(); err != nil {
exp := backoff.NewExponentialBackOff()
check := func() error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? in retryNotify you can use ntpCheck directly no?

return ntpCheck()
}

retryNotify := func(err error, d time.Duration) {
log.Error().Err(err).Msg("failed to run ntp check")
}

err := backoff.RetryNotify(check, backoff.WithContext(exp, ctx), retryNotify)
if err != nil {
log.Error().Err(err).Send()
continue
}

Expand Down
Loading