Skip to content

*: update kvproto to apiv3#11024

Open
disksing wants to merge 5 commits into
masterfrom
apiv3-update-proto
Open

*: update kvproto to apiv3#11024
disksing wants to merge 5 commits into
masterfrom
apiv3-update-proto

Conversation

@disksing

@disksing disksing commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #11025

The kvproto APIV3 branch changes several keyspace-related protobuf fields to oneofs. PD needs to consume the latest definitions and adapt the affected requests, responses, and test fixtures.

What is changed and how does it work?

  • Update kvproto to fd32127adca58438f6b05c869951182bbdd6041c.
  • Adapt TSO headers, keyspace metadata, GC safe point requests, and related mocks/tests to the generated oneof APIs.
  • Embed the generated unimplemented keyspace server where required.

Check List

Tests

  • Unit test
    • DASHBOARD=0 make pd-server-basic
    • make gotest GOTEST_ARGS='./pkg/gc ./pkg/keyspace ./pkg/storage ./pkg/mcs/resourcemanager/server ./server/...'
    • make -C client gotest GOTEST_ARGS="./clients/tso -run 'TestTSOStreamSuite|TestTSODispatcherTestSuite' -count=1"
    • make -C client gotest GOTEST_ARGS='./servicediscovery -count=1'

Code changes

  • Has the configuration change
  • Has HTTP APIs changed
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility: updates generated protobuf APIs to the APIV3 definitions

Release note

None.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with updated keyspace/TSO protobuf interfaces.
    • Corrected keyspace ID handling across keyspace APIs, GC safe points/states, TSO forwarding, and service discovery, including pagination tokens.
    • Ensured keyspace IDs are preserved consistently when serializing/deserializing metadata.
    • Added the standard gRPC unimplemented stub for the keyspace service.
  • Tests
    • Updated fixtures and assertions to use protobuf getter/wrapper forms for keyspace identifiers.
  • Chores
    • Updated the kvproto dependency to the newer revision.

Signed-off-by: disksing <i@disksing.com>
@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. labels Jul 20, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign okjiang for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@disksing, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0451c9c5-4662-4151-8397-51078605aa0a

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0eca1 and 9717bdc.

📒 Files selected for processing (2)
  • tests/integrations/mcs/resourcemanager/resource_manager_test.go
  • tests/integrations/mcs/tso/keyspace_group_manager_test.go
📝 Walkthrough

Walkthrough

The PR updates kvproto and migrates keyspace, GC, and TSO code from direct protobuf fields to generated oneof wrappers and getter accessors. Related tests, API serialization, dependency files, and keyspace gRPC compatibility are updated.

Changes

kvproto oneof migration

Layer / File(s) Summary
Protobuf dependency and API boundaries
client/go.mod, go.mod, tests/integrations/go.mod, tools/go.mod, client/http/types.go, client/keyspace_client.go, server/..., tools/pd-ctl/...
Updates kvproto versions and adapts keyspace metadata, requests, accessors, API serialization, server compatibility, and client validation to the new protobuf representation.
Keyspace metadata and storage migration
pkg/keyspace/..., pkg/storage/keyspace_test.go, pkg/mcs/...
Uses ID oneof wrappers and getter accessors throughout keyspace creation, assignment, persistence, and tests.
GC keyspace scope conversion
client/gc_client.go, server/gc_service.go, pkg/gc/..., tests/.../gc*
Updates GC scope encoding and keyspace ID extraction for the revised protobuf fields.
TSO keyspace header conversion
client/clients/tso/stream.go, client/servicediscovery/..., server/forward.go, pkg/utils/tsoutil/...
Encodes TSO keyspace IDs through the request-header oneof wrapper across stream and forwarding paths.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

  • tikv/pd#10600 — Both modify TSO request-header construction.
  • tikv/pd#10677 — Both modify keyspace ID handling in GC state management.
  • tikv/pd#10749 — Both modify GC client service-safe-point handling.

Suggested labels: lgtm, approved

