Description of problem: user story: switching off some Hosts, an attempt to delete them after some days fails with: PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates fore ign key constraint "host_status_hosts_host_id_fk" on table "host_status" DETAIL: Key (id)=(75170) is still referenced from table "host_status". The root cause is the following: 1) InventoryFullSync does update HostStatus of disconnected hosts to InventoryStatus::DISCONNECT (https://github.com/theforeman/foreman_rh_cloud/blob/master/lib/inventory_sync/async/inventory_full_sync.rb#L57) 2) but this update does not set "type" of the HostStatus (cf. https://github.com/theforeman/foreman_rh_cloud/blob/master/lib/inventory_sync/async/host_result.rb#L24) 3) that means, a host_status record in psql looks like: # su - postgres -c "psql foreman -c \"SELECT * FROM host_status WHERE type IS null\"" id | type | status | host_id | reported_at --------+------+--------+---------+---------------------------- 719546 | | 0 | 111613 | 2022-02-02 00:01:15.146124 .. 4) the empty type then prevents deletion of such host (here of host_id 111613). Version-Release number of selected component (if applicable): Sat 6.10 (any version applicable, though) How reproducible: 100% Steps to Reproduce: (havent reproduced by myself, just guessing the reproducer) 1. register a Host to RH cloud 2. switch off the host for few days 3. Ensure InventoryFullSync was run meantime 4. Try to delete the Host 5. Check in postgres host_status.type where host_status.host_id = <ID> Actual results: 4. is expected to raise the PG::ForeignKeyViolation error 5. the Host's status has empty type. Expected results: 5. the Host's status does not have empty type 4. The Host can be deleted. Additional info:
Please share if there is plan to include a fix for this bug in the next z stream of Satellite 6.10.