-
Notifications
You must be signed in to change notification settings - Fork 2
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
Icinga2Client#Do(): call parent method, re-try on HTTP 503 300 times #29
Conversation
TestsBefore: https://github.com/Al2Klimov/icingadb/actions/runs/8234573747 TODO
|
|
||
for attempt := 1; ; attempt++ { | ||
response, err := c.Client.Do(req) | ||
if err == nil && response.StatusCode == http.StatusServiceUnavailable && req.GetBody != nil && attempt < 300 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attempt < 300
with attempt
starting at 1 results in performing c.Client.Do()
300 times, not re-trying 300 times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of attempts isn't even the most relevant part here. It retries for roughly 5 minutes, which should be plenty for our tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the PR description for you.
During an Icinga 2 reload, there are phases where the API can't perform config changes and replies with an HTTP 503 error instead (see Icinga/icinga2#9445 for example) which means that the client should retry the operation at a later time. The PR retries such errors for approximately 5 minutes (plus response times).
refs Icinga/icingadb#685