[PR #1024] [MERGED] Refactor routing code and add support for subnet failover (HA) #1824

Closed
opened 2025-12-29 02:31:51 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1024
Author: @juanfont
Created: 11/28/2022
Status: Merged
Merged: 12/6/2022
Merged by: @kradalby

Base: mainHead: improve-routing


📝 Commits (10+)

  • 6484171 Add Route DB model and migration from existing field
  • 053bb70 Call processMachineRoutes when a new Map is received
  • 4bbd898 Refactor machine.go, and move functionality to routes.go + unit tests
  • f5ffc19 Added helper methods for subnet failover + unit tests
  • fada22e Run handlePrimarySubnetFailover() with a ticker when Serve
  • 6e23817 Removed unused code and linting fixes
  • 05bc1dd Update protobuf definitions + support methods for the API
  • 2020240 Updated generated pb code
  • 4e1ac8f Refactored route grpc glue code
  • eae37aa Use the new routes API from the CLI

📊 Changes

21 files changed (+2333 additions, -1173 deletions)

View changed files

📝 CHANGELOG.md (+3 -1)
📝 api_common.go (+2 -2)
📝 app.go (+12 -0)
📝 cmd/headscale/cli/routes.go (+102 -102)
📝 db.go (+89 -2)
📝 gen/go/headscale/v1/headscale.pb.go (+130 -109)
📝 gen/go/headscale/v1/headscale.pb.gw.go (+410 -352)
📝 gen/go/headscale/v1/headscale_grpc.pb.go (+100 -28)
📝 gen/go/headscale/v1/routes.pb.go (+411 -116)
📝 gen/openapiv2/headscale/v1/headscale.swagger.json (+138 -62)
📝 grpcv1.go (+37 -12)
📝 integration/cli_test.go (+143 -0)
📝 integration_cli_test.go (+0 -193)
📝 machine.go (+146 -74)
📝 machine_test.go (+9 -2)
📝 proto/headscale/v1/headscale.proto (+18 -4)
📝 proto/headscale/v1/routes.proto (+35 -12)
📝 protocol_common_poll.go (+18 -1)
📝 routes.go (+282 -62)
📝 routes_test.go (+248 -29)

...and 1 more files

📄 Description

This PR implements https://github.com/juanfont/headscale/pull/988, for better route management.

It enables Headscale to:

  • Enable and disable advertised subnets
  • Handle exit nodes
  • Manage multiple nodes offering the same route
  • Failover to another node when the primary node for a subnet is disconnected

Should also implement https://github.com/juanfont/headscale/issues/1010, and https://github.com/juanfont/headscale/issues/260.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1024 **Author:** [@juanfont](https://github.com/juanfont) **Created:** 11/28/2022 **Status:** ✅ Merged **Merged:** 12/6/2022 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `improve-routing` --- ### 📝 Commits (10+) - [`6484171`](https://github.com/juanfont/headscale/commit/6484171e97c1135a37b89901fbdd99cb56ee3024) Add Route DB model and migration from existing field - [`053bb70`](https://github.com/juanfont/headscale/commit/053bb704063f9ffd9e01bdb699e69dced793647d) Call processMachineRoutes when a new Map is received - [`4bbd898`](https://github.com/juanfont/headscale/commit/4bbd898fa2f383467173200984818ff676864329) Refactor machine.go, and move functionality to routes.go + unit tests - [`f5ffc19`](https://github.com/juanfont/headscale/commit/f5ffc19d89970e0ef665ea0dd0021c5280aa5352) Added helper methods for subnet failover + unit tests - [`fada22e`](https://github.com/juanfont/headscale/commit/fada22e9459391c5051505268038619ac3c05aca) Run handlePrimarySubnetFailover() with a ticker when Serve - [`6e23817`](https://github.com/juanfont/headscale/commit/6e2381762f3a1c7070bdb2d3eb03d4cea6c5ed6b) Removed unused code and linting fixes - [`05bc1dd`](https://github.com/juanfont/headscale/commit/05bc1dd8a46ee3777d39196e6c9748a153392e55) Update protobuf definitions + support methods for the API - [`2020240`](https://github.com/juanfont/headscale/commit/2020240a8afcd6c43c7b23d831935f508263899b) Updated generated pb code - [`4e1ac8f`](https://github.com/juanfont/headscale/commit/4e1ac8f4054b75f8e686d562b243f1d135dbf8c3) Refactored route grpc glue code - [`eae37aa`](https://github.com/juanfont/headscale/commit/eae37aabab7de82cc9e8726f749e5c240afe9a7e) Use the new routes API from the CLI ### 📊 Changes **21 files changed** (+2333 additions, -1173 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -1) 📝 `api_common.go` (+2 -2) 📝 `app.go` (+12 -0) 📝 `cmd/headscale/cli/routes.go` (+102 -102) 📝 `db.go` (+89 -2) 📝 `gen/go/headscale/v1/headscale.pb.go` (+130 -109) 📝 `gen/go/headscale/v1/headscale.pb.gw.go` (+410 -352) 📝 `gen/go/headscale/v1/headscale_grpc.pb.go` (+100 -28) 📝 `gen/go/headscale/v1/routes.pb.go` (+411 -116) 📝 `gen/openapiv2/headscale/v1/headscale.swagger.json` (+138 -62) 📝 `grpcv1.go` (+37 -12) 📝 `integration/cli_test.go` (+143 -0) 📝 `integration_cli_test.go` (+0 -193) 📝 `machine.go` (+146 -74) 📝 `machine_test.go` (+9 -2) 📝 `proto/headscale/v1/headscale.proto` (+18 -4) 📝 `proto/headscale/v1/routes.proto` (+35 -12) 📝 `protocol_common_poll.go` (+18 -1) 📝 `routes.go` (+282 -62) 📝 `routes_test.go` (+248 -29) _...and 1 more files_ </details> ### 📄 Description This PR implements https://github.com/juanfont/headscale/pull/988, for better route management. It enables Headscale to: - Enable and disable advertised subnets - Handle exit nodes - Manage multiple nodes offering the same route - Failover to another node when the primary node for a subnet is disconnected Should also implement https://github.com/juanfont/headscale/issues/1010, and https://github.com/juanfont/headscale/issues/260. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 02:31:51 +01:00
adam closed this issue 2025-12-29 02:31:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1824