Bug 2139371

Summary: can't save RH Cloud settings on an upgraded Satellite 6.12
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: RH Cloud - InventoryAssignee: Evgeni Golov <egolov>
Status: CLOSED ERRATA QA Contact: Jameer Pathan <jpathan>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.12.0CC: aruzicka, lvrtelov, pcreech
Target Milestone: 6.12.0Keywords: Triaged, Upgrades
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-16 13:35:51 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 Evgeni Golov 2022-11-02 10:17:15 UTC
Description of problem:
On a setup that has been upgraded from 6.11, one can't save any RH Cloud related settings.

Version-Release number of selected component (if applicable):
rubygem-foreman_rh_cloud-6.0.42-1.el8sat.noarch
satellite-6.12.0-4.el8sat.noarch


How reproducible:
100%

Steps to Reproduce:
1. install 6.11
2. upgrade to 6.12
3. go to settings → RH CLoud
4. try to edit a setting, like ID of RHC

Actual results:
500 Error

production log reads:
2022-11-02T06:01:48 [I|app|5a958eef] Started PUT "/api/settings/rhc_instance_id" for 10.39.195.157 at 2022-11-02 06:01:48 -0400
2022-11-02T06:01:48 [I|app|5a958eef] Processing by Api::V2::SettingsController#update as JSON
2022-11-02T06:01:48 [I|app|5a958eef]   Parameters: {"setting"=>{"value"=>"[FILTERED]"}, "apiv"=>"v2", "id"=>"rhc_instance_id"}
2022-11-02T06:01:48 [W|app|5a958eef] Action failed
2022-11-02T06:01:48 [I|app|5a958eef] Backtrace for 'Action failed' error (ActiveRecord::SubclassNotFound): The single-table inheritance mechanism failed to locate the subclass: 'Setting::RhCloud'. This error is raised because the column 'category' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Setting.inheritance_column to use another column for that information.
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/inheritance.rb:234:in `rescue in find_sti_class'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/inheritance.rb:227:in `find_sti_class'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/inheritance.rb:215:in `discriminate_class_for_record'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/persistence.rb:257:in `instantiate'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/querying.rb:58:in `block (2 levels) in find_by_sql'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/result.rb:62:in `block in each'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/result.rb:62:in `each'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/result.rb:62:in `each'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/querying.rb:58:in `map'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/querying.rb:58:in `block in find_by_sql'
 5a958eef | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/querying.rb:56:in `find_by_sql'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:824:in `block in exec_queries'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:842:in `skip_query_cache_if_necessary'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:811:in `exec_queries'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:626:in `load'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:250:in `records'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/finder_methods.rb:499:in `find_take'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/finder_methods.rb:98:in `take'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/finder_methods.rb:81:in `find_by'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/querying.rb:21:in `find_by'
 5a958eef | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/core.rb:183:in `find_by'
 5a958eef | /usr/share/foreman/app/services/setting_registry.rb:181:in `_find_or_new_db_record'
 5a958eef | /usr/share/foreman/app/services/setting_registry.rb:82:in `set_user_value'
 5a958eef | /usr/share/foreman/app/controllers/api/v2/settings_controller.rb:54:in `update'


Expected results:
No error, setting is saved

Additional info:
This is because the DB was not migrated to use `Setting` instead of `Setting::RhCloud` as the category of the settings.

Comment 3 Jameer Pathan 2022-11-04 08:30:54 UTC
Verified:

Verified with:
- Satellite 6.12 snap 16
- rubygem-foreman_rh_cloud-6.0.42.2-1.el8sat.noarch

Test steps:
- Install Satellite 6.11
- Upgrade Satellite to 6.12 snap 16
- Go to Administer > Settings > RH Cloud
- Try to edit rhc_instance_id setting

Observations:
- Setting was updated successfully 
- No traceback in production.log

Comment 6 errata-xmlrpc 2022-11-16 13:35:51 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 (Important: Satellite 6.12 Release), 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/RHSA-2022:8506