v3rpc: allow Defragment RPC on learner members#21950
Conversation
Defragmentation is a purely local maintenance operation that reclaims disk space in the BoltDB file without any Raft consensus involvement. Unlike Write/Put/Delete operations, it does not propose entries to the Raft log and cannot corrupt cluster state. However, isRPCSupportedForLearner() currently returns false for DefragmentRequest, causing learner members to reject defrag calls with ErrGRPCNotSupportedForLearner. As a result, learner databases grow unbounded over time since they cannot be defragmented via etcdctl or the maintenance API. Add DefragmentRequest to the set of RPCs permitted for learner members so that operators can run `etcdctl defrag` against a learner endpoint directly, matching the expected behavior for a read-only local maintenance operation. Fixes etcd-io#21740 Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: crawfordxx 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 @crawfordxx. 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. |
Problem
Learner members cannot be defragmented. Running
etcdctl defragskipslearner endpoints, and targeting the learner directly fails with:
Over time, a learner's BoltDB file grows unbounded while voting members
can reclaim space via defragmentation. There is no supported workaround.
Root cause
isRPCSupportedForLearner()inserver/etcdserver/api/v3rpc/util.goonly permits
StatusRequestand serializableRangeRequestfor learnermembers.
DefragmentRequestfalls through to thedefault: return falsecase, causing the unary interceptor to reject it before the handler runs.
Fix
Add
*pb.DefragmentRequestto the set of RPCs permitted for learner members.Defragmentation is a purely local, read-write maintenance operation on the
BoltDB file (
bboltcompact + copy). It:Allowing it on learners is therefore safe and consistent with how it works
on voting members.
Fixes #21740