cache: Added consistent reads for cache#21428
Conversation
|
Hi @akstron. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Please sign the DCO https://github.com/etcd-io/etcd/pull/21428/checks?check_run_id=65752362584 |
tests/integration/cache_test.go
Outdated
| func revLessThan(n int64) func(int64) bool { return func(r int64) bool { return r < n } } | ||
| func revGreaterEqual(n int64) func(int64) bool { return func(r int64) bool { return r >= n } } | ||
|
|
||
| func TestCacheConsistentRead(t *testing.T) { |
There was a problem hiding this comment.
the getTestCases also check for revision which is causing issue while trying to integrate. I want to send put requests outside the prefix to update the revision before every Get request but that also updates the server revision which is being checked in each test case.
example:
=== RUN TestCacheConsistentRead/fromKey_/foo/b
cache_test.go:638: revision: got 93, want 8
There was a problem hiding this comment.
That's good it's checking revision. That's the way
There was a problem hiding this comment.
Should I update getTestCases according to the new behaviour?
There was a problem hiding this comment.
Done. thanks. Also updated testWithPrefixGet test cases.
|
From https://github.com/etcd-io/etcd/pull/21428/checks?check_run_id=65752362584 |
f532d80 to
e54ddc6
Compare
|
/ok-to-test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted filessee 24 files with indirect coverage changes @@ Coverage Diff @@
## main #21428 +/- ##
==========================================
- Coverage 68.49% 68.44% -0.06%
==========================================
Files 428 428
Lines 35291 35372 +81
==========================================
+ Hits 24173 24209 +36
- Misses 9723 9756 +33
- Partials 1395 1407 +12 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
a102232 to
6c698b1
Compare
9d89dce to
2d67fa3
Compare
2d67fa3 to
dc7cee7
Compare
tests/integration/cache_test.go
Outdated
| opts: []clientv3.OpOption{clientv3.WithSerializable()}, | ||
| }, | ||
| { | ||
| name: "single key /foo/a serializable at rev=latest+1 (future), returns error", |
There was a problem hiding this comment.
Please add serializable read at rev=latest
There was a problem hiding this comment.
This would be a flaky test as the cache might not have caught up causing rpctypes.ErrFutureRev. Should I add with baseRev by updating optsFunc to accept baseRev as well?
2240136 to
3f2b88a
Compare
Signed-off-by: Alok Kumar Singh <dev.alok.singh123@gmail.com>
3f2b88a to
a1cb0a2
Compare
| t.Run("cache_already_caught_up", func(t *testing.T) { | ||
| c, _ := newCacheForWaitTest(10, 10, newTestProgressRequestor()) | ||
|
|
||
| if err := c.waitTillRevision(context.Background(), 10); err != nil { |
There was a problem hiding this comment.
Nit: if waitTillRevision has a bug this test will block for very long. Would be good to have some timeout based on expected time.
| t.Run("timeout", func(t *testing.T) { | ||
| c, _ := newCacheForWaitTest(10, 5, newTestProgressRequestor()) | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
There was a problem hiding this comment.
This test just waits 10 seconds on every execution. First that's too long time for happy path, second maybe using https://go.dev/blog/synctest would help with test design here.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: akstron, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Great job! Please address the comments and TODOs in followup PRs. |
|
Next step would be to implement waitTillRevision based on signals and not polling. |
Cache supports consistent reads when IsSerializable is false. Based on: https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/2340-Consistent-reads-from-cache
Cache.Get Request Flow
Background: conditionalProgressRequestor.run(ctx)
The progress loop only sends
RequestProgresswhen at least onewaitTillRevisioncall is actively waiting, avoiding unnecessaryserver round-trips for serializable-only workloads.
Part of #19371