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 1294674

Summary: Undefined variable unknown_paths when candlepin references not available repository
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: Subscription ManagementAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.5CC: bbuckingham, cwelton, lpramuk
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/12709
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 09:21:57 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:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2015-12-29 15:03:48 UTC
Description of problem:
When updating a system it can be that it tries to bind to a repository that is already being removed.
Updating this info in Katello is handled by models/system.rb:save_bound_repos_by_path() but this fails as soon as there is a reference to an unknown repository. Because then it uses a variable that is not defined anywhere except on a single line:

[crash] root@li-lc-1017:/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app# grep -r unknown_paths *
models/katello/system.rb:          unknown_paths << path


Below is a trace:

2015-12-29 14:50:12 [I]   Parameters: {"enabled_repos"=>{"repos"=>[{"baseurl"=>["https://li-lc-1017.ha
g.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/custom/HOICI/HOICI-1_0-sp15"], "repositoryid"=>"Hi
lti_HOICI_HOICI-1_0-sp15"}, {"baseurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg
-crash__Jira/custom/HOIOS/HOIOS-6_6_0-hf6"], "repositoryid"=>"Hilti_HOIOS_HOIOS-6_6_0-hf6"}, {"baseurl
"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/custom/HOIPRODUCTS/HOIPR
ODUCTS-1_1_0-hf6"], "repositoryid"=>"Hilti_HOIPRODUCTS_HOIPRODUCTS-1_1_0-hf6"}, {"baseurl"=>["https://
li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/custom/HOIRHEL/HOIRHEL-6_6-d20151011"
], "repositoryid"=>"Hilti_HOIRHEL_HOIRHEL-6_6-d20151011"}, {"baseurl"=>["https://li-lc-1017.hag.hilti.
com/pulp/repos/Hilti/Library/hg-crash__Jira/custom/HOIRHEL/HOIRHEL-6_6-d20151220"], "repositoryid"=>"H
ilti_HOIRHEL_HOIRHEL-6_6-d20151220"}, {"baseurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/
Library/hg-crash__Jira/content/eus/rhel/server/6/6.6/x86_64/optional/os"], "repositoryid"=>"rhel-6-ser
ver-eus-optional-rpms"}, {"baseurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-cr
ash__Jira/content/eus/rhel/server/6/6.6/x86_64/os"], "repositoryid"=>"rhel-6-server-eus-rpms"}, {"base
url"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/content/eus/rhel/serv
er/6/6.6/x86_64/sat-tools/6.1/os"], "repositoryid"=>"rhel-6-server-eus-satellite-tools-6.1-rpms"}, {"b
aseurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/content/eus/rhel/s
erver/6/6.6/x86_64/oracle-java/os"], "repositoryid"=>"rhel-6-server-eus-thirdparty-oracle-java-rpms"},
 {"baseurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/content/eus/rh
el/server/6/6.6/x86_64/loadbalancer/os"], "repositoryid"=>"rhel-lb-for-rhel-6-server-eus-rpms"}, {"bas
eurl"=>["https://li-lc-1017.hag.hilti.com/pulp/repos/Hilti/Library/hg-crash__Jira/content/eus/rhel/ser
ver/6/6.6/x86_64/rhscl/1/os"], "repositoryid"=>"rhel-server-rhscl-6-eus-rpms"}]}, "id"=>"1fbebc86-da15
-44e0-8ed2-5040cffb5e5b"}
[ERROR 2015-12-29 14:50:12 cp_proxy  #1155] NameError: undefined local variable or method `unknown_pat
hs' for #<Katello::System:0x00000011274780>
 | /opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/attribute_methods.rb:40
7:in `method_missing'
 | /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods.rb:
149:in `method_missing'
 | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app/models/katello/system.rb:233:in `bloc
k in save_bound_repos_by_path!'
 | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app/models/katello/system.rb:230:in `each
'
 | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app/models/katello/system.rb:230:in `save
_bound_repos_by_path!'
 | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app/controllers/katello/api/rhsm/candlepi
n_proxies_controller.rb:189:in `enabled_repos'
 | /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_rend
er.rb:4:in `send_action'
 | /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `p
rocess_action'
 | /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:
10:in `process_action'
 | /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:i
n `block in process_action'
 | /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:584:in
 `block (5 levels) in _run__3962542475979592503__process_action__4224815392861861857__callbacks'
 | /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in
 `block in _conditional_callback_around_12144'
 | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.77/app/controllers/katello/api/rhsm/candlepi





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


How reproducible:


Steps to Reproduce:
1. Use susbcription-manager refresh to update to repositories that are not available anymore in Katello.
2. 
3.

Actual results:
Repos will never get updated as it stops on this undefined variable

Expected results:
Repos are save and this broken repos are filtered out


Additional info:

Comment 1 Peter Vreman 2015-12-29 15:23:53 UTC
Fixed is already upstream in http://projects.theforeman.org/issues/12709

Comment 4 Lukas Pramuk 2016-05-02 17:32:08 UTC
VERIFIED.

@Sat6.2.0-Beta

Though I tried various ways to trigger binding an empty repo, I rather consider this bz verification as SanityOnly:

# head -119 /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.24/app/models/katello/system.rb | tail -3
        if possible_repos.empty?
          Rails.logger.warn("System #{self.name} (#{self.id}) requested binding to unknown repo #{path}")
        else

>>> undefined local variable was removed

Comment 6 errata-xmlrpc 2016-07-27 09:21:57 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-2016:1501