Skip to content
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

redo all route code #2422

Conversation

kradalby
Copy link
Collaborator

@kradalby kradalby commented Feb 11, 2025

This is more of an experiment that might work out, might not.

I've been worn down by how incredibly complicated our route (subnet route) and particularly HA route logic is. the database part has pointers to state that should be way out of reach (connected nodes) and so on.
We also store a bunch of info in the database that we dont need to persist:

  • Routes dont need its own table, it might as well just live in node.hostinfo (instead of being copied)
  • Approved routes can just be a prefix list on the node object, in the node table
  • Primary Route (HA) is only relevant at runtime, if there are two of a node, only set it for one.
  • CLI interface can just be overwriting, a set operation listing all approved routes for a node.

Base premise:

  • Remove Route table and code (keep structure for migration)
  • Remove complex save logic trying to figure out if its HA and needs to be failed over and all at the same time as saving.
  • Approvals is a simple list on the node object
  • "Announced" routes are the Hostinfo.RoutableIPs minus !ApprovedRoutes
  • Track Primary routes "in memory"
    • This part isnt necessarily beautiful, but I think it will be a lot simpler
  • these changes very seldom, so when a HA change, just send a full update
    • This we can optimise later, and the new structure should fit better into an event bus of some sort.

There is gonna be part of this code which isnt particularly "efficient", but that can be optimised later. I doubt it would be worse than the current setup anyways. Make it work, then make it fast.

TODO:

New CLI should be a lot easier to reason about:

List all (or specific) routes:

headscale nodes list-routes  [-i <node_id>]

Approval of routes will overwrite all, so you define the ones you want,
you can approve routes that are not yet defined:

headscale nodes approve-routes -i <node_id> "comma,separated,routes"

@kradalby kradalby force-pushed the kradalby/hypothetical-deletion-of-all-routes-code branch 4 times, most recently from 9b72603 to 3e353c3 Compare February 17, 2025 21:55
@kradalby kradalby force-pushed the kradalby/hypothetical-deletion-of-all-routes-code branch from 768156c to 05cca51 Compare February 24, 2025 11:46
@kradalby kradalby marked this pull request as ready for review February 24, 2025 16:03
@kradalby kradalby force-pushed the kradalby/hypothetical-deletion-of-all-routes-code branch from 1b40061 to 2859e02 Compare February 25, 2025 12:34
Signed-off-by: Kristoffer Dalby <[email protected]>
@kradalby kradalby force-pushed the kradalby/hypothetical-deletion-of-all-routes-code branch from 2859e02 to f57d0f6 Compare February 26, 2025 10:26
@kradalby kradalby merged commit 7891378 into juanfont:main Feb 26, 2025
140 of 145 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants