Skip to content

Commit eae6695

Browse files
craig[bot]shubhamdhama
andcommitted
Merge #148451
148451: kv,server: extract `Cluster` service and register with DRPC server r=cthumuluru-crdb a=shubhamdhama `` kv,server: extract `Cluster` service and register with DRPC server `` This is a follow-up to #145195, where we extracted `KVBatch` from the `Internal` service. Here, we do the same with `Cluster`. The TL;DR is that smaller services are easier to maintain and can be more smoothly migrated to DRPC. We also enable this service on the DRPC server. This is controlled by `rpc.experimental_drpc.enabled` (off by default). This change is part of a series and is similar to: #146926 Note: This only registers the service; the client is not updated to use the DRPC client, so this service will not have any functional effect. `` server: replace `RPCClusterClient` for cluster join operation `` This change replaces the direct client creation through `NewInternalClient` with the gRPC adapter. See #147950 for more context. Also, since we have a more targeted service for `Join` RPC, we should use its adapter interface. Release note: none Epic: CRDB-48923 Co-authored-by: Shubham Dhama <[email protected]>
2 parents 32b9329 + b884f97 commit eae6695

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

pkg/kv/kvpb/api.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,6 +3727,14 @@ service TenantSpanConfig {
37273727
rpc SpanConfigConformance(SpanConfigConformanceRequest) returns (SpanConfigConformanceResponse) {}
37283728
}
37293729

3730+
// Cluster service offers RPCs for inter-node communication essential for
3731+
// cluster bootstrapping and operation.
3732+
service Cluster {
3733+
// Join a bootstrapped cluster. If the target node is itself not part of a
3734+
// bootstrapped cluster, an appropriate error is returned.
3735+
rpc Join (JoinNodeRequest) returns (JoinNodeResponse) {}
3736+
}
3737+
37303738
// Batch and RangeFeed service implemented by nodes for KV API requests.
37313739
service Internal {
37323740
rpc Batch (BatchRequest) returns (BatchResponse) {}

pkg/server/init.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ func (s *initServer) attemptJoinTo(
466466
BinaryVersion: &latestVersion,
467467
}
468468

469-
initClient := kvpb.NewInternalClient(conn)
469+
var initClient kvpb.RPCClusterClient
470+
if !rpcbase.TODODRPC {
471+
initClient = kvpb.NewGRPCInternalClientAdapter(conn)
472+
}
470473
resp, err := initClient.Join(ctx, req)
471474
if err != nil {
472475
status, ok := grpcstatus.FromError(errors.UnwrapAll(err))

pkg/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,9 @@ func NewServer(cfg Config, stopper *stop.Stopper) (serverctl.ServerStartupInterf
995995
if err := kvpb.DRPCRegisterTenantSpanConfig(drpcServer, node); err != nil {
996996
return nil, err
997997
}
998+
if err := kvpb.DRPCRegisterCluster(drpcServer, node); err != nil {
999+
return nil, err
1000+
}
9981001
kvserver.RegisterPerReplicaServer(grpcServer.Server, node.perReplicaServer)
9991002
if err := kvserver.DRPCRegisterPerReplica(drpcServer, node.perReplicaServer); err != nil {
10001003
return nil, err

0 commit comments

Comments
 (0)