Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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:
Hi Shimon,
when I was playing with the bug, I recall that I prevented new instances of malformed hosts statuses (with empty type) by this fix:
diff a/lib/inventory_sync/async/inventory_full_sync.rb b/lib/inventory_sync/async/inventory_full_sync.rb
--- a/lib/inventory_sync/async/inventory_full_sync.rb
+++ b/lib/inventory_sync/async/inventory_full_sync.rb
def add_missing_hosts_statuses(hosts_ids)
InventorySync::InventoryStatus.create(
hosts_ids.map do |host_id|
{
host_id: host_id,
status: InventorySync::InventoryStatus::DISCONNECT,
reported_at: DateTime.current,
+ type: InventorySync::InventoryStatus.name,
}
end
)
end
Does it make sense to have that as PR / potential fix?
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team. Thank you.
The empty host_status type does not necessarily mean the type must be InventorySync::InventoryStatus . I mean, it is quite possible there were bugs in 6.10 or 6.11 where InventoryStatus type was not set, but now I was testing 6.14 and a few potential ways of getting to the https://bugzilla.redhat.com/show_bug.cgi?id=2051945#c10 - and even *without* explicitly setting the type, the status type is properly populated. Also a few other attempts to make the InventoryStatus string purged away failed.
So I suppose that:
- there are some bugs in 6.10 and 6.11 wrt InventoryStatus that are fixed since 6.12-ish time
- there might be some other bug that, say, after manifest refresh (and something) in non-SCA mode, Katello::SubscriptionStatus string is replaced by empty type -and that bug remains in 6.12+ versions. But we dont have a reproducer at all
Since 6.11 and older is unsupported, I recommend to:
- upgrade to any supported Satellite version first
- if problem persists after the upgrade, then collect:
1) sosreport
2) output of psql command
echo "SELECT h.id,h.name, hs.* FROM hosts as h, host_status as hs WHERE hs.host_id = h.id AND hs.type IS null ORDER BY h.id " | su - postgres -c "psql foreman"
3) from that data, locate newest reported_at timestamp, and provide all logs since that time (i.e. "tar cvzf bz2051945_logs.tar.gz $(find /var/log -newermt 2024-02-11)" for reported_at = 2024-02-11).
I will further check the last support case from Sat6.13, if I get similar data from it.
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.
Comment 17Red Hat Bugzilla
2024-08-29 04:25:15 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days