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:
Fran Bull
2025-08-19 13:11:10 -07:00
committed by franbull
parent d986baa18f
commit b48d2de6ab
3 changed files with 75 additions and 0 deletions

View File

@@ -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)
}