Bug 1403149 - Capsule sync on sat6.1.11 failed w/ error "undefined method `each' for nil:NilClass"
Summary: Capsule sync on sat6.1.11 failed w/ error "undefined method `each' for nil:Ni...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Capsule
Version: 6.1.10
Hardware: Unspecified
OS: Unspecified
high
high vote
Target Milestone: Unspecified
Assignee: Justin Sherrill
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-09 08:56 UTC by Sachin Ghai
Modified: 2017-05-19 12:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-19 12:45:13 UTC
Target Upstream Version:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.