[PR #1931] [MERGED] Simplify map session management #2403

Closed
opened 2025-12-29 03:21:05 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1931
Author: @kradalby
Created: 5/8/2024
Status: Merged
Merged: 5/24/2024
Merged by: @kradalby

Base: mainHead: kradalby/close-via-notifier


📝 Commits (10+)

  • e2d95e2 try to close on existing connection, also reject
  • 5b132b6 expand notifier and mapresp metrics
  • 59c522d make timeout and rejects label node id
  • 1f9ffaa remove mapresponse map
  • eb33299 standardise trace logging in notifier
  • 9851123 update comments
  • 3ed9f72 format id in metrics
  • 97f8b36 add missing ts version
  • 0a69b26 send updates async so we reach select in poll
  • 3d92837 expand integ test cert validity

📊 Changes

18 files changed (+423 additions, -282 deletions)

View changed files

📝 Dockerfile.tailscale-HEAD (+36 -14)
📝 flake.nix (+2 -2)
📝 go.mod (+2 -0)
📝 go.sum (+4 -0)
📝 hscontrol/app.go (+12 -33)
📝 hscontrol/metrics.go (+23 -8)
📝 hscontrol/noise.go (+5 -55)
📝 hscontrol/notifier/metrics.go (+41 -5)
📝 hscontrol/notifier/notifier.go (+135 -56)
📝 hscontrol/notifier/notifier_test.go (+1 -1)
📝 hscontrol/poll.go (+98 -70)
📝 hscontrol/types/config.go (+4 -1)
📝 hscontrol/types/node.go (+4 -0)
📝 integration/general_test.go (+24 -20)
📝 integration/hsic/hsic.go (+8 -4)
📝 integration/scenario.go (+9 -4)
📝 integration/tailscale.go (+4 -1)
📝 integration/tsic/tsic.go (+11 -8)

📄 Description

This PR removes the complicated session management introduced in https://github.com/juanfont/headscale/pull/1791 which kept track of the sessions in a map, in addition to the channel already kept track of in the notifier.

Instead of trying to close the mapsession, it will now be replaced by the new one and closed after so all new updates goes to the right place.

The map session serve function is also split into a streaming and a non-streaming version for better readability.

RemoveNode in the notifier will not remove a node if the channel is not matching the one that has been passed (e.g. it has been replaced with a new one).

A new tuning parameter has been added to added to set timeout before the notifier gives up to send an update to a node.

Add a keep alive resetter so we wait with sending keep alives if a node has just received an update.

In addition it adds a bunch of env debug flags that can be set:

  • HEADSCALE_DEBUG_HIGH_CARDINALITY_METRICS: make certain metrics include per node.id, not recommended to use in prod.
  • HEADSCALE_DEBUG_PROFILING_ENABLED: activate tracing
  • HEADSCALE_DEBUG_PROFILING_PATH: where to store traces
  • HEADSCALE_DEBUG_DUMP_CONFIG: calls spew.Dump on the config object startup
  • HEADSCALE_DEBUG_DEADLOCK: enable go-deadlock to dump goroutines if it looks like a deadlock has occured, enabled in integration tests.

Signed-off-by: Kristoffer Dalby kristoffer@tailscale.com


🔄 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/1931 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 5/8/2024 **Status:** ✅ Merged **Merged:** 5/24/2024 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `kradalby/close-via-notifier` --- ### 📝 Commits (10+) - [`e2d95e2`](https://github.com/juanfont/headscale/commit/e2d95e25a1df289e9c0a1f91f927edd58aa61abf) try to close on existing connection, also reject - [`5b132b6`](https://github.com/juanfont/headscale/commit/5b132b66b7a4bc74a67a42f2e3c5b1ba0b24d04c) expand notifier and mapresp metrics - [`59c522d`](https://github.com/juanfont/headscale/commit/59c522d1f56b732c1d0870411d5a6044e94aeed6) make timeout and rejects label node id - [`1f9ffaa`](https://github.com/juanfont/headscale/commit/1f9ffaa449a961d10a3b3e21d7ea03fb01493400) remove mapresponse map - [`eb33299`](https://github.com/juanfont/headscale/commit/eb332996d9a5587f992f96ee9519f8b5a0055c1b) standardise trace logging in notifier - [`9851123`](https://github.com/juanfont/headscale/commit/9851123d7055bcb731a8f64e5f9e1ce57415bf8c) update comments - [`3ed9f72`](https://github.com/juanfont/headscale/commit/3ed9f72707675148e8f306844ec263a71d7d268c) format id in metrics - [`97f8b36`](https://github.com/juanfont/headscale/commit/97f8b36ccbd51c6636e0e85f31e86b7f156ce850) add missing ts version - [`0a69b26`](https://github.com/juanfont/headscale/commit/0a69b261dc66a99b64905e27dddb45af46b77614) send updates async so we reach select in poll - [`3d92837`](https://github.com/juanfont/headscale/commit/3d928379e230e0d3f4feacbc36658963e667dd3c) expand integ test cert validity ### 📊 Changes **18 files changed** (+423 additions, -282 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile.tailscale-HEAD` (+36 -14) 📝 `flake.nix` (+2 -2) 📝 `go.mod` (+2 -0) 📝 `go.sum` (+4 -0) 📝 `hscontrol/app.go` (+12 -33) 📝 `hscontrol/metrics.go` (+23 -8) 📝 `hscontrol/noise.go` (+5 -55) 📝 `hscontrol/notifier/metrics.go` (+41 -5) 📝 `hscontrol/notifier/notifier.go` (+135 -56) 📝 `hscontrol/notifier/notifier_test.go` (+1 -1) 📝 `hscontrol/poll.go` (+98 -70) 📝 `hscontrol/types/config.go` (+4 -1) 📝 `hscontrol/types/node.go` (+4 -0) 📝 `integration/general_test.go` (+24 -20) 📝 `integration/hsic/hsic.go` (+8 -4) 📝 `integration/scenario.go` (+9 -4) 📝 `integration/tailscale.go` (+4 -1) 📝 `integration/tsic/tsic.go` (+11 -8) </details> ### 📄 Description This PR removes the complicated session management introduced in https://github.com/juanfont/headscale/pull/1791 which kept track of the sessions in a map, in addition to the channel already kept track of in the notifier. Instead of trying to close the mapsession, it will now be replaced by the new one and closed after so all new updates goes to the right place. The map session serve function is also split into a streaming and a non-streaming version for better readability. RemoveNode in the notifier will not remove a node if the channel is not matching the one that has been passed (e.g. it has been replaced with a new one). A new tuning parameter has been added to added to set timeout before the notifier gives up to send an update to a node. Add a keep alive resetter so we wait with sending keep alives if a node has just received an update. In addition it adds a bunch of env debug flags that can be set: - `HEADSCALE_DEBUG_HIGH_CARDINALITY_METRICS`: make certain metrics include per node.id, not recommended to use in prod. - `HEADSCALE_DEBUG_PROFILING_ENABLED`: activate tracing - `HEADSCALE_DEBUG_PROFILING_PATH`: where to store traces - `HEADSCALE_DEBUG_DUMP_CONFIG`: calls `spew.Dump` on the config object startup - `HEADSCALE_DEBUG_DEADLOCK`: enable go-deadlock to dump goroutines if it looks like a deadlock has occured, enabled in integration tests. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> --- <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 03:21:05 +01:00
adam closed this issue 2025-12-29 03:21:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2403