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 1403149

Summary: Capsule sync on sat6.1.11 failed w/ error "undefined method `each' for nil:NilClass"
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: Foreman ProxyAssignee: Justin Sherrill <jsherril>
Status: CLOSED WONTFIX QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.10CC: bbuckingham, bkearney, jsherril
Target Milestone: UnspecifiedKeywords: 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: 2017-05-19 12:45:13 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 Sachin Ghai 2016-12-09 08:56:58 UTC
Description of problem:
We were building internal instances for upgrade testing and Installed Sat6.0 along with external capsule on rhel6. Later, we upgraded the satellite as well as capsule with Sat6.1.11 and both capsule/satellite upgraded successfully. However, when we tried to sync the satellite with capsule, got following error:

~]# hammer -u admin -p changeme capsule content synchronize --id=2
[............................................................................................................................................] [100%]
undefined method `each' for nil:NilClass

production.log:
===================
2016-12-05 12:16:08 [I] Processing by ForemanTasks::Api::TasksController#show as application/json;version=2
2016-12-05 12:16:08 [I]   Parameters: {"id"=>"f6388afe-21fb-4a6f-b377-886f94411e9c", "task"=>{}}
2016-12-05 12:16:08 [W] Polling failed, attempt no. 1, retrying in 2
2016-12-05 12:16:08 [W] undefined method `each' for nil:NilClass (NoMethodError)
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.93/app/lib/actions/pulp/consumer/sync_node.rb:66:in `changed_repos'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.93/app/lib/actions/pulp/consumer/sync_node.rb:51:in `external_task='
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/action/polling.rb:98:in `poll_external_task_with_rescue'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/action/polling.rb:21:in `run'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/action/cancellable.rb:9:in `run'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.93/app/lib/actions/pulp/abstract_async_task.rb:57:in `run'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/action.rb:487:in `block (3 levels) in execute_run'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware/stack.rb:26:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware.rb:16:in `pass'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware.rb:25:in `run'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.9/lib/dynflow/middleware/stack.rb:26:in `pass'




Version-Release number of selected component (if applicable):
upgraded sat6.1.11

How reproducible:


Steps to Reproduce:
1. install sat6.0/capsule6.0
2. upgrade the satellite to 6.1.11
3.

Actual results:
capsule sync failed with error:
 [W] undefined method `each' for nil:NilClass (NoMethodError

Expected results:
sync should work

Additional info:

suggested fix by dev Justin Sherrill:
--

--- /tmp/sync_node.rb   2016-06-10 12:25:38.975904474 -0400
+++ app/lib/actions/pulp/consumer/sync_node.rb  2016-06-10 12:26:54.999712679 -0400
@@ -63,7 +63,7 @@
           end

           if pulp_task && pulp_task['state'] == 'finished' && pulp_task['result']
-            pulp_task['result']['details']['repository']['details']['repositories'].each do |repo|
+           (pulp_task['result'].try(:[], 'details').try(:[], 'repository').try(:[], 'details').try(:[], :repositories) || []).each do |repo|
               changes[repo['repo_id']] = (repo['units']['added'] > 0 || repo['units']['removed'] > 0 || repo['units']['updated'] > 0)
             end
           end

Comment 2 Justin Sherrill 2016-12-09 15:23:19 UTC
Patch to fix issue:  https://gist.github.com/jlsherrill/9c7eb016314e63b926fa6a124ce56085


I *Think* this error only occurs if some error is already occurring.  In this case Sachin's Satellite and capsule times were not in sync.

Comment 3 Bryan Kearney 2017-05-19 12:45:13 UTC
We will not be addressing this bug in the 6.1 code base. If you have concerns with this, please feel free to reach out to me with any concerns or issues you may have. Thank you.