Repository navigation
Conversation
Add /v3/_/cluster routes for leadership transfer, learner addition and promotion, node removal, drain begin/end/status and primary/secondary compaction. Each handler calls the in-process ClusterService so leader forwarding, drain preflight and validation match gRPC, and requires the RPC's fixed scope (ledger:ReadCluster / ledger:WriteCluster). Node errors are normalized through the gRPC adapter's known-error mapping (extracted as KnownErrorStatus) so local and forwarded failures render the same HTTP status, reason and message. Node IDs accept JSON integers or decimal strings at full uint64 width. Maintenance mode stays on POST /v3/_/apply. Schemathesis excludes the new routes because they reconfigure its single-node server. Protobuf, persisted formats and service revision 40 are unchanged.
Strix Security Review✅ No open security findings. PR summary: Adds HTTP routes under `/v3/_/cluster` for the cluster administration RPCs (leadership transfer, learner add/promote, node removal, drain begin/end/status, primary and secondary compaction), each calling the in-process `ClusterService` implementation behind the matching `ledger:ReadCluster` / `ledger:WriteCluster` scope guard. It also extracts the gRPC adapter's typed-error mapping into `KnownErrorStatus` and renders those statuses as HTTP codes with their ledger reasons. Review summaryReviewed the nine new Ruled out (2)
Review 1 on this PR · Reviewed by Strix |
NumaryBot
left a comment
There was a problem hiding this comment.
The required automated review completed with no remaining findings.
What changed
Adds HTTP routes under
/v3/_/clusterfor the operatorClusterServiceoperations:POST /v3/_/cluster/leadership/transferTransferLeadershipledger:WriteClusterPOST /v3/_/cluster/learnersAddLearnerledger:WriteClusterPOST /v3/_/cluster/learners/{nodeId}/promotePromoteLearnerledger:WriteClusterDELETE /v3/_/cluster/nodes/{nodeId}[?force=true]RemoveNodeledger:WriteClusterPOST /v3/_/cluster/drain,POST /v3/_/cluster/drain/endBeginDrain,EndDrainledger:WriteClusterGET /v3/_/cluster/drainGetDrainStatusledger:ReadClusterPOST /v3/_/cluster/compactions/{primary,secondary}CompactPrimary,CompactSecondaryledger:WriteClusterEach handler calls the in-process
ClusterService, so leader forwarding, drain preflight, membership checks and validation are the gRPC ones. Maintenance mode is already reachable as thesetMaintenanceModevariant ofPOST /v3/_/apply; it is documented, not duplicated.Why
HTTP parity for cluster administration (api-parity epic). Linked ticket: EN-3289.
Product / operational motivation
ClusterServicegRPC andledgerctl.docs/technical/architecture/subsystems/api/http-api.md#cluster-administration-over-http,docs/technical/contributing/api-comparison.md#cluster-administration-over-http,openapi.yml.Technical decision
Backendembeds aClusterAdmininterface (the subset ofclusterpb.ClusterServiceServerused), wired to the existing gRPC server implementation. Errors go through the gRPC adapter's known-error mapping (extracted asKnownErrorStatus), then a status-to-HTTP rendering that keeps the gRPC status class, message and ledger reason (RAFT_NODE_REMOVAL_COMMITTED,RAFT_NODE_NOT_IN_CLUSTER).node/membershipdirectly from HTTP (duplicates forwarding and preflight); a loopback gRPC client (extra hop, auth plumbing); a dedicated maintenance route (duplicatesPOST /v3/_/apply).Risk
MEDIUM: new write surface for destructive cluster operations. Mitigated by the RPC's own fixed scopes (default mapping:
ledger:adminonly), strict input validation, and the shared gRPC implementation.Validation
bash scripts/agent-checkAI_REVIEW_BASE_SHA=7affc2ac5 bash scripts/agent-check-pr(race: adapter/grpc, adapter/http, bootstrap; Schemathesis 66/75 operations, the 9 cluster routes excluded)TestClusterAdmin_ErrorMapping(local and forwarded errors),TestClusterNodeID_Decoding,TestOpenAPI_ClusterAdmin(requests and responses againstopenapi.yml), route-scope exhaustiveness rowsArchitecture / behavior impact
pkg/grpcprotocol.Version(40) are unchanged. The v2-to-v3 endpoint map is unchanged: no v2 operation maps to these routes.classifyErroris unchanged; cluster handlers use their own status rendering.503after a membership or drain request (including a deadline or cancellation, mapped toUnavailableas on gRPC) does not prove non-commit; retry guidance is documented per operation.^/v3/_/cluster/: those operations would drain or reconfigure its single-node server.api-boundary-contracts,authentication-authorization-boundaries,raft-membership-leadership.Review focus
handleClusterError/clusterStatusClassininternal/adapter/http/cluster_admin.go: which status messages are passed through.KnownErrorStatusextraction ininternal/adapter/grpc/server.go(behavior-preserving move).Known concerns
CreateCheckpointis not exposed here; it belongs with the backup/restore HTTP work.