6 Commits

Author SHA1 Message Date
Fran Bull
bd3128752c cmd/natc,tsconsensus: add 'follower only' bootstrap option
Currently consensus has a bootstrap routine where a tsnet node tries to
join each other node with the cluster tag, and if it is not able to join
any other node it starts its own cluster.

That algorithm is racy, and can result in split brain (more than one
leader/cluster) if all the nodes for a cluster are started at the same
time.

Add a FollowAddr argument to the bootstrap function. If provided this
tsnet node will never lead, it will try (and retry with exponential back
off) to follow the node at the provided address.

Add a --follow flag to cmd/natc that uses this new tsconsensus
functionality.

Also slightly reorganize some arguments into opts structs.

Updates #14667

Signed-off-by: Fran Bull <fran@tailscale.com>
2025-07-16 09:11:20 -07:00
Brad Fitzpatrick
12e92b1b08 tsconsensus: skipping slow non-applicable tests on Windows for now
Updates #16340

Change-Id: I61b0186295c095f99c5be81dc4dced5853025d35
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-06-20 10:42:15 -07:00
Fran Bull
3d6e1171c1 tsconsensus: protect from data race
lock for access to a.peers

Fixes #16284

Signed-off-by: Fran Bull <fran@tailscale.com>
2025-06-16 10:31:51 -07:00
Fran Bull
c9a5d638e9 tsconsensus: enable writing state to disk
The comments in the raft code say to only use the InMemStore for tests.

Updates #16027

Signed-off-by: Fran Bull <fran@tailscale.com>
2025-05-30 13:59:25 -07:00
Fran Bull
11d1dd2aed tsconsensus: mark 2 tests that were flaky in CI
Updates #15627

Signed-off-by: Fran Bull <fran@tailscale.com>
2025-04-11 07:59:10 -07:00
Fran Bull
8597b25840 tsconsensus: add a tsconsensus package
tsconsensus enables tsnet.Server instances to form a consensus.

tsconsensus wraps hashicorp/raft with
 * the ability to do discovery via tailscale tags
 * inter node communication over tailscale
 * routing of commands to the leader

Updates #14667

Signed-off-by: Fran Bull <fran@tailscale.com>
2025-04-08 13:12:14 -07:00