Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-23647

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

    • Sprint 142, Sprint 143
    • Moderate
    • To Do
    • No

      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.

              rhn-support-hyu Hao Chang Yu
              rhn-support-hyu Hao Chang Yu
              Jeremy Lenz Jeremy Lenz
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: