Closed roperzh closed 1 year ago
Oooh great catch!
@georgekarrv I thought this would be a good bug to start on.
@georgekarrv Just a heads-up that I started work on this one, I might be able to have something ready by EOD but if not I'll make sure to keep you posted on whatever remains to be done!
EDIT: PR is up and ready for review: https://github.com/fleetdm/fleet/pull/11017
Hosts deleted, cleaned, MDM tables refreshed too, Fleet harmonizes.
Fleet version: 4.28.1
🧑💻 Expected behavior
When a host is deleted, all references are removed from other tables (we don't enforce foreign key constraints to the
hosts
table.)💥 Actual behavior
host_mdm_apple_profiles
, and allnano_
tables still keep the host reference.This is probably not a big deal for the nano tables, but I don't think the cron is smart enough to deal with
host_mdm_apple_profiles
.More info
We have an slice of hosts references:
https://github.com/fleetdm/fleet/blob/f5c8daacf01b0765324a7f627aaeffa96c37b699/server/datastore/mysql/hosts.go#L309-L312
But those are
DELETE
d byid
, however all MDM tables reference hosts byhost_uuid
https://github.com/fleetdm/fleet/blob/f5c8daacf01b0765324a7f627aaeffa96c37b699/server/datastore/mysql/hosts.go#L336-L338