Skip to content

Commit

Permalink
etcdserver: non-mutating requests pass through quotaKVServer when NOS…
Browse files Browse the repository at this point in the history
…PACE
  • Loading branch information
chaochn47 committed Oct 22, 2021
1 parent ef1f71a commit 82cf603
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG-3.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.5.1) and

- Endpoints self identify now as `etcd-endpoints://{id}/{authority}` where authority is based on first endpoint passed, for example `etcd-endpoints://0xc0009d8540/localhost:2079`

### tools/benchmark

- [Add etcd client autoSync flag](https://github.com/etcd-io/etcd/pull/13416)

### Other

- Updated [base image](https://github.com/etcd-io/etcd/pull/13386) from `debian:buster-v1.4.0` to `debian:bullseye-20210927` to fix the following critical CVEs:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG-3.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).

- Add [`etcd --log-format`](https://github.com/etcd-io/etcd/pull/13339) flag to support log format.

### tools/benchmark

- [Add etcd client autoSync flag](https://github.com/etcd-io/etcd/pull/13416)

### Metrics, Monitoring

See [List of metrics](https://etcd.io/docs/latest/metrics/) for all metrics per release.
Expand Down
4 changes: 4 additions & 0 deletions server/storage/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func NewBackendQuota(cfg config.ServerConfig, be backend.Backend, name string) Q
}

func (b *BackendQuota) Available(v interface{}) bool {
// if there are no mutating requests, it's safe to pass through
if b.Cost(v) == 0 {
return true
}
// TODO: maybe optimize Backend.Size()
return b.be.Size()+int64(b.Cost(v)) < b.maxBackendBytes
}
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/v3_alarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ func TestV3StorageQuotaApply(t *testing.T) {
}
}

// txn with non-mutating Ops should go through when NOSPACE alarm is raised
_, err = kvc0.Txn(context.TODO(), &pb.TxnRequest{
Compare: []*pb.Compare{
{
Key: key,
Result: pb.Compare_EQUAL,
Target: pb.Compare_CREATE,
TargetUnion: &pb.Compare_CreateRevision{CreateRevision: 0},
},
},
Success: []*pb.RequestOp{
{
Request: &pb.RequestOp_RequestDeleteRange{
RequestDeleteRange: &pb.DeleteRangeRequest{
Key: key,
},
},
},
},
})
if err != nil {
t.Fatal(err)
}

ctx, cancel := context.WithTimeout(context.TODO(), integration.RequestWaitTimeout)
defer cancel()

Expand Down

0 comments on commit 82cf603

Please sign in to comment.