Project

General

Profile

Actions

Bug #35885

closed

Bug 2155392 - Host config report page raises "undefined method `[]' for nil:NilClass" error

Added by Hao Yu almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:

Description

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

Description of problem:
Host config report page raises "undefined method `[]' for nil:NilClass" error if an ansible task reported multiple results per module action. For example, copy multiple files using loop.

-----------------------
[I|app|ae69c14e] Processing by ConfigReportsController#show as HTML
[I|app|ae69c14e] Parameters: {"id"=>"18694"}
[I|app|ae69c14e] Rendering config_reports/show.html.erb within layouts/application
[I|app|ae69c14e] Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb (Duration: 12.4ms | Allocations: 7413)
[I|app|ae69c14e] Rendered config_reports/show.html.erb within layouts/application (Duration: 34.6ms | Allocations: 15873)
[W|app|ae69c14e] undefined method `[]' for nil:NilClass
[I|app|ae69c14e] Backtrace for 'undefined method `[]' for nil:NilClass' error (ActionView::Template::Error): undefined method `[]' for nil:NilClass
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/helpers/foreman_ansible/ansible_reports_helper.rb:47:in `ansible_module_message'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:24:in `block in _8af412795d3bd4ecb65c84004fd343a7'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:18:in `_8af412795d3bd4ecb65c84004fd343a7'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:274:in `_run'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:185:in `block in render'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:182:in `instrument'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:385:in `instrument_render_template'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:183:in `render'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
-----------------------

How reproducible:
Easy

Steps to Reproduce:
1. Create a custom role which copy multiple files

mkdir /etc/ansible/roles/copy_ssh_keys/
mkdir /etc/ansible/roles/copy_ssh_keys/tasks

  1. Create this file
    main.yml
    ---
    - name: Copy ssh keys
    copy:
    src: "/var/lib/foreman-proxy/ssh/{{ item }}"
    dest: "/root/.ssh"
    owner: root
    group: root
    mode: 0400
    with_items:
    - id_rsa_foreman_proxy
    - id_rsa_foreman_proxy.pub

2. Import the 'copy_ssh_keys' role to the Satellite and add it to a host
3. Trigger host ansible role job and wait until the job is finished successfully
4. Inspect the config report of this host job in Web UI -> Config Reports -> hostname

Actual results:
undefined method `[]' for nil:NilClass

Expected results:
Can show report without error.

Actions #1

Updated by The Foreman Bot almost 2 years ago

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

Updated by The Foreman Bot almost 2 years ago

  • Fixed in Releases foreman_ansible-11.0.0 added
Actions #3

Updated by Hao Yu almost 2 years ago

  • Status changed from Ready For Testing to Closed
Actions #4

Updated by The Foreman Bot almost 2 years ago

  • Pull request https://github.com/theforeman/foreman_ansible/pull/588 added
Actions #5

Updated by The Foreman Bot almost 2 years ago

  • Fixed in Releases foreman_ansible-10.0.0 added
Actions #6

Updated by Nofar Alfassi almost 2 years ago

  • Fixed in Releases foreman_ansible-10.3.0, foreman_ansible-11.1.0 added
  • Fixed in Releases deleted (foreman_ansible-10.0.0, foreman_ansible-11.0.0)
Actions

Also available in: Atom PDF