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

Reduce the frequency of retries and logging when an error occurs #395

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 8 additions & 0 deletions monitor/remote_client_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
if err != nil {
return
}
errCount := 0
errThreshold := 20

Check warning on line 137 in monitor/remote_client_monitor.go

View check run for this annotation

Codecov / codecov/patch

monitor/remote_client_monitor.go#L136-L137

Added lines #L136 - L137 were not covered by tests
for {
if m.closed.Load() {
wd.DoneWithError(errors.New("remote monitor is closed"))
Expand All @@ -143,6 +145,7 @@
if st.Load() {
break
}
errCount++

Check warning on line 148 in monitor/remote_client_monitor.go

View check run for this annotation

Codecov / codecov/patch

monitor/remote_client_monitor.go#L148

Added line #L148 was not covered by tests
m.logger.Error(err, "receive monitor message error")
if m.client.IsClosed(err) {
m.retry.Do(func() error {
Expand All @@ -161,8 +164,13 @@
m.logger.Info("monitor the remote server success")
}
}
} else if errCount > errThreshold {
w := min(errCount/errThreshold, errThreshold)
m.logger.Info("receive monitor message error threshold exceeded, will retry after %d seconds", w)
time.Sleep(time.Second * time.Duration(w))

Check warning on line 170 in monitor/remote_client_monitor.go

View check run for this annotation

Codecov / codecov/patch

monitor/remote_client_monitor.go#L167-L170

Added lines #L167 - L170 were not covered by tests
}
} else {
errCount = 0

Check warning on line 173 in monitor/remote_client_monitor.go

View check run for this annotation

Codecov / codecov/patch

monitor/remote_client_monitor.go#L173

Added line #L173 was not covered by tests
m.messages.PushBack(msg)
}
}
Expand Down
Loading