Skip to content

Add range --count-only and --keys-only mutual exclusivity check#21802

Open
nwnt wants to merge 1 commit into
etcd-io:mainfrom
nwnt:add-mutual-exclusive-range-options
Open

Add range --count-only and --keys-only mutual exclusivity check#21802
nwnt wants to merge 1 commit into
etcd-io:mainfrom
nwnt:add-mutual-exclusive-range-options

Conversation

@nwnt
Copy link
Copy Markdown
Member

@nwnt nwnt commented May 24, 2026

Adding the mutual exclusivity check for Range on the server side.

Addressing the comment #21791 (comment).

Signed-off-by: Nont <9658731+nwnt@users.noreply.github.com>
@k8s-ci-robot
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 serathius 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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.20%. Comparing base (dde11c0) to head (d58b67e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
api/v3rpc/rpctypes/error.go 90.47% <ø> (ø)
server/etcdserver/api/v3rpc/key.go 77.51% <100.00%> (-0.93%) ⬇️

... and 31 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #21802      +/-   ##
==========================================
+ Coverage   70.08%   70.20%   +0.12%     
==========================================
  Files         426      426              
  Lines       35245    35247       +2     
==========================================
+ Hits        24701    24745      +44     
+ Misses       9157     9113      -44     
- Partials     1387     1389       +2     

Continue to review full report in Codecov by Sentry.

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

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

@k8s-ci-robot
Copy link
Copy Markdown

@nwnt: The following test 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-e2e-amd64 d58b67e link true /test pull-etcd-e2e-amd64

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.

ErrGRPCCanceled = status.Error(codes.Canceled, "etcdserver: request canceled")
ErrGRPCDeadlineExceeded = status.Error(codes.DeadlineExceeded, "etcdserver: context deadline exceeded")

ErrGRPCRangeKeysAndCountOptions = status.Error(codes.InvalidArgument, "etcdserver: both KeysOnly and CountOnly cannot be true at the same time")
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.

What happens currently? Do we have a test for that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From what I can see:

  • on the client side, the validation is on etcdctl get command, but the same check is not performed by the client package for the Get operation.
  • on the server side, the current behavior is if --count-only takes the priority where storeTxnCommon.rangeKeys returns early.

There are no tests that validate the latter behavior. The --keys-only tests I added previously avoided this case because I ran into the validation error returned by etcdctl (used by the e2e tests), but at that time I incorrectly assumed the client (used by the integration tests) also did it.

I'm thinking maybe what we should do instead is to adjust the behavior of etcdctl to stop validating this case and document it that --count-only takes precedence and we can adjust the test cases accordingly.

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.

Even if client validates and server doesn't, we still need to avoid breaking server behavior. We need a server only test using clientv3 instead of etcdctl. That's why we use common package to write a test that can be executed on both paths client and command line. Please take a look how to best do that.

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

Labels

Development

Successfully merging this pull request may close these issues.

3 participants