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 1595960

Summary: Generate applicability tasks fails with - undefined method `each' for true:TrueClass (NoMethodError)
Product: Red Hat Satellite Reporter: sthirugn <sthirugn>
Component: Content ManagementAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Lai <ltran>
Severity: high Docs Contact:
Priority: high    
Version: 6.3.1CC: akarimi, andrew.schofield, ben.argyle, cduryee, dchaudha, janarula, jjansky, kabbott, pmoravec, robert.sprockeels, smane, tbrisker, vdeshpan
Target Milestone: UnspecifiedKeywords: PrioBumpField, PrioBumpGSS, PrioBumpQA, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-09-12 09:30:34 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 sthirugn@redhat.com 2018-06-27 22:21:45 UTC
Description of problem:
Generate applicability tasks fails with - undefined method `each' for true:TrueClass (NoMethodError)

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

How reproducible:
random

Steps to Reproduce:
this happens randomly and fails the generate applicability tasks:

2018-06-20 10:47:21 ddf82eee [app] [I] Completed 200 OK in 35ms (Views: 0.2ms | ActiveRecord: 0.8ms)
2018-06-20 10:47:22  [katello/pulp_rest] [I] RestClient.post "https://satellite.exmaple.com/pulp/api/v2/consumers/4d74976f-9abd-4063-8ad8-704f204153e2/actions/content/regenerate_applicability/", "{}", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"2", "accept"=>"application/json", "content_type"=>"application/json"
 | \n# => 404 NotFound | application/json 579 bytes
 | 
2018-06-20 10:47:22  [app] [W] Pulp consumer b401f474-d0ae-4116-91e4-070aff659139 not found.
2018-06-20 10:47:22  [foreman-tasks/action] [E] undefined method `each' for true:TrueClass (NoMethodError)
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64.2/app/lib/actions/pulp/abstract_async_task.rb:108:in `external_task='
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/action/polling.rb:83:in `initiate_external_action'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/action/polling.rb:18:in `run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/action/cancellable.rb:13:in `run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64.2/app/lib/actions/pulp/abstract_async_task.rb:45:in `run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/action.rb:518:in `block (3 levels) in execute_run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware/stack.rb:26:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware.rb:18:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware.rb:31:in `run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware/stack.rb:22:in `call'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware/stack.rb:26:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.34/lib/dynflow/middleware.rb:18:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64.2/app/lib/actions/middleware/remote_action.rb:16:in `block in run'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64.2/app/lib/actions/middleware/remote_action.rb:40:in `block in as_remote_user'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.64.2/app/models/katello/concerns/user_extensions.rb:21:in `cp_config'

Actual results:
as shown above

Expected results:
No error

Additional info:

Comment 1 sthirugn@redhat.com 2018-06-27 22:33:24 UTC
chatting with beav in irc, the following could have happened:
- 1. The content host registered successfully
- 2. fired generate applicability task
- 3. Content host is unregistered before Step 2 above is processed

Comment 4 sthirugn@redhat.com 2018-07-02 19:52:44 UTC
I was able to reproduce the issue by the following:
1. Register a content host
2. do several yum install/removals - I created a script like so:
#cat testinstall.sh
for i in `seq 1 6`; do
  echo "Installing vim"
  yum install -y vim
  echo "Removing vim"
  yum remove -y vim
done
3. Let the script run for 1 or 2 iterations and make sure that the generate applicability tasks run fine.
4. Stop foreman-tasks and let the script run to completion.
# systemctl stop foreman-tasks
5. Unregister the content host.
6. Start foreman-tasks and let the script run to completion.
# Start foreman tasks and wait until the pending tasks are executed.
systemctl stop foreman-tasks
6. Notice that all the pending regenerate applicability tasks go to Stopped/Warning state with the message in foreman tasks:
undefined method `each' for true:TrueClass

the log should be similar to what is posted in this bug's description.

Note:
The only difference is I see is the status of the foreman tasks:

In my test it went to Stopped/Warning status. In a customer environment, it went to Paused/Error status.  It may very well because of the way I which stop/start foreman-tasks explicitly. Since the trace is matching, fixing this should alleviate the customer issue for sure.

Comment 5 sthirugn@redhat.com 2018-07-02 20:01:37 UTC
Apologies, in the above step, the tasks ended with warning are all - Package Profile update tasks and not Generate applicability tasks - but the stacktrace looks similar.

Comment 6 sthirugn@redhat.com 2018-07-02 20:09:03 UTC
Now I am able to reproduce the Generate Applicability error exactly as noted in the customer environment:

1. Stop foreman-tasks
2. Register the client
3. Notice the client is registered. The General applicability task and the Package Profile Update tasks are in planned status.
4. Unregister the client
5. Start foreman-tasks
6. Notice the following:
Generate applicability task goes to Paused/Error
Package Profile Update goes to Stopped/Warning


This simulates the customer environment in which there is a lot of load on foreman-tasks and due to some reason - the client gets provisioned, registered to Satellite and immediately unregistered - probably because of a configuration issue.

Comment 8 Justin Sherrill 2018-07-06 13:43:46 UTC
*** Bug 1598736 has been marked as a duplicate of this bug. ***

Comment 9 sthirugn@redhat.com 2018-08-23 18:49:09 UTC
*** Bug 1589791 has been marked as a duplicate of this bug. ***

Comment 12 Pavel Moravec 2019-02-06 19:13:29 UTC
Reproducer steps:

- have an activation key with a RHEL subscription (any sub works fine, AK itself is just increasing probability of the reproducer)

- in 1st terminal on a Content Host:

while true; do
  for act in enable disable; do
    subscription-manager repos --${act}=rhel-7-server-rpms
  done
  date
  sleep 0.1
done

- 2nd terminal on the C.H.:

while true; do
  subscription-manager register --activationkey=ak_test --force --org=RedHat
  date
  sleep 1
done

- wait a minute or two, and check paused,error tasks with label Actions::Katello::Host::GenerateApplicability


(hint for engineering: why _this_ task gets paused, while profile upload does not? what makes the profile upload task better?)

Comment 13 Pavel Moravec 2019-02-06 21:05:22 UTC
I can't reproduce this on 6.4.1. So I would suggest closing the BZ as resolved in 6.4.

Comment 17 Tomer Brisker 2019-09-12 09:30:34 UTC
This issue has been resolved in Satellite 6.4 and is no longer reproducible. 
Closing as CURRENTRELEASE. Please reopen if the issue still occurs in Satellite 6.4 or newer.