Project

General

Profile

Actions

Bug #37215

closed

Getting "undefined method '#id' for NilClass::Jail (NilClass)" error when generating Ansible inventory report

Added by Hao Yu about 2 months ago. Updated 24 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Reporting
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Clone from bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=2266794

Description of problem:
Getting the following error when generating the Ansible inventory report.

Safemode::NoMethodError
undefined method '#id' for NilClass::Jail (NilClass)
---
- "/usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:22:in `method_missing'" 
- Ansible - Ansible Inventory:89:in `block in initialize'
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in
  `block (2 levels) in each_record'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in
  `each'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in
  `block in each_record'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:245:in
  `block in in_batches'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in
  `loop'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in
  `in_batches'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in
  `each'" 
- "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in
  `each_record'" 
- "/usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:31:in `method_missing'" 
- Ansible - Ansible Inventory:83:in `initialize'
- "/usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'" 
- "/usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'" 
- "/usr/share/foreman/app/services/foreman/renderer/safe_mode_renderer.rb:7:in `render'" 
- "/usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'" 
- "/usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'" 
- "/usr/share/foreman/app/models/template.rb:172:in `render'" 
- "/usr/share/foreman/app/models/report_composer.rb:241:in `render'" 
- "/usr/share/foreman/app/jobs/template_render_job.rb:12:in `block in perform'" 
- "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'" 
- "/usr/share/foreman/app/jobs/template_render_job.rb:9:in `perform'" 
- "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/execution.rb:48:in `block
  in perform_now'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:117:in
  `block in run_callbacks'" 
- "/usr/share/gems/gems/i18n-1.13.0/lib/i18n.rb:322:in `with_locale'" 
- "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/translation.rb:9:in `block
  (2 levels) in <module:Translation>'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in
  `instance_exec'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in
  `block in run_callbacks'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/core_ext/time/zones.rb:66:in
  `use_zone'" 
- "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/timezones.rb:9:in `block
  (2 levels) in <module:Timezones>'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in
  `instance_exec'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in
  `block in run_callbacks'" 
- "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/instrumentation.rb:21:in
  `block in instrument'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications.rb:203:in
  `block in instrument'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications/instrumenter.rb:24:in
  `instrument'" 
- "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications.rb:203:in
  `instrument'" 
- "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/instrumentation.rb:31:in
  `instrument'" 

How reproducible:
Easy

Steps to Reproduce:
1. Has some hosts not associated to any content view or LCE. The satellite host entry itself should be sufficient to reproduce.
2. Navigate to Monitor -> Report Templates -> "Ansible - Ansible Inventory" -> Click "Generate" button
3. Set "Yes" for Content Attributes and click Generate button.

Actual results:
Safemode::NoMethodError
undefined method '#id' for NilClass::Jail (NilClass)

Expected results:
Report generates successfully

Additional info:
Similar issue to bug #2256411 but different report template.

Actions #1

Updated by The Foreman Bot about 2 months ago

  • Status changed from New to Ready For Testing
  • Assignee set to Hao Yu
  • Pull request https://github.com/theforeman/foreman/pull/10074 added
Actions #2

Updated by vi won about 2 months ago

Did some testing. We use this as well to sync inventory from Foreman->AWX. It seems to only happen when "Content Attributes" is set to yes. If you disable that option in the report, it seems to generate ok.

Actions #3

Updated by ebarrere please_edit_me about 2 months ago

vi won wrote in #note-2:

Did some testing. We use this as well to sync inventory from Foreman->AWX. It seems to only happen when "Content Attributes" is set to yes. If you disable that option in the report, it seems to generate ok.

Thanks! I'm having the same issue and this workaround will save me.

Actions #4

Updated by The Foreman Bot 24 days ago

  • Fixed in Releases 3.11.0 added
Actions #5

Updated by Hao Yu 24 days ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF