Skip to content

etcdctl: add --stream flag to get command#21747

Merged
fuweid merged 1 commit into
etcd-io:mainfrom
Jefftree:etcdctl-stream-flag
May 14, 2026
Merged

etcdctl: add --stream flag to get command#21747
fuweid merged 1 commit into
etcd-io:mainfrom
Jefftree:etcdctl-stream-flag

Conversation

@Jefftree
Copy link
Copy Markdown
Member

@Jefftree Jefftree commented May 13, 2026

Add --stream flag. Also removes the supportsGetStream variable since e2e now supports getStream.

e2e tests now exercise the streaming path (TestKVGet) so no new tests were added.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.28%. Comparing base (3bdaa05) to head (695442b).

Files with missing lines Patch % Lines
etcdctl/ctlv3/command/get_command.go 0.00% 13 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
etcdctl/ctlv3/command/get_command.go 0.00% <0.00%> (ø)

... and 21 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #21747      +/-   ##
==========================================
- Coverage   70.29%   70.28%   -0.02%     
==========================================
  Files         426      426              
  Lines       35215    35227      +12     
==========================================
+ Hits        24754    24758       +4     
+ Misses       9073     9072       -1     
- Partials     1388     1397       +9     

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 3bdaa05...695442b. Read the comment docs.

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

@Jefftree
Copy link
Copy Markdown
Member Author

/retest

@Jefftree
Copy link
Copy Markdown
Member Author

/assign @serathius @fuweid

Comment thread tests/common/kv_test.go
t.Run(fmt.Sprintf("Stream=%v", stream), func(t *testing.T) {
if !supportsGetStream || !rangeStreamSupports(tt.options) {
if !rangeStreamSupports(tt.options) {
t.Skip("Stream not supported")
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.

In pull request, we only run few set of TestKVGet - E2E_TEST_MINIMAL=true

https://github.com/kubernetes/test-infra/blob/befc6a5ebd53bbaca099ffd026b4356d29e835ca/config/jobs/etcd/etcd-presubmits.yaml#L216

If we set it to false, the cluster will be mixed with old release one. It will return error like this.

                                        match not found.  Set EXPECT_DEBUG for more info Errs: [unexpected exit code [1] after running [/home/niuhechaofan/workspace/etcd/bin/etcdctl
--endpoints=http://localhost:20000,http://localhost:20005,http://localhost:20010 get c -w json --rev=6 -w fields --keys-only --stream -w json]], last lines:
                                        Error: rpc error: code = Unimplemented desc = unknown method RangeStream for service etcdserverpb.KV
                        Test:           TestKVGet/QuorumLastVersion/Get_third_version_of_'c'_by_its_revision_--keys-only/Stream=true
                        Messages:       count not get key "c", err: match not found.  Set EXPECT_DEBUG for more info Errs: [unexpected exit code [

Copy link
Copy Markdown
Member

@serathius serathius May 13, 2026

Choose a reason for hiding this comment

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

Nice catch, we run mixed version etcd clusters only in periodics.

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.

Thanks for flagging this. My thinking is that we can fetch the server version (via client.Status) and then only proceed with rangestream on >=3.7 to handle the mixed version case.

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.

we can fetch the server version (via client.Status)

Maybe we can go with this? the clusterSupportsGetStream will go through all the members with GetStream. If old member doesn't support it, it will return false.

 func TestKVGet(t *testing.T) {
        testKVGet(t, false)
  }

  func TestKVGetStream(t *testing.T) {
        testKVGet(t, true)
  }

  func testKVGet(t *testing.T, stream bool) {
        testRunner.BeforeTest(t)
        for _, tc := range clusterTestCases() {
                t.Run(tc.name, func(t *testing.T) {
                        ctx, cancel := context.WithTimeout(t.Context(), 30*time.Second)
                        defer cancel()

                        clus := testRunner.NewCluster(ctx, t, config.WithClusterConfig(tc.config))
                        defer clus.Close()

                        if stream && !clusterSupportsGetStream(t, clus) {
                                t.Skip("RangeStream is not supported by this cluster")
                        }

                        // ...

Signed-off-by: Jefftree <jeffrey.ying86@live.com>
@Jefftree
Copy link
Copy Markdown
Member Author

/retest

@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fuweid, Jefftree, serathius

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

The pull request process is described 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

@fuweid fuweid merged commit ebda1e8 into etcd-io:main May 14, 2026
32 checks passed
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