Suggested reviewers: rleungx, bufferflies, okjiang, jmpotato, ystaticy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: updating kvproto to APIV3.
Description check ✅ Passed The description includes the issue number, summary of changes, tests, side effects, and release note sections.
Linked Issues check ✅ Passed The PR updates kvproto to APIV3 and migrates the listed TSO, keyspace, GC, HTTP, and pd-ctl call sites as required by #11025.
Out of Scope Changes check ✅ Passed The changes are consistent with the APIV3 migration and supporting test updates; no unrelated code changes stand out.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch apiv3-update-proto

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
server/apiv2/handlers/keyspace.go (1)

300-300: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer strconv.FormatUint over casting uint32 to int.

While casting to int is safe on 64-bit architectures, it is generally more idiomatic to use unsigned formatting for unsigned integers rather than casting them to signed variants.

♻️ Proposed refactor
-		resp.NextPageToken = strconv.Itoa(int(scanned[len(scanned)-1].GetId()))
+		resp.NextPageToken = strconv.FormatUint(uint64(scanned[len(scanned)-1].GetId()), 10)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/apiv2/handlers/keyspace.go` at line 300, Update the NextPageToken
assignment in the keyspace handler to format scanned[len(scanned)-1].GetId()
with strconv.FormatUint, converting it only to the required unsigned integer
type and removing the uint32-to-int cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/keyspace/keyspace.go`:
- Around line 553-561: Move the manager.keyspaceNameLookup.Store call out of the
RunInTxn callback and perform it only after the enclosing transaction returns
successfully. Keep the storage update inside the transaction, and ensure the
cache is not mutated when the transaction fails or commit encounters a CAS
mismatch.

---

Nitpick comments:
In `@server/apiv2/handlers/keyspace.go`:
- Line 300: Update the NextPageToken assignment in the keyspace handler to
format scanned[len(scanned)-1].GetId() with strconv.FormatUint, converting it
only to the required unsigned integer type and removing the uint32-to-int cast.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2146e9a5-68fc-4eef-aebb-6a5b35f47316

📥 Commits

Reviewing files that changed from the base of the PR and between 0b37df9 and 895c3ca.

⛔ Files ignored due to path filters (4)
  • client/go.sum is excluded by !**/*.sum
  • go.sum is excluded by !**/*.sum
  • tests/integrations/go.sum is excluded by !**/*.sum
  • tools/go.sum is excluded by !**/*.sum
📒 Files selected for processing (21)
  • client/clients/tso/stream.go
  • client/gc_client.go
  • client/go.mod
  • client/http/types.go
  • client/keyspace_client.go
  • client/keyspace_client_test.go
  • client/servicediscovery/tso_service_discovery.go
  • go.mod
  • pkg/gc/gc_state_manager.go
  • pkg/gc/gc_state_manager_test.go
  • pkg/keyspace/keyspace.go
  • pkg/keyspace/keyspace_test.go
  • pkg/mcs/resourcemanager/server/manager_test.go
  • pkg/storage/keyspace_test.go
  • pkg/utils/tsoutil/tso_proto_factory.go
  • server/apiv2/handlers/keyspace.go
  • server/forward.go
  • server/gc_service.go
  • server/keyspace_service.go
  • tests/integrations/go.mod
  • tools/go.mod

Comment thread pkg/keyspace/keyspace.go
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 20, 2026
Signed-off-by: disksing <i@disksing.com>
@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@disksing: 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-check-deps 9717bdc link true /test pull-check-deps

Full PR test history. Your PR dashboard.

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.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.85507% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.25%. Comparing base (0b37df9) to head (9717bdc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11024      +/-   ##
==========================================
+ Coverage   79.23%   79.25%   +0.02%     
==========================================
  Files         541      541              
  Lines       76035    76053      +18     
==========================================
+ Hits        60245    60275      +30     
+ Misses      11545    11534      -11     
+ Partials     4245     4244       -1     
Flag Coverage Δ
unittests 79.25% <89.85%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@disksing

Copy link
Copy Markdown
Contributor Author

/test pull-unit-test-next-gen-3

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

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update kvproto dependency to APIV3 definitions

1 participant