fix: expose incompatible pool configuration refusals

This commit is contained in:
pingqiu committed 2026-11-19 23:40:13 -08:00
1 parent 8bf7cfd663
commit 7899cd9240
2 files changed
+12

No files matched your search

+9
View File
@@ -216,6 +216,15 @@ func (l *Limiter) Admit(ctx context.Context, payload int64, abort func(error)) (
return 0, err
}
if errors.Is(err, ErrConfig) {
l.mu.Lock()
warn := l.stats.LastPoolError != err.Error()
l.stats.LastPoolError = err.Error()
l.stats.Skipped++
l.stats.SkippedByClass[c]++
l.mu.Unlock()
if warn {
log.Printf("hostlimit: shared pool configuration refused; background protection may lag: %v", err)
}
return 0, err
}
fallback := err != nil // A is deliberately degraded: no shared memory/spill cap.
@@ -164,6 +164,9 @@ func TestFallbackAndConfigMismatch(t *testing.T) {
if _, e = b.Admit(context.Background(), 1, nil); !errors.Is(e, ErrConfig) {
t.Fatalf("config mismatch bypassed cap: %v", e)
}
if st := b.Snapshot().(Stats); st.LastPoolError == "" || st.Skipped != 1 {
t.Fatal("configuration refusal was silent", st)
}
c.Directory += "-missing"
f := newTest(t, c)
x, e = f.Admit(context.Background(), 1, nil)