fleet/server/worker
Jordan Montgomery 572536d466
Skip setup experience during AxM based migrations (#32822)
Fixes #32096

The gist of the fix is that when syncing devices from DEP we save the
migration deadline to our host_dep_assignments table. The next
enrollment, which we assume should be the migration, looks at
host_dep_assignments, sees that mdm_migration_deadline is non-Null and
mdm_migration_completed is NULL, and uses that as the signal that a
migration is in progress and skips enqueuing setup experience items. It
then marks the migration as complete which sets mdm_migration_completed
= mdm_migration_deadline. Once this is set setup experience will run as
normal unless mdm_migration_completed gets set to NULL and/or
mdm_migration_deadline gets set to a value in the future(which e.g.
would happen if the customer assigned to another MDM server then
assigned to migrate to fleet again)

DB test failure is expected here because it won't like the migration
timestamp but that is a necessary failure because this fix is going to
be backported into 4.73

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes

## Testing

- [x] Added/updated automated tests
- [x] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)

- [x] QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

- [x] Confirmed that the fix is not expected to adversely impact load
test results
- [x] Alerted the release DRI if additional load testing is needed

## Database migrations

- [x] Checked table schema to confirm autoupdate
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* New Features
  * Tracks and stores Apple DEP MDM migration deadlines per device/host.
  * Detects “migration in progress” during DEP sync and check-in.
* Automatically marks migration complete and skips Setup Assistant items
while migration is in progress to prevent conflicts.

* Bug Fixes
* Improved DEP compatibility by updating the protocol version and
User-Agent used for Apple’s APIs, reducing the chance of blocked or
rejected requests.

* Migrations
* Adds fields to support migration deadlines and completion status (no
action required).

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Magnus Jensen <magnus@fleetdm.com>
2025-09-11 09:40:40 -04:00
..
apple_mdm.go Wait for expected profiles to be sent before releasing device (#31381) 2025-07-31 17:50:57 +02:00
apple_mdm_test.go Skip setup experience during AxM based migrations (#32822) 2025-09-11 09:40:40 -04:00
automation_failer.go Support failing policies integrations (#5973) 2022-06-06 10:41:51 -04:00
automation_failer_test.go 🧹 friday cleanup party: substitute deprecated import of go-kit (#19774) 2024-06-17 10:27:31 -03:00
batch_activities.go Batch script cron schedule (#31808) 2025-08-14 14:44:47 -04:00
batch_activities_test.go Batch script cron schedule (#31808) 2025-08-14 14:44:47 -04:00
db_migrations.go MABM bugfix: fix the expected format of the migrated VPP token (#21761) 2024-09-03 13:23:44 -04:00
db_migrations_test.go MABM bugfix: fix the expected format of the migrated VPP token (#21761) 2024-09-03 13:23:44 -04:00
jira.go Add "No Team" integration configurations for Jira and Zendesk (#32387) 2025-09-02 18:02:34 -05:00
jira_test.go Add "No Team" integration configurations for Jira and Zendesk (#32387) 2025-09-02 18:02:34 -05:00
macos_setup_assistant.go Remove pending MDM device from Fleet (#23067) 2024-10-24 16:42:30 -05:00
macos_setup_assistant_test.go Skip setup experience during AxM based migrations (#32822) 2025-09-11 09:40:40 -04:00
vpp_verification.go fix issues in setup experience due to VPP verification (#30679) 2025-07-11 14:57:15 -04:00
worker.go Allow worker to filter queue by job type (#31556) 2025-08-06 17:22:48 -05:00
worker_test.go Allow worker to filter queue by job type (#31556) 2025-08-06 17:22:48 -05:00
zendesk.go Add "No Team" integration configurations for Jira and Zendesk (#32387) 2025-09-02 18:02:34 -05:00
zendesk_test.go Add "No Team" integration configurations for Jira and Zendesk (#32387) 2025-09-02 18:02:34 -05:00