[Satellite6] foreman-rake foreman_tasks:export_tasks fails with NoMethodError: undefined method `state' for nil:NilClass

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.2

Issue

  • Creating a task-export always fails at the end with error NoMethodError: undefined method 'state' for nil:NilClass

Resolution

This issue in the dynflow component has been fixed in Satellite 6.3 via RHSA-2018:0336.

To successfully export the task list on Satellite 6.2, will be needed to remove the tasks that are in 'planning' state and with the result 'error', with the following commands:

foreman-rake console
ForemanTasks::Task.where(:state => "planning").where(:result => "error").destroy_all
quit()

After successfully removing the problematic tasks, repeat the export command.

For more KB articles/solutions related to Red Hat Satellite 6.x Satellite Tasking System Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Satellite Tasking System Issues

Root Cause

In the dynflow component, there's a bug that prevent showing plans without root_plan_step as tracked in This content is not included.BZ#1501357.
This is the condition of those tasks that are in a 'planning' state but with 'error' as result.

Diagnostic Steps

You can run a command for export_tasks with the --trace option

foreman-rake foreman_tasks:export_tasks task_search=all --trace
** Invoke foreman_tasks:export_tasks (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute foreman_tasks:export_tasks
Gathering 128 tasks.
1/128
2/128
3/128
4/128
5/128
6/128
7/128
8/128
9/128
10/128
11/128
12/128
13/128
14/128
15/128
16/128
17/128
18/128
19/128
20/128
21/128
22/128
23/128
24/128
25/128
26/128
27/128
28/128
29/128
30/128
31/128
32/128
33/128
34/128
35/128
36/128
37/128
38/128
39/128
40/128
41/128
42/128
43/128
44/128
45/128
46/128
47/128
48/128
49/128
50/128
51/128
52/128
53/128
54/128
55/128
56/128
57/128
58/128
59/128
60/128
61/128
62/128
63/128
64/128
65/128
66/128
67/128
68/128
69/128
70/128
71/128
72/128
73/128
74/128
75/128
76/128
77/128
78/128
79/128
80/128
81/128
82/128
83/128
84/128
85/128
86/128
87/128
88/128
89/128
90/128
91/128
92/128
93/128
94/128
95/128
96/128
97/128
98/128
99/128
100/128
101/128
102/128
103/128
104/128
105/128
106/128
107/128
108/128
109/128
110/128
111/128
112/128
113/128
114/128
115/128
116/128
117/128
118/128
119/128
120/128
121/128
122/128
123/128
rake aborted!
NoMethodError: undefined method `state' for nil:NilClass
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:165:in `step_css_class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:4:in `block in singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-5:in `instance_eval'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-5:in `singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-7:in `__tilt_18397580'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:61:in `erb'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:12:in `block (2 levels) in singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:11:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:11:in `block in singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-5:in `instance_eval'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-5:in `singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/plan_step.erb:-7:in `__tilt_18397580'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:61:in `erb'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/show.erb:48:in `block in singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/show.erb:-5:in `instance_eval'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/show.erb:-5:in `singleton class'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/web/views/show.erb:-7:in `__tilt_18397580'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `call'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:170:in `evaluate'
/opt/rh/rh-ror41/root/usr/share/gems/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:61:in `erb'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:46:in `render_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:264:in `block (5 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:264:in `open'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:264:in `block (4 levels) in <top (required)>'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/delegation.rb:132:in `each'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/delegation.rb:132:in `each_with_index'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/delegation.rb:132:in `public_send'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/delegation.rb:132:in `method_missing'
/opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/relation/delegation.rb:99:in `method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:263:in `block (3 levels) in <top (required)>'
/opt/rh/rh-ruby22/root/usr/share/ruby/tmpdir.rb:88:in `mktmpdir'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.7.14.14/lib/foreman_tasks/tasks/export_tasks.rake:256:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/opt/rh/rh-ruby22/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/opt/rh/rh-ruby22/root/usr/bin/rake:33:in `<main>'
Tasks: TOP => foreman_tasks:export_tasks

To check if there are tasks in a 'planning' state and an 'error' result, you can run the following command:

su - postgres -c "psql foreman -c \"select * from foreman_tasks_tasks where state= 'planning' and result = 'error';\""
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.