fleet/server/datastore
Dante Catalfamo 3a2a689796
Don't expire iOS devices prematurely (#25436)
#25406 

The `last_seen_times` table is only updates when osquery hits one of its
authenticated endpoints, meaning it isn't updated when devices without
osquery, like iphones, are enrolled. I've left a
[comment](https://github.com/fleetdm/fleet/issues/25406#issuecomment-2590637318)
on the original issue explaining how this happens. Originally, if there
was no `last_seen_time`, the fallback value would be the `created_at`
value on the `hosts` table, so ios devices would always get deleted once
they were added X number of days ago.

In its place, I've added the `detail_updated_at` column on the `hosts`
table as the fallback value, and only use `created_at` if that is also
empty. `detail_updated_at` is updated every time a full detail refetch
completes. In the case of ios/ipados, [this is done using
MDM](cd5c0e8aed/server/service/apple_mdm.go (L3101)).
`detail_updated_at` is updated less frequently than `last_seen_times`,
only once every hour or so instead of every 30 seconds, but since
expiration policies are set on the scale of days instead of hours, this
should be fine.

The way I've QA'd this is by adding an iOS device to my fleet instance,
waited 24 hours, and set the expiration policy to 24 hours.
2025-01-16 10:13:22 -05:00
..
cached_mysql Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
filesystem Added signed URLs (#25197) 2025-01-09 12:56:54 -06:00
mysql Don't expire iOS devices prematurely (#25436) 2025-01-16 10:13:22 -05:00
mysqlredis Support matching a host in orbit enrollment using the serial number (#9612) 2023-02-28 12:55:04 -05:00
redis Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
s3 Added signed URLs (#25197) 2025-01-09 12:56:54 -06:00