[Fleet] Update query in delete unenrolled agents task (#224808)

## Summary

Issue reported by users that some unenrolled agents on the UI are not
being deleted by the background task.
The cause turned out to be a discrepancy in how unenrolled agents are
determined on the UI versus the background task.

The UI shows agents as unenrolled if `active:false` field matches (logic
[here](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/fleet/server/services/agents/build_status_runtime_field.ts#L115-L119))

The delete unenrolled agents task also queried on the existence of
`unenrolled_at` field.
It seems some agents don't have this field set, those should be deleted
too.
This commit is contained in:
Julia Bardi 2025-06-24 08:43:39 +02:00 committed by GitHub
parent 0176ea941b
commit c989634a81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,7 +116,6 @@ export class DeleteUnenrolledAgentsTask {
active: false,
},
},
{ exists: { field: 'unenrolled_at' } },
],
},
},