[3.5] Backport: non mutating requests pass through quotaKVServer when NOSPACE

Signed-off-by: Vaibhav Mehta <mehvaibh@amazon.com>
This commit is contained in:
Chao Chen
2021-10-22 16:36:37 -07:00
committed by Vaibhav Mehta
parent 5454ca67bd
commit 378ad6b517
2 changed files with 30 additions and 1 deletions

View File

@@ -125,8 +125,13 @@ func NewBackendQuota(s *EtcdServer, name string) Quota {
}
func (b *backendQuota) Available(v interface{}) bool {
cost := b.Cost(v)
// if there are no mutating requests, it's safe to pass through
if cost == 0 {
return true
}
// TODO: maybe optimize backend.Size()
return b.s.Backend().Size()+int64(b.Cost(v)) < b.maxBackendBytes
return b.s.Backend().Size()+int64(cost) < b.maxBackendBytes
}
func (b *backendQuota) Cost(v interface{}) int {