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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

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 logic 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:

  • Wire up Primary route tracker
  • Delete old CLI, write new
  • Write migration code (and test)
  • handle autoapprovers

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"

Signed-off-by: Kristoffer Dalby <[email protected]>
Signed-off-by: Kristoffer Dalby <[email protected]>
@kradalby kradalby force-pushed the kradalby/hypothetical-deletion-of-all-routes-code branch from be0020c to d658a67 Compare February 13, 2025 14:38
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.

1 participant