fleet/server/datastore/mysql
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
..
common_mysql Fixing issue where deleted profiles were being sent to devices. (#25095) 2025-01-06 13:16:34 -06:00
migrations Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
activities.go Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
activities_test.go Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
aggregated_stats.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
aggregated_stats_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
app_configs.go Include Linux disk encryption status in configuration profiles aggregate status response when applicable, fix disk encryption/MDM configuration order-of-operations issues, add integration tests for LUKS (#24114) 2024-11-25 08:34:43 -06:00
app_configs_test.go Include Linux disk encryption status in configuration profiles aggregate status response when applicable, fix disk encryption/MDM configuration order-of-operations issues, add integration tests for LUKS (#24114) 2024-11-25 08:34:43 -06:00
apple_mdm.go Fixed issue with incorrect batch DDM update activity. (#25372) 2025-01-14 11:24:36 -06:00
apple_mdm_test.go Fix bug where DDM/Windows profiles with secrets were not being marked Verified. (#25065) 2025-01-01 18:43:02 -06:00
calendar_events.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
calendar_events_test.go Correctly handle NULL timezones (#20605) 2024-07-22 10:04:29 -07:00
campaigns.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
campaigns_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
carves.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
carves_test.go
config.go 🧹 friday cleanup party: substitute deprecated import of go-kit (#19774) 2024-06-17 10:27:31 -03:00
cron_stats.go Monitor and alert on errors in cron jobs (#24347) 2024-12-19 15:55:29 -06:00
cron_stats_test.go Monitor and alert on errors in cron jobs (#24347) 2024-12-19 15:55:29 -06:00
delete.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
delete_test.go Updated factory method for creating queries in tests 2023-07-07 09:05:51 -04:00
email_changes.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
email_changes_test.go
errors.go Add gosimple linter (#23250) 2024-10-29 14:17:51 -05:00
fulltext.go
fulltext_test.go
hosts.go Don't expire iOS devices prematurely (#25436) 2025-01-16 10:13:22 -05:00
hosts_test.go Don't expire iOS devices prematurely (#25436) 2025-01-16 10:13:22 -05:00
invites.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
invites_test.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
jobs.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
jobs_test.go Send DeviceConfigured MDM command after DEP enrollment (#17737) 2024-03-25 13:25:29 -04:00
labels.go SSVL: prevent deletion of a label if used to scope software installers (#24644) 2024-12-11 14:21:10 -05:00
labels_test.go SSVL: Add labels to upload endpoint; add validations and related datastore methods (#24733) 2024-12-16 18:17:13 -06:00
linux_mdm.go Linux OS settings + disk encryption host filter fixes (#24200) 2024-11-26 19:26:22 -06:00
linux_mdm_test.go Add Linux encryption states to APIs (#23806) 2024-11-19 13:11:59 -07:00
locks.go Merge conflicts 2024-04-16 10:20:59 -05:00
locks_test.go Improvements for select next Apple MDM command query. (#24128) 2024-12-05 12:02:48 -06:00
maintained_apps.go Allow pulling the base list of Fleet Maintained Apps without requiring a team ID (#24595) 2024-12-11 21:12:38 -06:00
maintained_apps_test.go SSVL: Add labels to upload endpoint; add validations and related datastore methods (#24733) 2024-12-16 18:17:13 -06:00
mdm.go Fixed issue with incorrect batch DDM update activity. (#25372) 2025-01-14 11:24:36 -06:00
mdm_test.go Update nanomdm dependency with latest bug fixes and improvements. (#23906) 2024-11-20 11:47:11 -06:00
microsoft_mdm.go Update Apple config/DDM profiles if secret variables changed (#24995) 2024-12-30 17:58:39 -06:00
microsoft_mdm_test.go chore: merge in main 2024-11-06 10:13:47 -05:00
migrations_test.go Use docker compose on CI instead of docker-compose (#21017) 2024-08-02 18:12:36 -03:00
mysql.go Fixed potential deadlocks when deploying Apple configuration profiles. (#24777) 2024-12-16 11:16:42 -06:00
mysql_test.go Minor fixes from analyzing test results (#23260) 2024-10-25 15:57:51 -05:00
nanomdm_storage.go Replace script/profile secrets. (#24841) 2024-12-18 15:27:35 -06:00
nanomdm_storage_test.go 19016 ingest certs on start (#19360) 2024-05-30 18:18:42 -03:00
operating_system_vulnerabilities.go Add gosimple linter (#23250) 2024-10-29 14:17:51 -05:00
operating_system_vulnerabilities_test.go Profiles batch activity (#21604) 2024-08-30 16:00:35 -05:00
operating_systems.go Fixed potential deadlocks when deploying Apple configuration profiles. (#24777) 2024-12-16 11:16:42 -06:00
operating_systems_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs_test.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
password_reset.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
password_reset_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
policies.go Add VPP install automation in GitOps (#25400) 2025-01-14 12:52:39 -06:00
policies_test.go Add VPP install automation in GitOps (#25400) 2025-01-14 12:52:39 -06:00
queries.go Automatic install custom packages (#25021) 2024-12-27 15:10:28 -03:00
queries_test.go 21855 – Paginate and filter Queries on the server, update platform filtering from compatible to targeted platforms (#24446) 2024-12-11 10:50:28 -08:00
query_results.go Added server_settings.query_report_cap (#19692) 2024-06-14 12:24:01 -03:00
query_results_test.go Added server_settings.query_report_cap (#19692) 2024-06-14 12:24:01 -03:00
scep.go 19016 ingest certs on start (#19360) 2024-05-30 18:18:42 -03:00
scep_test.go use Fleet instead of FleetDM in certificates (#19748) 2024-06-14 11:08:49 -03:00
scheduled_queries.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
scheduled_queries_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
schema.sql Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
scripts.go Fix detection of uninstall scripts when recording script results after a host has had MDM actions taken (#25157) 2025-01-06 07:57:17 -06:00
scripts_test.go Allow software uninstalls, script-based lock/unlock/wipe, while scripts are globally disabled (#24815) 2024-12-30 08:32:48 -06:00
secret_variables.go Update Apple config/DDM profiles if secret variables changed (#24995) 2024-12-30 17:58:39 -06:00
secret_variables_test.go Update Apple config/DDM profiles if secret variables changed (#24995) 2024-12-30 17:58:39 -06:00
sessions.go Include expiration info, drop "personalized", in MFA email (#24630) 2024-12-10 18:58:40 -06:00
sessions_test.go Include expiration info, drop "personalized", in MFA email (#24630) 2024-12-10 18:58:40 -06:00
setup_experience.go feat: do not run setup experience on hosts in a team with no software or script configured (#24073) 2024-11-22 13:52:28 -05:00
setup_experience_test.go SSVL: Add labels to upload endpoint; add validations and related datastore methods (#24733) 2024-12-16 18:17:13 -06:00
software.go fix: better filtering to handle de-scoping after uninstall edge case (#24963) 2024-12-20 16:56:51 -05:00
software_installers.go fix: retrigger automatic installations after label scope changes (#25163) 2025-01-06 12:18:16 -05:00
software_installers_test.go Automatic install custom packages (#25021) 2024-12-27 15:10:28 -03:00
software_test.go fix: retrigger automatic installations after label scope changes (#25163) 2025-01-06 12:18:16 -05:00
software_titles.go Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
software_titles_test.go Add VPP policy automation support to backend (#25154) 2025-01-13 15:53:24 -06:00
statistics.go Added statistics for number of saved queries. (#24043) 2024-11-22 11:24:29 -05:00
statistics_test.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
targets.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
targets_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
teams.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
teams_test.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
testing_utils.go SSVL: Add labels to upload endpoint; add validations and related datastore methods (#24733) 2024-12-16 18:17:13 -06:00
unicode_test.go Bugfix: only count hosts that user has permission to see in count field of label endpoints (#18859) 2024-05-21 12:02:08 -04:00
users.go API, datastore, migration for new "user settings", with `"hidden_hosts_table_columns" setting (#25184) 2025-01-09 10:04:47 -08:00
users_test.go API, datastore, migration for new "user settings", with `"hidden_hosts_table_columns" setting (#25184) 2025-01-09 10:04:47 -08:00
vpp.go Add VPP install automation in GitOps (#25400) 2025-01-14 12:52:39 -06:00
vpp_test.go Add VPP install automation in GitOps (#25400) 2025-01-14 12:52:39 -06:00
vulnerabilities.go Optimize vulnerability host counts (#24914) 2025-01-13 15:44:02 -07:00
vulnerabilities_test.go Optimize vulnerability host counts (#24914) 2025-01-13 15:44:02 -07:00
windows_updates.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
windows_updates_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
wstep.go Add certificate management for Microsoft MDM (WSTEP) (#12543) 2023-06-29 19:31:53 -03:00
wstep_test.go Move nanomdm dependency in monorepo (#16015) 2024-01-11 23:28:48 -03:00