Bug 1294674 - Undefined variable unknown_paths when candlepin references not available repository
Undefined variable unknown_paths when candlepin references not available repo...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Subscription Management (Show other bugs)
6.1.5
Unspecified Unspecified
unspecified Severity high (vote)
: Beta
: --
Assigned To: Katello Bug Bin
Lukas Pramuk
http://projects.theforeman.org/issues...
: Triaged
Depends On:
Blocks: 1122832
  Show dependency treegraph
 
Reported: 2015-12-29 10:03 EST by Peter Vreman
Modified: 2016-07-27 05:21 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-07-27 05:21:57 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 12709 None None None 2016-04-22 11:13 EDT

  None (edit)
Description Peter Vreman 2015-12-29 10:03:48 EST
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 10:23:53 EST
Fixed is already upstream in http://projects.theforeman.org/issues/12709
Comment 4 Lukas Pramuk 2016-05-02 13:32:08 EDT
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 05:21:57 EDT
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.