Skip to content

Fix keys_only not including lease in response - #22550

Open
nwnt wants to merge 1 commit into
etcd-io:mainfrom
nwnt:fix-no-lease-keys-only-range
Open

nwnt wants to merge 1 commit into
etcd-io:mainfrom
nwnt:fix-no-lease-keys-only-range

Conversation

@nwnt

@nwnt nwnt commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Ref: #22209

The change ensures that the lease associated with the revision is also returned, not just for the current revision but for the previous revisions when specified in the Range request.

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nwnt
Once this PR has been reviewed and has the lgtm label, please assign ivanvc for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@serathius serathius changed the title Add leaseID to keyIndex's generation Fix keys_only not including lease in response Oct 9, 2026
@nwnt

nwnt commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

Fixing the failed tests now.

Signed-off-by: Nont <9658731+nwnt@users.noreply.github.com>
@nwnt
nwnt force-pushed the fix-no-lease-keys-only-range branch from 197d0b1 to 4dd8e29 Compare October 9, 2026 08:59
@nwnt

nwnt commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

Fixed the failed unit tests and lint. Looking at the e2e errors.

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.15686% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.00%. Comparing base (f061acd) to head (4dd8e29).

Files with missing lines Patch % Lines
server/storage/mvcc/key_index.go 92.59% 2 Missing ⚠️
server/storage/mvcc/kvstore.go 60.00% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
server/storage/mvcc/index.go 96.06% <100.00%> (+0.06%) ⬆️
server/storage/mvcc/kvstore_txn.go 79.05% <100.00%> (+0.11%) ⬆️
server/storage/mvcc/key_index.go 74.25% <92.59%> (+1.64%) ⬆️
server/storage/mvcc/kvstore.go 93.50% <60.00%> (-0.34%) ⬇️

... and 24 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #22550      +/-   ##
==========================================
- Coverage   73.01%   73.00%   -0.02%     
==========================================
  Files         448      448              
  Lines       31813    31827      +14     
==========================================
+ Hits        23227    23234       +7     
- Misses       8583     8590       +7     
  Partials        3        3              

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f061acd...4dd8e29. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nwnt

nwnt commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

/retest

@kubernetes-prow

Copy link
Copy Markdown

@nwnt: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-govulncheck 4dd8e29 link true /test pull-etcd-govulncheck
pull-etcd-grpcproxy-e2e-amd64 4dd8e29 link true /test pull-etcd-grpcproxy-e2e-amd64
pull-etcd-e2e-amd64 4dd8e29 link true /test pull-etcd-e2e-amd64
pull-etcd-e2e-arm64 4dd8e29 link true /test pull-etcd-e2e-arm64

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions 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. I understand the commands that are listed here.

Comment thread tests/common/kv_test.go

func testKVGet(t *testing.T, stream bool) {
testRunner.BeforeTest(t)
for _, tc := range clusterTestCases() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hybrid version tests fail because we change behavior between minor version. This is expected as a fix for but that was not caught before.

Look how other tests filter clusterTestCases() for hybrid cases

@serathius

serathius commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Overall LGTM, we just need to disable upgrade tests and remember to reenable them after we backport fix.

/cc @fuweid @ahrtr

This is an important fix for regression in v3.7, after discussing it with Nont adding a lease to index is the only solution other disabling the optimization. As we already announced the optimization as part of the blogpost we expect people to depend on it, so we should consider backporting this change as a fix for v3.7.

@kubernetes-prow
kubernetes-prow Bot requested review from ahrtr and fuweid October 9, 2026 11:47
@fuweid fuweid self-assigned this Oct 10, 2026
Revisions(key, end []byte, atRev int64, limit int, withTotalCount bool) ([]Revision, int)
CountRevisions(key, end []byte, atRev int64) int
Put(key []byte, rev Revision)
Put(key []byte, leaseID lease.LeaseID, rev Revision)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that we need to store all leases in memory, also a lease for each revision of each key. We need to evaluate the impact on memory usage.

We don't have a user facing knob, the FastKeysOnly feature is always enabled. How much is the apiserver depend on this feature?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 1.37, previous performance prevented any dependeence. We are planning to add some dependence in 1.38.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


type revisionLease struct {
revision Revision
leaseID lease.LeaseID

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that even there is no lease, it also consumes 8 bytes for each revision

@serathius serathius Oct 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but even with K8s 1k QPS and 5 minute compaction window that's only ~2MB of data.

@nwnt

nwnt commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

The way other way is to support fastKeysOnly when the revision is not specified, and fallback to read from boltdb when it's specified. I believe we should be able to get the leases for keys in the current revision.

@ahrtr

ahrtr commented Oct 13, 2026

Copy link
Copy Markdown
Member

The motivation of MVCC is to promote performance for concurrent read & write, but leases themselves aren't MVCCed. It's a little weird & pointless to couple leases with revisions inside the index . It would also make the design & implementation harder to evolve in future.

Proposed solution:

  • document this as a known limitation, if users want to get keys only, then they gets keys only, no other info would be returned, including leases.
  • we also add a knob to let users enable or disable this feature FastKeysOnly

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants