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

Subnet Routing Failover #54

Closed
Tracked by #35
drag0n141 opened this issue Mar 21, 2023 · 16 comments
Closed
Tracked by #35

Subnet Routing Failover #54

drag0n141 opened this issue Mar 21, 2023 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@drag0n141
Copy link

Is it planned to add the subnet failover function to the webui?

juanfont/headscale#1024

@iFargle iFargle mentioned this issue Mar 21, 2023
11 tasks
@iFargle
Copy link
Owner

iFargle commented Mar 21, 2023

I'll give it a shot :)

@iFargle iFargle self-assigned this Mar 22, 2023
@iFargle iFargle added the enhancement New feature or request label Mar 22, 2023
@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

So it doesn't look like there's a way to do this via the builtin API, other than enabling / disabling routes in a certain order to determine which is primary.

As of now, it looks like if you just enable the route on two nodes it "just works" -- Do you need to be able to select which is primary?

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

I can also add an indicator of route failover if that would be beneficial

@drag0n141
Copy link
Author

As of now, it looks like if you just enable the route on two nodes it "just works" -- Do you need to be able to select which is primary?

Yes correctly :) but dont know i that is possible i am not using the routing failover at the moment.

I can also add an indicator of route failover if that would be beneficial

I think that would help.

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

It's technically possible -- I'll see what I can do! I'm working on rewriting how I manage routes so once that's done I"ll work on this

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

I've added some preliminary work into v0.6.0
You can test with ghcr.io/ifargle/headscale-webui:testing right now if you'd like to try it out

@drag0n141
Copy link
Author

I have installed the :testing version. Now all Routes are duplicated. One normal Route and one as "Failover Pair"

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

Interesting...
All routes, including the exit routes?

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

Can you give examples of the failover ranges you are using?
All I'm doing right now is a simple list search to determine if there are duplicate IP's:

headscale-webui/renderer.py

Lines 307 to 332 in fc5908f

for route in pulled_routes["routes"]:
for route_info in all_routes["routes"]:
if str(route_info["prefix"]) == str(route["prefix"]) and (route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0"):
if route_info["id"] != route["id"]:
ha_enabled = False
app.logger.info("HA pair found: %s", str(route["prefix"]))
failover_pair_prefixes = str(route["prefix"])
if route["enabled"]:
ha_enabled = True
if route["prefix"] != "0.0.0.0/0" and route["prefix"] != "::/0" and route["prefix"] in failover_pair_prefixes:
route_enabled = "red"
route_tooltip = 'enable'
color_index = failover_pair_prefixes.index(str(route["prefix"]))
route_enabled_color = helper.get_color(color_index, "failover")
if route["enabled"]:
color_index = failover_pair_prefixes.index(str(route["prefix"]))
route_enabled = helper.get_color(color_index, "failover")
route_tooltip = 'disable'
routes = routes+""" <p
class='waves-effect waves-light btn-small """+route_enabled+""" lighten-2 tooltipped'
data-position='top' data-tooltip='Click to """+route_tooltip+""" (Failover Pair)'
id='"""+route['id']+"""'
onclick="toggle_failover_route("""+route['id']+""", '"""+str(route['enabled'])+"""', '"""+str(route_enabled_color)+"""')">
"""+route['prefix']+"""
</p>
"""

@iFargle
Copy link
Owner

iFargle commented Mar 22, 2023

Oh I see the issue..

failover_pair_prefixes = str(route["prefix"])

Should be...
failover_pair_prefixes.append(str(route["prefix"]))

I've pushed anew build. Let me know if you still see duplicates

@iFargle
Copy link
Owner

iFargle commented Mar 23, 2023

I need to figure out a better way to do this.
I think in the next release I'll add another button to the machines page dedicated to managing routes. The way it's currently implemented is limited. It's also something I've been wanting for a bit but it'll require some work

@drag0n141
Copy link
Author

Now it looks good no more duplicates :)

image

@iFargle
Copy link
Owner

iFargle commented Mar 23, 2023

Perfect!
They're colored based on their pair. I think I'm going to add a routes page to this release. I'll see if I have time

@iFargle
Copy link
Owner

iFargle commented Mar 23, 2023

btw don't use testing for long -- I am always pushing updates to it so things will break all the time. Or just use this current release of testing until I push it to main :)

@iFargle
Copy link
Owner

iFargle commented Mar 29, 2023

Back at it this week. Made some good improvements in the testing build
image

Once I finish the code up for better enabling/disabling of these routes it will be pushed to main

@iFargle
Copy link
Owner

iFargle commented Mar 30, 2023

Closing -- This will be in main in about 1.5 hours (multiarch builds take a while). Please use the main branch after it's available.

Thanks!

@iFargle iFargle closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants