-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codereorg: Part 5, state #1492
Codereorg: Part 5, state #1492
Conversation
631d1a8
to
e4b0e82
Compare
32a0567
to
b5be2ef
Compare
All tests pass locally, it is hard to know if Github actions is reliable or not. |
My observation so far is that tests including a larger amount of nodes are more unreliable, particularly with excess network requirements:
|
260c535
to
1b344ac
Compare
55aca05
to
5b8053f
Compare
7071644
to
0b4dc82
Compare
546f1f0
to
0864811
Compare
0864811
to
4bdfde3
Compare
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit replaces the timestamp based state system with a new one that has update channels directly to the connected nodes. It will send an update to all listening clients via the polling mechanism. It introduces a new package notifier, which has a concurrency safe manager for all our channels to the connected nodes. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commits extends the mapper with functions for creating "delta" MapResponses for different purposes (peer changed, peer removed, derp). This wires up the new state management with a new StateUpdate struct letting the poll worker know what kind of update to send to the connected nodes. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Co-Authored-By: Jason <armooo@armooo.net> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
93788d5
to
1d7b736
Compare
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Closes juanfont#1544 Co-Authored-By: Patrick Huang <huangxiaoman@gmail.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
1d7b736
to
86937b9
Compare
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This field is no longer used, it was used in our old state "algorithm" to determine if we should send an update. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit rearranges the poll handler to immediatly accept updates and notify its peers and return, not travel down the function for a bit. This reduces the DB calls and other holdups that isnt necessary to send a "lite response", a map response without peers, or accepting an endpoint update. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
86937b9
to
1f4d51d
Compare
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Hello there, I'm start testing this changes, and found bug with "on-the-fly" state update:
|
It seems there is also an issue with updating the "last-seen"/"online" status. I wanted to test the subnet-router failover, but as soon as I executed
Although there are no network connectivity issues, tailscale is working, and headscale is accessible via http:
|
@vsychov Thank you, I appreciate this a lot. I think what I will do since this PR is so messy already is to get it in, and then it would be great if you could create two issues for me on this (and other things you find), and then we make them blocking before alpha. I would also appreciate your continued testing of this work. |
Approved! |
hscontrol/mapper/mapper.go
Outdated
changed := make(types.Machines, len(machineKeys)) | ||
lastSeen := make(map[tailcfg.NodeID]bool) | ||
for idx, machineKey := range machineKeys { | ||
peer, err := m.db.GetMachineByID(machineKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing MachineKey with IDs of the DB?
} | ||
|
||
func NewNotifier() *Notifier { | ||
return &Notifier{} | ||
} | ||
|
||
func (n *Notifier) AddNode(machineKey string, c chan<- struct{}) { | ||
func (n *Notifier) AddNode(machineKey string, c chan<- types.StateUpdate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here seems to be the MachineKey of the Node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have nodes with the same machinekey but different nodekeys, right?
@vsychov did you try the tests with the route/exit node issue including the last commit? Would you mind opening an issue for that one? I'll have a look at the online status now. |
@kradalby , I'll try my tests on current |
Problems still appear, I created issue: #1561 |
This PR reworks the state management in headscale, instead of relying on timestamps and frequent checking, and sending the entire world every time, we now send incremental updates based on the change that has happened.
Closes #1390
Fixes #1461