v3rpc: return Unavailable instead of Unknown for ErrNotPrimary#21684
v3rpc: return Unavailable instead of Unknown for ErrNotPrimary#21684blackwell-systems wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: blackwell-systems The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @blackwell-systems. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
|
Please provide a test |
|
Added The existing |
When LeaseRenew returns lease.ErrNotPrimary (e.g. after a leader switch), the error was not mapped in toGRPCErrorMap, causing togRPCError to return codes.Unknown (2). Clients seeing Unknown do not know to retry. Add ErrGRPCLeaseNotPrimary with codes.Unavailable and map lease.ErrNotPrimary to it, so clients receive a retryable status code. Fixes etcd-io#21671 Signed-off-by: Dayna Blackwell <daynajblackwell@gmail.com> Signed-off-by: Dayna Blackwell <blackwellsystems@protonmail.com>
Adds TestLeaseNotPrimaryReturnsUnavailable which verifies the gRPC status code is codes.Unavailable, ensuring clients can distinguish transient leadership errors from permanent failures and retry. Signed-off-by: Dayna Blackwell <blackwellsystems@protonmail.com>
53cf384 to
79f4b60
Compare
|
/retest |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 29 files with indirect coverage changes @@ Coverage Diff @@
## main #21684 +/- ##
==========================================
+ Coverage 69.09% 69.24% +0.14%
==========================================
Files 432 432
Lines 35544 35544
==========================================
+ Hits 24560 24613 +53
+ Misses 9595 9544 -51
+ Partials 1389 1387 -2 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
When
LeaseRenewreturnslease.ErrNotPrimary(e.g. after a leader switch), the error was not mapped intoGRPCErrorMap, causingtogRPCErrorto fall through tostatus.Error(codes.Unknown, err.Error()). Clients seeingUnknown(code 2) do not know to retry.This adds
ErrGRPCLeaseNotPrimarywithcodes.Unavailable(14) and mapslease.ErrNotPrimaryto it, so clients receive a retryable status code. This is consistent with howErrLeaderChangedandErrNoLeaderare already mapped tocodes.Unavailable.Changes:
api/v3rpc/rpctypes/error.go: addErrGRPCLeaseNotPrimary,ErrLeaseNotPrimary, and theerrStringToErrormappingserver/etcdserver/api/v3rpc/util.go: addlease.ErrNotPrimarytotoGRPCErrorMapserver/etcdserver/api/v3rpc/util_test.go: add test caseTests pass:
Fixes #21671