fix(keepalived): ensure Refresh() runs once per cycle#1385
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where Refresh() was being called multiple times within a single collection cycle when retries occurred. The fix ensures Refresh() runs exactly once per cycle by moving it outside the retry loop.
Key Changes:
- Moved
Refresh()call outside the exponential backoff retry loop to ensure it runs only once per collection cycle - Adjusted the initial backoff interval from 10ms to 50ms to provide more time for keepalived to process refresh signals
- Improved error handling by immediately marking keepalived as down if refresh signals fail
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, b); err != nil { | ||
| slog.Error("No data found to be exported", "error", err) | ||
| if keepalivedUp == 1 { | ||
| b := backoff.NewExponentialBackOff() |
There was a problem hiding this comment.
The initial backoff interval has been increased from 10ms to 50ms. This means the first retry will wait longer before attempting to fetch stats after a failure. Consider documenting the rationale for this timing change, as it increases the minimum wait time by 5x. If this change is intentional to give keepalived more time to generate stats after the Refresh signal, it would be helpful to explain this in a code comment.
| b := backoff.NewExponentialBackOff() | |
| b := backoff.NewExponentialBackOff() | |
| // Use a 50ms initial backoff (increased from 10ms) to give keepalived time | |
| // to generate stats after the Refresh signal before the first retry. |
|
Thank you @c88888 |
…1385) Co-authored-by: peter <>
No description provided.