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.

Bug 2058863

Summary: Everytime a host build is being submitted that somehow generates a huge traceback with error "undefined method `insights' for nil:NilClass" in Satellite 7.0
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: RH Cloud - InsightsAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: addubey
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.11.0CC: aruzicka, ehelms
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_rh_cloud-5.0.34 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:34:01 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 Sayan Das 2022-02-26 13:41:00 UTC
Description of problem:

Everytime a host build is being submitted that somehow generates a huge traceback with error "undefined method `insights' for nil:NilClass" in Satellite 7.0

That does not affect the build process but the traceback is neither acceptable nor unrelatable. 


Version-Release number of selected component (if applicable):

satellite-7.0.0-0.5.beta.el8sat.noarch


How reproducible:

Always

Steps to Reproduce:
1. Install and configure a Satellite 7.0 (Snap 10) on top of RHEL 8 and sync contents in it.

2. Configure it for PXE based provisioning and configure certain hostgrooups for quick builds.

3. In global parameters, override the value of host_registration_insights to false as we don't want the insights registration to happen. 

4. Disable "Inventory Auto Upload"

5. Create and Submit a Host build while observing the /var/log/foreman/production.log 


Actual results:

After submitting the host for build, for some reason, satellite tries to access "/insights_cloud/hits/undefined" and gets a traceback. The traceback perhaps happens as the host_id itself is undefined as can be seen below.

# grep "undefined method \`\insights'" /var/log/foreman/production.log -B10 -A10
2022-02-26T18:46:43 [I|app|38a82759]   Rendering layouts/base.html.erb
2022-02-26T18:46:43 [I|app|38a82759]   Rendered /usr/share/gems/gems/foreman_theme_satellite-9.0.0.3/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb (Duration: 3.8ms | Allocations: 6662)
2022-02-26T18:46:43 [I|app|38a82759]   Rendered layouts/base.html.erb (Duration: 36.2ms | Allocations: 39909)
2022-02-26T18:46:43 [I|app|38a82759] Completed 200 OK in 62ms (Views: 46.6ms | ActiveRecord: 3.1ms | Allocations: 46415)
2022-02-26T18:46:44 [I|app|404f5c53] Started GET "/api/hosts/ester-berzins.sat.example.com" for 10.74.XX.YY at 2022-02-26 18:46:44 +0530
2022-02-26T18:46:44 [I|app|0258d878] Started GET "/insights_cloud/hits/undefined" for 10.74.XX.YY at 2022-02-26 18:46:44 +0530
2022-02-26T18:46:44 [I|app|404f5c53] Processing by Api::V2::HostsController#show as JSON
2022-02-26T18:46:44 [I|app|404f5c53]   Parameters: {"apiv"=>"v2", "id"=>"ester-berzins.sat.example.com"}
2022-02-26T18:46:44 [I|app|0258d878] Processing by InsightsCloud::HitsController#show as JSON
2022-02-26T18:46:44 [I|app|0258d878]   Parameters: {"host_id"=>"undefined"}
2022-02-26T18:46:44 [W|app|0258d878] undefined method `insights' for nil:NilClass
2022-02-26T18:46:44 [I|app|0258d878] Backtrace for 'undefined method `insights' for nil:NilClass' error (NoMethodError): undefined method `insights' for nil:NilClass
 0258d878 | /usr/share/gems/gems/foreman_rh_cloud-5.0.31/app/controllers/insights_cloud/hits_controller.rb:19:in `show'
 0258d878 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 0258d878 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/base.rb:195:in `process_action'
 0258d878 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 0258d878 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 0258d878 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 0258d878 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 0258d878 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 0258d878 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 0258d878 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
--
2022-02-26T18:54:23 [I|app|db04f288]   Rendered /usr/share/gems/gems/foreman_theme_satellite-9.0.0.3/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb (Duration: 3.3ms | Allocations: 6645)
2022-02-26T18:54:23 [I|app|db04f288]   Rendered layouts/base.html.erb (Duration: 31.9ms | Allocations: 39875)
2022-02-26T18:54:23 [I|app|db04f288] Completed 200 OK in 51ms (Views: 34.4ms | ActiveRecord: 2.9ms | Allocations: 48632)
2022-02-26T18:54:23 [I|app|bf3e4a51] Started GET "/api/hosts/olive-yamada.sat.example.com" for 10.74.XX.YY at 2022-02-26 18:54:23 +0530
2022-02-26T18:54:23 [I|app|6717a329] Started GET "/insights_cloud/hits/undefined" for 10.74.XX.YY at 2022-02-26 18:54:23 +0530
2022-02-26T18:54:23 [I|app|bf3e4a51] Processing by Api::V2::HostsController#show as JSON
2022-02-26T18:54:23 [I|app|bf3e4a51]   Parameters: {"apiv"=>"v2", "id"=>"olive-yamada.sat.example.com"}
2022-02-26T18:54:23 [I|app|6717a329] Processing by InsightsCloud::HitsController#show as JSON
2022-02-26T18:54:23 [I|app|6717a329]   Parameters: {"host_id"=>"undefined"}
2022-02-26T18:54:23 [I|app|bf3e4a51]   Rendering api/v2/hosts/show.json.rabl
2022-02-26T18:54:23 [W|app|6717a329] undefined method `insights' for nil:NilClass
2022-02-26T18:54:23 [I|app|6717a329] Backtrace for 'undefined method `insights' for nil:NilClass' error (NoMethodError): undefined method `insights' for nil:NilClass
 6717a329 | /usr/share/gems/gems/foreman_rh_cloud-5.0.31/app/controllers/insights_cloud/hits_controller.rb:19:in `show'
 6717a329 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 6717a329 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/base.rb:195:in `process_action'
 6717a329 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 6717a329 | /usr/share/gems/gems/actionpack-6.0.3.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 6717a329 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 6717a329 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 6717a329 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 6717a329 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 6717a329 | /usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'


Expected results:

No such tracebacks related to insights should occur or unnecessarily fill up the logs. 


Additional info:

production.log file will be attached on the BZ as a private attachment.

Comment 7 errata-xmlrpc 2022-07-05 14:34:01 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498