Bug 1456446 - Capsule sync failed w/ error: undefined local variable or method `capsule' for #<Class:0x0000000f0b18a0> (NameError)
Summary: Capsule sync failed w/ error: undefined local variable or method `capsule' fo...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Upgrades
Version: 6.2.10
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Justin Sherrill
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-29 12:19 UTC by Sachin Ghai
Modified: 2019-06-13 21:25 UTC (History)
8 users (show)

Fixed In Version: rubygem-katello-3.0.0.137-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-20 17:24:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1553 0 normal SHIPPED_LIVE Satellite 6.2.10 Async Bug Release 2017-06-20 21:19:07 UTC

Description Sachin Ghai 2017-05-29 12:19:28 UTC
Description of problem:
Upgraded satellite server from 6.2.9 -> 6.2.10 snap2 and kept the capsule at last released version 6.2.9

Later I ran capsule sync and it failed w/ error:

-bash-4.2# hammer -u admin -p changeme capsule content synchronize --id=2
Could not synchronize capsule content:
  undefined local variable or method `capsule' for #<Class:0x0000000f0b18a0>



2017-05-29 08:15:02 b95edd90 [app] [I] Processing by Katello::Api::V2::CapsuleContentController#sync as JSON
2017-05-29 08:15:02 b95edd90 [app] [I]   Parameters: {"api_version"=>"v2", "id"=>"2", "capsule_content"=>{}}
2017-05-29 08:15:02 b95edd90 [app] [I] Authorized user admin(Admin User)
2017-05-29 08:15:02 b95edd90 [foreman-tasks/dynflow] [D] ExecutionPlan 65bc30ab-65a0-4cb0-95bb-57d2f2f67960      pending >>  planning
2017-05-29 08:15:02 b95edd90 [foreman-tasks/dynflow] [D]          Step 65bc30ab-65a0-4cb0-95bb-57d2f2f67960: 1   pending >>   running in phase     Plan Actions::Katello::CapsuleContent::Sync
2017-05-29 08:15:02 b95edd90 [foreman-tasks/action] [E] undefined local variable or method `capsule' for #<Class:0x0000000f0b18a0> (NameError)
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activerecord-4.1.5/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/models/katello/glue/pulp/repo.rb:64:in `block in needs_importer_updates'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/models/katello/glue/pulp/repo.rb:63:in `select'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/models/katello/glue/pulp/repo.rb:63:in `needs_importer_updates'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/lib/actions/katello/capsule_content/sync.rb:86:in `repos_needing_updates'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.135/app/lib/actions/katello/capsule_content/sync.rb:24:in `plan'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/action.rb:461:in `block (3 levels) in execute_plan'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/stack.rb:26:in `call'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/stack.rb:26:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware.rb:17:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware.rb:34:in `plan'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/stack.rb:22:in `call'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/stack.rb:26:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware.rb:17:in `pass'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware.rb:34:in `plan'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/stack.rb:22:in `call'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/middleware/world.rb:30:in `execute'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.13.6/lib/dynflow/action.rb:460:in `block (2 levels) in execute_plan'

Version-Release number of selected component (if applicable):
satellite server upgrade from 6.2.9 -> sat6.2.10 snap2 and capsule at old version 6.2.9

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
capsule sync failed

Expected results:
sync should succeed.

Additional info:

Comment 1 Sachin Ghai 2017-05-29 12:22:26 UTC
Okay, Just confirmed.. issue is not specific to n-1 capsule. If both satellite and capsule are installed w/ same 6.2.10 snap2, still it appears.

Comment 4 Evgeni Golov 2017-05-29 13:06:47 UTC
The following (untested) patch should fix it:

diff --git a/app/models/katello/glue/pulp/repo.rb b/app/models/katello/glue/pulp/repo.rb
index d6ff19d..1f2c71b 100644
--- a/app/models/katello/glue/pulp/repo.rb
+++ b/app/models/katello/glue/pulp/repo.rb
@@ -61,7 +61,7 @@ module Katello
 
         def self.needs_importer_updates(repos, capsule_content)
           repos.select do |repo|
-            repo_details = capsule.pulp_repo_facts(repo.pulp_id)
+            repo_details = capsule_content.pulp_repo_facts(repo.pulp_id)
             next unless repo_details
             capsule_importer = repo_details["importers"][0]
             !repo.importer_matches?(capsule_importer, capsule_content.capsule)

Comment 7 Lukas Pramuk 2017-06-08 16:26:05 UTC
This is not really upgrade bug as I hit it with not upgraded 6.2.9.

Comment 8 Lukas Pramuk 2017-06-08 16:28:36 UTC
edit: I hit it with not upgraded 6.2.10 snap2 Satellite and external 6.2.9 Capsule

Comment 9 Lukas Pramuk 2017-06-08 16:36:27 UTC
VERIFIED.

@satellite-6.2.10-3.0.el7sat.noarch
tfm-rubygem-katello-3.0.0.137-1.el7sat.noarch

# hammer capsule list
---|-----------------|------------------------------|--------------------------
ID | NAME            | URL                          | FEATURES                 
---|-----------------|------------------------------|--------------------------
2  | cap.example.com | https://cap.example.com:9090 | Templates, Pulp Node, ...
1  | sat.example.com | https://sat.example.com:9090 | Pulp, Puppet, Puppet C...
---|-----------------|------------------------------|--------------------------

# hammer capsule content synchronize --id=2
[......................................................................] [100%]

>>> capsule synced just fine (both UI/CLI)

Comment 11 errata-xmlrpc 2017-06-20 17:24:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1553


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