mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Do not set last_enrolled_at when re-enrolling orbit (#20620)
Server fix for #20397. (I incorrectly added that `last_enrolled_at = NOW()` on the first iOS/iPadOS support PR.) - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Added/updated tests. - [ ] Manual QA for all new/changed functionality.
This commit is contained in:
parent
2282c495c2
commit
1a512b2792
3 changed files with 4 additions and 2 deletions
|
|
@ -0,0 +1 @@
|
|||
* Fixed a bug that set `last_enrolled_at` during orbit re-enrollment, which caused osquery enroll failures when `FLEET_OSQUERY_ENROLL_COOLDOWN` is set .
|
||||
|
|
@ -1874,7 +1874,6 @@ func (ds *Datastore) EnrollOrbit(ctx context.Context, isMDMEnabled bool, hostInf
|
|||
uuid = COALESCE(NULLIF(uuid, ''), ?),
|
||||
osquery_host_id = COALESCE(NULLIF(osquery_host_id, ''), ?),
|
||||
hardware_serial = COALESCE(NULLIF(hardware_serial, ''), ?),
|
||||
last_enrolled_at = NOW(),
|
||||
team_id = ?
|
||||
WHERE id = ?`
|
||||
_, err := tx.ExecContext(ctx, sqlUpdate,
|
||||
|
|
|
|||
|
|
@ -8258,7 +8258,9 @@ func testHostsEnrollOrbit(t *testing.T, ds *Datastore) {
|
|||
require.NoError(t, err)
|
||||
h2OrbitFetched, err := ds.Host(ctx, h2Orbit.ID)
|
||||
require.NoError(t, err)
|
||||
require.NotEqual(t, h1OsqueryFetched.LastEnrolledAt, h2OrbitFetched.LastEnrolledAt)
|
||||
// orbit should not update last_enrolled_at if re-enrolling (because last_enrolled_at
|
||||
// is to be set by osquery only).
|
||||
require.Equal(t, h1OsqueryFetched.LastEnrolledAt, h2OrbitFetched.LastEnrolledAt)
|
||||
time.Sleep(1 * time.Second) // to test the update of last_enrolled_at
|
||||
h2Osquery, err := ds.EnrollHost(ctx, false, dupUUID, dupUUID, dupHWSerial, uuid.New().String(), nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue