[PR #2008] [MERGED] replace ephemeral deletion logic #2444

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

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2008
Author: @kradalby
Created: 7/12/2024
Status: Merged
Merged: 7/18/2024
Merged by: @kradalby

Base: mainHead: kradalby/2006-ephemerals-get-deleted


📝 Commits (8)

  • cb8c2fc replace ephemeral deletion logic
  • 69f3583 use uint64 as authekyid and ptr helper in tests
  • 4ee0b53 add test db helper
  • b6c0424 add list ephemeral node func
  • efd7964 schedule ephemeral nodes for removal on startup
  • 48731c2 fix gorm query for postgres
  • 8edb253 add godoc
  • 6d3ff2a Merge branch 'main' into kradalby/2006-ephemerals-get-deleted

📊 Changes

13 files changed (+417 additions, -206 deletions)

View changed files

📝 .github/workflows/test-integration.yaml (+1 -0)
📝 hscontrol/app.go (+20 -45)
📝 hscontrol/auth.go (+4 -4)
📝 hscontrol/db/node.go (+101 -45)
📝 hscontrol/db/node_test.go (+133 -18)
📝 hscontrol/db/preauth_keys.go (+2 -2)
📝 hscontrol/db/preauth_keys_test.go (+3 -76)
📝 hscontrol/db/routes_test.go (+6 -9)
📝 hscontrol/db/suite_test.go (+12 -2)
📝 hscontrol/db/users_test.go (+3 -4)
📝 hscontrol/poll.go (+15 -0)
📝 hscontrol/types/node.go (+1 -1)
📝 integration/general_test.go (+116 -0)

📄 Description

this commit replaces the way we remove ephemeral nodes, currently they are deleted in a loop and we look at last seen time. This time is now only set when a node disconnects and there was a bug (#2006) where nodes that had never disconnected was deleted since they did not have a last seen.

The new logic will start an expiry timer when the node disconnects and delete the node from the database when the timer is up.

If the node reconnects within the expiry, the timer is cancelled.

Fixes #2006


🔄 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/2008 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 7/12/2024 **Status:** ✅ Merged **Merged:** 7/18/2024 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `kradalby/2006-ephemerals-get-deleted` --- ### 📝 Commits (8) - [`cb8c2fc`](https://github.com/juanfont/headscale/commit/cb8c2fc91a08f0e6449e6fb8e51bcecd9f6e5e46) replace ephemeral deletion logic - [`69f3583`](https://github.com/juanfont/headscale/commit/69f3583dfb7c9611e6a68f99f4c5bd6c81c5dce0) use uint64 as authekyid and ptr helper in tests - [`4ee0b53`](https://github.com/juanfont/headscale/commit/4ee0b53109ce72423fe58a2cdb9e39ec1f7ea2ca) add test db helper - [`b6c0424`](https://github.com/juanfont/headscale/commit/b6c042480a53a66d2698e2a263e8aa49128888fd) add list ephemeral node func - [`efd7964`](https://github.com/juanfont/headscale/commit/efd7964c87077c117f4ae8ccafd49494cb75d939) schedule ephemeral nodes for removal on startup - [`48731c2`](https://github.com/juanfont/headscale/commit/48731c200b16857edfb41fa5418f3d42ce03fae5) fix gorm query for postgres - [`8edb253`](https://github.com/juanfont/headscale/commit/8edb253542047c88482e91b6a0fedb16a3fab206) add godoc - [`6d3ff2a`](https://github.com/juanfont/headscale/commit/6d3ff2a7572952908b41c3846d09c2b89b755b9f) Merge branch 'main' into kradalby/2006-ephemerals-get-deleted ### 📊 Changes **13 files changed** (+417 additions, -206 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test-integration.yaml` (+1 -0) 📝 `hscontrol/app.go` (+20 -45) 📝 `hscontrol/auth.go` (+4 -4) 📝 `hscontrol/db/node.go` (+101 -45) 📝 `hscontrol/db/node_test.go` (+133 -18) 📝 `hscontrol/db/preauth_keys.go` (+2 -2) 📝 `hscontrol/db/preauth_keys_test.go` (+3 -76) 📝 `hscontrol/db/routes_test.go` (+6 -9) 📝 `hscontrol/db/suite_test.go` (+12 -2) 📝 `hscontrol/db/users_test.go` (+3 -4) 📝 `hscontrol/poll.go` (+15 -0) 📝 `hscontrol/types/node.go` (+1 -1) 📝 `integration/general_test.go` (+116 -0) </details> ### 📄 Description this commit replaces the way we remove ephemeral nodes, currently they are deleted in a loop and we look at last seen time. This time is now only set when a node disconnects and there was a bug (#2006) where nodes that had never disconnected was deleted since they did not have a last seen. The new logic will start an expiry timer when the node disconnects and delete the node from the database when the timer is up. If the node reconnects within the expiry, the timer is cancelled. Fixes #2006 --- <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:18 +01:00
adam closed this issue 2025-12-29 03:21:18 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2444