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 1456446

Summary: Capsule sync failed w/ error: undefined local variable or method `capsule' for #<Class:0x0000000f0b18a0> (NameError)
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: UpgradesAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.10CC: bbuckingham, dlezzoum, egolov, inecas, jsherril, lpramuk, mbacovsk, zhunting
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.137-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-20 17:24:19 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 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