Bug 1294674 - Undefined variable unknown_paths when candlepin references not available repository
Summary: Undefined variable unknown_paths when candlepin references not available repo...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Subscription Management
Version: 6.1.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Katello Bug Bin
QA Contact: Lukas Pramuk
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2015-12-29 15:03 UTC by Peter Vreman
Modified: 2019-09-26 14:46 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 09:21:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 12709 0 Normal Closed unknown_paths is not used and initialized 2021-02-01 20:46:21 UTC
Red Hat Product Errata RHBA-2016:1501 0 normal SHIPPED_LIVE Red Hat Satellite 6.2 Capsule and Server 2016-07-27 12:28:58 UTC

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


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