Raft: Implement Raft cluster bootstrapping
This issue tracks the work of bootstrapping a Raft cluster in Gitaly. As a part of &13562, we haven't supported dynamic cluster membership. The bootstrapping initializes necessary data for each Raft group and promotes the current node as the primary node of all Raft groups. The cluster should only be initialized once. At first glance, we need to add a sub-command to do so.
The raft configuration looks something like the following:
[[raft]]
cluster_id = "7766d7c1-7266-4bc9-9dad-5ee8617c455b"
node_id = 1
initial_addresses = {1: "127.0.0.1:3001", 2: "127.0.0.1:3002", 3: "127.0.0.1:3003"}
After the cluster is ready, two other nodes could join and be considered to be the replicas of all Raft groups of the primary node. Replica bootstrapping is handled at #6033.
If the cluster is turned off, the next node joining the cluster is elected to be the primary node. It takes over the cluster from the persistent state. The election and failover will be handled at #6039. This issue should focus on the bootstrapping part.
When bootstrapping, the initial member should do the following things:
-
Initialize cluster ID -
Initialize first storage ID -
Register its storages -
Persist all ddata.
This issue entails adding an adapter to make dragonboat
works with Gitaly's storage engine (badger).