keyspace: load keyspace by ID through gRPC#10911
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesLoadKeyspaceByID feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@client/keyspace_client_test.go`:
- Around line 71-80: The errors from server.Serve and listener.Close are being
silently dropped with blank identifiers, which hides lifecycle failures. In the
goroutine where server.Serve is called, capture the error and log it or store it
for test diagnostics. Similarly, in the cleanup function, capture the error from
listener.Close() and handle it appropriately by logging or asserting on it.
Alternatively, if these errors should legitimately be ignored, add explicit
errcheck exclusions to .golangci.yml for these specific error cases.
🪄 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: 18be4bc5-9e8e-450b-b85f-2873c964d74a
⛔ Files ignored due to path filters (4)
client/go.sumis excluded by!**/*.sumgo.sumis excluded by!**/*.sumtests/integrations/go.sumis excluded by!**/*.sumtools/go.sumis excluded by!**/*.sum
📒 Files selected for processing (8)
client/go.modclient/keyspace_client.goclient/keyspace_client_test.goclient/metrics/metrics.gogo.modserver/keyspace_service.gotests/integrations/go.modtools/go.mod
|
/test pull-unit-test-next-gen-3 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10911 +/- ##
==========================================
+ Coverage 79.15% 79.18% +0.02%
==========================================
Files 540 540
Lines 74801 74847 +46
==========================================
+ Hits 59212 59266 +54
+ Misses 11405 11402 -3
+ Partials 4184 4179 -5
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/keyspace_service_test.go (1)
58-65: ⚡ Quick winAssert the exact failure contract for mismatched cluster ID.
At Line 62,
re.Error(err)is too broad and can pass on unrelated failures. This case should verify mismatch-cluster validation specifically, and that no response is returned.Proposed test tightening
- _, err = service.LoadKeyspaceByID(ctx, &keyspacepb.LoadKeyspaceByIDRequest{ + resp, err := service.LoadKeyspaceByID(ctx, &keyspacepb.LoadKeyspaceByIDRequest{ Header: testutil.NewRequestHeader(leader.GetClusterID() + 1), Id: created.GetId(), }) re.Error(err) + re.ErrorContains(err, "mismatch cluster id") + re.Nil(resp) - resp, err := service.LoadKeyspaceByID(ctx, &keyspacepb.LoadKeyspaceByIDRequest{ + resp, err = service.LoadKeyspaceByID(ctx, &keyspacepb.LoadKeyspaceByIDRequest{ Header: testutil.NewRequestHeader(leader.GetClusterID()), Id: created.GetId() + 1000, })🤖 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/keyspace_service_test.go` around lines 58 - 65, The test assertion at line 62 uses a generic re.Error(err) check which is too broad and could pass for any error condition, not specifically validating the cluster ID mismatch contract. Replace the generic error assertion with specific checks that verify both the error is for cluster ID mismatch (check error type, code, or message for cluster validation failure) and that the response returned from the LoadKeyspaceByID call is nil when the cluster ID in the request header does not match the leader cluster ID.
🤖 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.
Nitpick comments:
In `@server/keyspace_service_test.go`:
- Around line 58-65: The test assertion at line 62 uses a generic re.Error(err)
check which is too broad and could pass for any error condition, not
specifically validating the cluster ID mismatch contract. Replace the generic
error assertion with specific checks that verify both the error is for cluster
ID mismatch (check error type, code, or message for cluster validation failure)
and that the response returned from the LoadKeyspaceByID call is nil when the
cluster ID in the request header does not match the leader cluster ID.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 14b3632b-8117-4218-b264-0c369e04efa8
⛔ Files ignored due to path filters (4)
client/go.sumis excluded by!**/*.sumgo.sumis excluded by!**/*.sumtests/integrations/go.sumis excluded by!**/*.sumtools/go.sumis excluded by!**/*.sum
📒 Files selected for processing (1)
server/keyspace_service_test.go
|
/test pull-unit-test-next-gen-3 |
|
/test pull-unit-test-next-gen-3 |
1 similar comment
|
/test pull-unit-test-next-gen-3 |
|
/test pull-integration-realcluster-test |
|
/test pull-unit-test-next-gen-3 |
1 similar comment
|
/test pull-unit-test-next-gen-3 |
|
/retest |
| // kvproto at the same time. You can run `go mod tidy` to make it replaced with go-mod style specification. | ||
| // After the PR to kvproto is merged, remember to comment this out and run `go mod tidy`. | ||
| // replace github.com/pingcap/kvproto => github.com/$YourPrivateRepo $YourPrivateBranch | ||
| replace github.com/pingcap/kvproto => github.com/pingcap/kvproto v0.0.0-20260618032004-5ec421b79217 |
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
9483e13 to
b02d6fb
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@tests/server/keyspace/keyspace_service_test.go`:
- Around line 78-88: The failpoint test at the LoadKeyspaceByID call (around
line 82-88) is not actually exercising the skipKeyspaceRegionCheck failpoint
because it reuses the success state from the earlier LoadKeyspaceByID call on
lines 64-69. To fix this, you need to modify the test state between the two
calls so that LoadKeyspaceByID would fail the region check without the failpoint
enabled. This could involve removing or invalidating the keyspace regions after
the first successful call, then enable the failpoint and verify that
LoadKeyspaceByID succeeds anyway, which proves the skipKeyspaceRegionCheck
failpoint is properly bypassing the region validation logic.
🪄 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: b8278253-094f-495f-a6a2-06d69374de29
⛔ Files ignored due to path filters (4)
client/go.sumis excluded by!**/*.sumgo.sumis excluded by!**/*.sumtests/integrations/go.sumis excluded by!**/*.sumtools/go.sumis excluded by!**/*.sum
📒 Files selected for processing (9)
client/go.modclient/keyspace_client.goclient/keyspace_client_test.goclient/metrics/metrics.gogo.modserver/keyspace_service.gotests/integrations/go.modtests/server/keyspace/keyspace_service_test.gotools/go.mod
🚧 Files skipped from review as they are similar to previous changes (3)
- client/keyspace_client.go
- server/keyspace_service.go
- client/metrics/metrics.go
Signed-off-by: Ryan Leung <rleungx@gmail.com>
|
/retest |
|
/test pull-unit-test-next-gen-3 |
1 similar comment
|
/test pull-unit-test-next-gen-3 |
Signed-off-by: Ryan Leung <rleungx@gmail.com>
|
@bufferflies: Your lgtm message is repeated, so it is ignored. DetailsIn response to this: 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. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bufferflies, JmPotato The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: ref #10912
What is changed and how does it work?
Check List
Tests
Related changes
Release note
Summary by CodeRabbit
New Features
Chores