1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-11-27 20:04:00 +01:00
juanfont.headscale/hscontrol/db
Kristoffer Dalby 4a8dc2d445 hscontrol/state,db: preserve node expiry on MapRequest updates
Fixes a regression introduced in v0.27.0 where node expiry times were
being reset to zero when tailscaled restarts and sends a MapRequest.

The issue was caused by using GORM's Save() method in persistNodeToDB(),
which overwrites ALL fields including zero values. When a MapRequest
updates a node (without including expiry information), Save() would
overwrite the database expiry field with a zero value.

Changed to use Updates() which only updates non-zero values, preserving
existing database values when struct pointer fields are nil.

In BackfillNodeIPs, we need to explicitly update IPv4/IPv6 fields even
when nil (to remove IPs), so we use Select() to specify those fields.

Added regression test that validates expiry is preserved after MapRequest.

Fixes #2862
2025-11-11 12:47:48 -06:00
..
sqliteconfig db: add sqlite "source of truth" schema 2025-07-07 15:48:38 +01:00
testdata db: add defensive removal of old indicies 2025-11-10 20:07:29 +01: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_test.go mapper: produce map before poll (#2628) 2025-07-28 11:15:53 +02:00
db.go db: add defensive removal of old indicies 2025-11-10 20:07:29 +01:00
ephemeral_garbage_collector_test.go db: add sqlite "source of truth" schema 2025-07-07 15:48:38 +01:00
ip_test.go Redo route code (#2422) 2025-02-26 16:22:55 +01:00
ip.go hscontrol/state,db: preserve node expiry on MapRequest updates 2025-11-11 12:47:48 -06:00
node_test.go state: use AllApprovedRoutes instead of SubnetRoutes 2025-11-02 13:19:59 +01:00
node.go state: use AllApprovedRoutes instead of SubnetRoutes 2025-11-02 13:19:59 +01:00
policy.go reformat code (#2019) 2024-07-22 08:56:00 +02:00
preauth_keys_test.go mapper: produce map before poll (#2628) 2025-07-28 11:15:53 +02:00
preauth_keys.go state/nodestore: in memory representation of nodes 2025-09-09 09:40:00 +02:00
schema.sql db: add sqlite "source of truth" schema 2025-07-07 15:48:38 +01:00
suite_test.go db: add sqlite "source of truth" schema 2025-07-07 15:48:38 +01:00
text_serialiser.go Refactor to use reflect.TypeFor 2025-08-23 20:43:49 +02:00
users_test.go mapper: produce map before poll (#2628) 2025-07-28 11:15:53 +02:00
users.go stricter hostname validation and replace (#2383) 2025-10-22 13:50:39 +02:00