Skip to content

api/etcdserverpb/rpc.proto: add leader_id response header - #22327

Open
gyuho wants to merge 1 commit into
etcd-io:mainfrom
gyuho:leader-id-response-header
Open

api/etcdserverpb/rpc.proto: add leader_id response header#22327
gyuho wants to merge 1 commit into
etcd-io:mainfrom
gyuho:leader-id-response-header

Conversation

@gyuho

@gyuho gyuho commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

(/cc @SaranBalaji90 @jamesmthompson)

Adds leader_id (field 5) to the v3 ResponseHeader and fills it at every server-side header site from the already-wired RaftStatusGetter.Leader(). The field is optional: 0 means "no hint," and it is not a fencing token. Old clients ignore it; new clients treat 0 from old servers as "unknown leader." Cost is at most ~11 bytes per response for a value the server already holds in memory.

Today a client must poll Status to learn the leader; this field puts that leader member ID in every Put/Get/Watch response, which is what Phase 2's opt-in leader-aware balancer builds on.

A new common-suite test (TestResponseHeaderLeaderId, integration and e2e) verifies leader_id is nonzero once a leader is elected, matches each member's status.leader, agrees across members, and appears on Put and Get, with mixed-version clusters checked per current-version endpoint.

c.f., #22268

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gyuho
Once this PR has been reviewed and has the lgtm label, please assign siyuanfoundation 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

@kubernetes-prow

Copy link
Copy Markdown

Hi @gyuho. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@fuweid

fuweid commented Aug 24, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@fuweid

fuweid commented Aug 24, 2026

Copy link
Copy Markdown
Member

The commit requires author to signoff by git commit -s

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.72%. Comparing base (23a4e40) to head (575d780).

Additional details and impacted files
Files with missing lines Coverage Δ
server/etcdserver/apply/backend.go 86.11% <100.00%> (+0.07%) ⬆️

... and 25 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #22327      +/-   ##
==========================================
- Coverage   69.76%   69.72%   -0.05%     
==========================================
  Files         448      448              
  Lines       38159    38164       +5     
==========================================
- Hits        26622    26610      -12     
- Misses      10107    10122      +15     
- Partials     1430     1432       +2     

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 23a4e40...575d780. Read the comment docs.

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

Add leader_id (field 5) to the ResponseHeader proto and populate it at
every server-side fill site from RaftStatusGetter.Leader(). That
interface is already wired at each site.

The field is advisory: 0 means the responding member does not know who
the leader is. It is not a fencing token and is not atomic with
raft_term. Old clients ignore the field; new clients treat 0 as
"no hint."

Covers all v3 RPC responses through fillWithoutRevision / fill,
newResponseHeader (watch), ClusterServer.header, EtcdServer.newHeader,
and applierV3backend.newHeader.

ref. etcd-io#22268

Signed-off-by: Gyuho Lee <gyuhol@nvidia.com>
@gyuho
gyuho force-pushed the leader-id-response-header branch from 43ef676 to 575d780 Compare August 25, 2026 04:07
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.

2 participants