mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(shared-state): drop breaker deltas older than the fail window
During a Redis outage the queued failure deltas kept a replaced gateway's loop alive for ever. A queued failure older than the fail window cannot change the fleet count, so the breaker now drops it.
This commit is contained in:
@@ -294,3 +294,33 @@ func TestSharedInflightEndRestartsIdleStoppedLoop(t *testing.T) {
|
||||
}
|
||||
l.close()
|
||||
}
|
||||
|
||||
func TestSharedBreakerDropsDeltasPastFailWindow(t *testing.T) {
|
||||
store, clk := sharedTestEnv()
|
||||
l := sharedTestLoop(store, clk)
|
||||
b := testBreaker(l)
|
||||
store.setFailIncr(errors.New("redis down"))
|
||||
b.recordFailure("p")
|
||||
l.refresh()
|
||||
if !b.pending() {
|
||||
t.Fatal("delta dropped inside the fail window")
|
||||
}
|
||||
clk.advance(testBrkWindow + time.Second)
|
||||
if b.pending() {
|
||||
t.Error("failure delta older than the fail window still pending")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSharedStateIdleStopsDuringOutageAfterFailWindow(t *testing.T) {
|
||||
store, clk := sharedTestEnv()
|
||||
l := newSharedStateLoop(store, nil, nil)
|
||||
l.nowFn = clk.now
|
||||
l.every = 5 * time.Millisecond
|
||||
b := testBreaker(l)
|
||||
store.setFailIncr(errors.New("redis down"))
|
||||
b.recordFailure("p")
|
||||
waitLoop(t, l, true)
|
||||
clk.advance(sharedStateIdleStop + time.Second)
|
||||
waitLoop(t, l, false)
|
||||
l.close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user