mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Merge pull request #118282 from wojtek-t/retry_after_followup
Follow up from dynamic retryAfter
This commit is contained in:
commit
c07c739f04
@ -111,7 +111,12 @@ func (s *droppedRequestsStats) updateHistory(unixTime int64, count int64) {
|
|||||||
s.history = append(s.history, unixStat{unixTime: unixTime, requests: count})
|
s.history = append(s.history, unixStat{unixTime: unixTime, requests: count})
|
||||||
|
|
||||||
startIndex := 0
|
startIndex := 0
|
||||||
for ; startIndex < len(s.history) && unixTime-s.history[startIndex].unixTime > maxRetryAfter; startIndex++ {
|
// Entries that exceed 2*retryAfter or maxRetryAfter are never going to be needed.
|
||||||
|
maxHistory := 2 * s.retryAfter.Load()
|
||||||
|
if maxHistory > maxRetryAfter {
|
||||||
|
maxHistory = maxRetryAfter
|
||||||
|
}
|
||||||
|
for ; startIndex < len(s.history) && unixTime-s.history[startIndex].unixTime > maxHistory; startIndex++ {
|
||||||
}
|
}
|
||||||
if startIndex > 0 {
|
if startIndex > 0 {
|
||||||
s.history = s.history[startIndex:]
|
s.history = s.history[startIndex:]
|
||||||
@ -138,14 +143,12 @@ func (s *droppedRequestsStats) updateRetryAfterIfNeededLocked(unixTime int64) {
|
|||||||
retryAfter := s.retryAfter.Load()
|
retryAfter := s.retryAfter.Load()
|
||||||
|
|
||||||
droppedRequests := int64(0)
|
droppedRequests := int64(0)
|
||||||
if len(s.history) > 0 {
|
for i := len(s.history) - 1; i >= 0; i-- {
|
||||||
for i := len(s.history) - 1; i >= 0; i-- {
|
if unixTime-s.history[i].unixTime > retryAfter {
|
||||||
if unixTime-s.history[i].unixTime > retryAfter {
|
break
|
||||||
break
|
}
|
||||||
}
|
if s.history[i].unixTime < unixTime {
|
||||||
if s.history[i].unixTime < unixTime {
|
droppedRequests += s.history[i].requests
|
||||||
droppedRequests += s.history[i].requests
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func TestDroppedRequestsTracker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fakeClock.Step(time.Duration(secondsToAdvance) * time.Second)
|
fakeClock.Step(time.Duration(secondsToAdvance) * time.Second)
|
||||||
|
|
||||||
// Record only first dropped request and recompute retryAfter.
|
// Record all droppeded requests and recompute retryAfter.
|
||||||
for r := 0; r < step.droppedRequests; r++ {
|
for r := 0; r < step.droppedRequests; r++ {
|
||||||
tracker.RecordDroppedRequest("pl")
|
tracker.RecordDroppedRequest("pl")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user