Bug 1864058

Summary: ActiveRecord::InvalidForeignKey error when performing "Unregister Host" action through satellite 6 webUI
Product: Red Hat Satellite Reporter: Ganesh Payelkar <gpayelka>
Component: RH Cloud - InsightsAssignee: Shimon Shtein <sshtein>
Status: CLOSED DUPLICATE QA Contact: Mirek Długosz <mzalewsk>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.8.0CC: aruzicka, jturel
Target Milestone: 6.8.0Keywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-08-12 13:00:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ganesh Payelkar 2020-08-03 17:56:19 UTC
Description of problem:

ActiveRecord::InvalidForeignKey error when performing "Unregister Host" action through satellite 6 webUI

Version-Release number of selected component (if applicable):
satellite-6.8.0-0.7.beta.el7sat.noarch

How reproducible:
New installation of 6.8 Beta

Steps to Reproduce:
1. register host to satellite6
2. Try to delete a client through webUI


Actual results:  

2020-08-03T21:48:32 [I|aud|] LookupValue (31) destroy event on match fqdn=client.example.com
2020-08-03T21:48:32 [I|aud|] LookupValue (31) destroy event on value satellite.example.com
2020-08-03T21:48:32 [I|aud|] LookupValue (31) destroy event on lookup_key_id 64
2020-08-03T21:48:32 [I|aud|] LookupValue (31) destroy event on omit false
2020-08-03T21:48:32 [I|app|1a63f1b7]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-2.0.2/app/views/foreman_tasks/api/tasks/details.json.rabl (Duration: 94.1ms | Allocations: 16485)
2020-08-03T21:48:32 [I|app|1a63f1b7] Completed 200 OK in 142ms (Views: 81.7ms | ActiveRecord: 45.5ms | Allocations: 19356)
2020-08-03T21:48:32 [I|aud|] LookupValue (32) destroy event on match fqdn=client.example.com
2020-08-03T21:48:32 [I|aud|] LookupValue (32) destroy event on value 9090
2020-08-03T21:48:32 [I|aud|] LookupValue (32) destroy event on lookup_key_id 65
2020-08-03T21:48:32 [I|aud|] LookupValue (32) destroy event on omit false
2020-08-03T21:48:32 [E|bac|] PG::ForeignKeyViolation: ERROR:  update or delete on table "hosts" violates foreign key constraint "fk_rails_864b02d191" on table "insights_hits"
DETAIL:  Key (id)=(25) is still referenced from table "insights_hits".
 (ActiveRecord::InvalidForeignKey)
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `async_exec_params'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `block in exec_no_cache'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'


Expected results:


Additional info: 

foreman=# select * from katello_subscription_facets where host_id=(select id from hosts where name='client.example.com');
 id | host_id | uuid | last_checkin | service_level | release_version | autoheal | registered_at | registered_through | user_id | hypervisor | hypervi
sor_host_id | purpose_usage | purpose_role | dmi_uuid 
----+---------+------+--------------+---------------+-----------------+----------+---------------+--------------------+---------+------------+--------
------------+---------------+--------------+----------
(0 rows)

foreman=# select * from insights_hits where host_id=(select id from hosts where name='client.example.com');
 id | host_id |         last_seen          |                                                                                         title            
                                                                              |              solution_url              | total_risk | likelihood |    
publish_date     |                                                                            results_url                                             
                               
----+---------+----------------------------+----------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------+----------------------------------------+------------+------------+----
-----------------+------------------------------------------------------------------------------------------------------------------------------------
-------------------------------
  7 |      25 | 2020-07-25 13:27:23.055728 | Kdump crashkernel reservation failed due to improper configuration of crashkernel parameter              
                                                                              | https://access.redhat.com/node/59432   |          2 |          4 | 201
6-10-31 04:08:33 | https://cloud.redhat.com/insights/advisor/recommendations/crashkernel_reservation_failed%7CCRASHKERNEL_RESERVATION_FAILED/b0f8c817-
32e2-44b4-b400-efa4151ae115/
  8 |      25 | 2020-07-25 13:27:23.055728 | Decreased security: Yum GPG verification disabled (third-party repos)                                    
                                                                              |                                        |          1 |          1 | 201
7-11-02 12:00:00 | https://cloud.redhat.com/insights/advisor/recommendations/hardening_yum%7CHARDENING_YUM_GPG_3RD_6/b0f8c817-32e2-44b4-b400-efa4151ae
115/
  9 |      25 | 2020-07-25 13:27:23.055728 | System boot will fail when nr_hugepages is set over system memory                                        
                                                                              | https://access.redhat.com/node/5176581 |          3 |          3 | 202
0-07-25 06:06:00 | https://cloud.redhat.com/insights/advisor/recommendations/kernel_nr_hugepages_boot_fail%7CKERNEL_NR_HUGEPAGES_BOOT_FAIL/b0f8c817-32
e2-44b4-b400-efa4151ae115/
 10 |      25 | 2020-07-25 13:27:23.055728 | Kernel panic occurs when a network interface with an IPv6 local route is unregistered                    
                                                                              | https://access.redhat.com/node/3177471 |          3 |          3 | 201
9-06-02 19:01:00 | https://cloud.redhat.com/insights/advisor/recommendations/network_device_unregister_issue%7CNETWORK_DEVICE_UNREGISTER_ISSUE/b0f8c81
7-32e2-44b4-b400-efa4151ae115/
 11 |      25 | 2020-07-25 13:27:23.055728 | Kernel panic occurs when ip6_route_dev_notify function receives an empty pointer from snmp6_alloc_dev whi
le unregistering IPv6 enabled network device due to a known bug in the kernel | https://access.redhat.com/node/4209461 |          2 |          2 | 201
9-10-19 20:54:00 | https://cloud.redhat.com/insights/advisor/recommendations/network_ipv6_dev_route_crash%7CNETWORK_IPV6_DEV_ROUTE_CRASH/b0f8c817-32e2
-44b4-b400-efa4151ae115/
(5 rows)

Comment 1 Brad Buckingham 2020-08-06 14:47:59 UTC
Is this a regression from 6.7?

Comment 2 Ganesh Payelkar 2020-08-06 15:01:42 UTC
Brad,  

I have no idea about 6.7

Comment 6 Adam Ruzicka 2020-08-12 13:00:32 UTC
I believe this is a dupe of BZ #1860422, feel free to reopen if you think this one is different in any way.

*** This bug has been marked as a duplicate of bug 1860422 ***