mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-25 04:37:42 +00:00
cmd/natc,tsconsensus: add cluster config admin
Add the ability for operators of natc in consensus mode to remove servers from the raft cluster config, without losing other state. Updates #14667 Signed-off-by: Fran Bull <fran@tailscale.com>
This commit is contained in:
@@ -30,6 +30,7 @@ type ConsensusIPPool struct {
|
||||
IPSet *netipx.IPSet
|
||||
perPeerMap *syncs.Map[tailcfg.NodeID, *consensusPerPeerState]
|
||||
consensus commandExecutor
|
||||
clusterController clusterController
|
||||
unusedAddressLifetime time.Duration
|
||||
}
|
||||
|
||||
@@ -168,6 +169,7 @@ func (ipp *ConsensusIPPool) StartConsensus(ctx context.Context, ts *tsnet.Server
|
||||
return err
|
||||
}
|
||||
ipp.consensus = cns
|
||||
ipp.clusterController = cns
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -442,3 +444,18 @@ func (ipp *ConsensusIPPool) Apply(l *raft.Log) any {
|
||||
type commandExecutor interface {
|
||||
ExecuteCommand(tsconsensus.Command) (tsconsensus.CommandResult, error)
|
||||
}
|
||||
|
||||
type clusterController interface {
|
||||
GetClusterConfiguration() (raft.Configuration, error)
|
||||
DeleteClusterServer(id raft.ServerID) (uint64, error)
|
||||
}
|
||||
|
||||
// GetClusterConfiguration gets the consensus implementation's cluster configuration
|
||||
func (ipp *ConsensusIPPool) GetClusterConfiguration() (raft.Configuration, error) {
|
||||
return ipp.clusterController.GetClusterConfiguration()
|
||||
}
|
||||
|
||||
// DeleteClusterServer removes a server from the consensus implementation's cluster configuration
|
||||
func (ipp *ConsensusIPPool) DeleteClusterServer(id raft.ServerID) (uint64, error) {
|
||||
return ipp.clusterController.DeleteClusterServer(id)
|
||||
}
|
||||
|
Reference in New Issue
Block a user