headscale/hscontrol/db
Kristoffer Dalby 7e62031444
replace ephemeral deletion logic (#2008)
* replace ephemeral deletion logic

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

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

* use uint64 as authekyid and ptr helper in tests

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

* add test db helper

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

* add list ephemeral node func

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

* schedule ephemeral nodes for removal on startup

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

* fix gorm query for postgres

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

* add godoc

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

---------

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-07-18 10:01:59 +02:00
..
api_key_test.go Replace the timestamp based state system 2023-09-19 10:20:21 -05:00
api_key.go Replace database locks with transactions (#1701) 2024-02-08 17:28:19 +01:00
db.go feat: implements apis for managing headscale policy (#1792) 2024-07-18 07:38:25 +02:00
ip_test.go Restore foreign keys and add constraints (#1562) 2024-05-15 20:40:14 -04:00
ip.go Migrate IP fields in database to dedicated columns (#1869) 2024-04-17 07:03:06 +02:00
node_test.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
node.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
policy.go feat: implements apis for managing headscale policy (#1792) 2024-07-18 07:38:25 +02:00
preauth_keys_test.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
preauth_keys.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
routes_test.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
routes.go Remove allocations of lists before use (#1989) 2024-06-23 22:06:50 +02:00
suite_test.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
users_test.go replace ephemeral deletion logic (#2008) 2024-07-18 10:01:59 +02:00
users.go more log.Error -> fmt.Errorf cleanup 2024-04-15 12:31:53 +02:00