Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/datastore/mysql/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,11 @@ func upsertHostDEPAssignmentsDB(ctx context.Context, tx sqlx.ExtContext, hosts [
added_at = CURRENT_TIMESTAMP,
deleted_at = NULL,
abm_token_id = VALUES(abm_token_id),
mdm_migration_completed = IF(
mdm_migration_completed IS NOT NULL AND mdm_migration_completed >= mdm_migration_deadline,
VALUES(mdm_migration_deadline),
mdm_migration_completed
),
mdm_migration_deadline = VALUES(mdm_migration_deadline),
hardware_serial = VALUES(hardware_serial)`

Expand Down
10 changes: 10 additions & 0 deletions server/datastore/mysql/apple_mdm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5678,6 +5678,16 @@
require.Equal(t, depHostID, hdepa.HostID)
require.Nil(t, hdepa.DeletedAt)
require.Equal(t, depAssignment.AddedAt, hdepa.AddedAt)

// Regression: re-syncing with a new migration deadline after migration was
// completed should preserve the completed state (not re-open the migration).
newDeadline := migrationDeadline.Add(48 * time.Hour).Truncate(time.Millisecond)
n, err = ds.IngestMDMAppleDevicesFromDEPSync(ctx, []godep.Device{{SerialNumber: depSerial, MDMMigrationDeadline: &newDeadline}}, abmToken.ID, nil, nil, nil)

Check failure on line 5685 in server/datastore/mysql/apple_mdm_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-4core)

ineffectual assignment to n (ineffassign)
require.NoError(t, err)

checkinInfo, err = ds.GetHostMDMCheckinInfo(ctx, depUUID)
require.NoError(t, err)
require.False(t, checkinInfo.MigrationInProgress, "re-sync with new deadline should not re-open a completed migration")
})

t.Run("manual enrollment", func(t *testing.T) {
Expand Down
Loading