Actions
Bug #8272
openPlugins don't cleanup after themselves during uninstallation
Status:
New
Priority:
Normal
Assignee:
-
Category:
Plugin integration
Target version:
-
Description
Summary:¶
If you install a plugin (e.g., ruby193-rubygem-foreman_abrt or ruby193-rubygem-foreman_bootdisk) which adds settings to the Settings model and then uninstall the plugin, attempting to get the list of settings via the API will fail.
To reproduce the problem:¶
sudo yum install -y ruby193-rubygem-foreman_abrt
sudo yum remove -y ruby193-rubygem-foreman_abrt
curl -k -u $ADMIN_USERNAME:$ADMIN_PASSWORD -H "Accept: version=2,application/json" http://$FOREMAN_SERVER.$DOMAIN/api/settings
An exception like this will be generated:
{ "error": {"message":"The single-table inheritance mechanism failed to locate the subclass: 'Setting::Abrt'. 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."} }
To repair the problem:¶
foreman-rake console <<EOF
(1..100).each do |i|
begin
Setting.find_by_id(i)
rescue ActiveRecord::RecordNotFound,ActiveRecord::SubclassNotFound
Setting.delete(i)
end
end
exit
EOF
To verify the fix:¶
sudo yum install -y jq
if [ `curl -k -u $ADMIN_USERNAME:$ADMIN_PASSWORD -H "Accept: version=2,application/json" http://$FOREMAN_SERVER.$DOMAIN/api/settings | jq '.total'` != null ]; then
echo "Fix verified."
else
echo "Fix failed."
fi
Updated by Dominic Cleal about 10 years ago
- Project changed from Plugins to Foreman
- Category set to Settings
We put a fix into the UI to ignore settings for plugins when removed, we should do the same for the API.
Updated by Anonymous almost 10 years ago
This is also a problem elsewhere:
# foreman-rake config Workaround for RbVmomi may not work as ComputeResource is already loaded: ComputeResource [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. rake aborted! ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Setting::Bootdisk'. 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. /usr/share/foreman/vendor/ruby/1.9.1/gems/activerecord-3.2.21/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class' [...]
Updated by Anonymous about 8 years ago
- Related to Bug #17337: after uninstalling remote-execution-plugin i can't create locations anymore added
Updated by Adam Jacob Muller over 7 years ago
This occurred to me on my upgrade from 1.13 -> 1.14, the foreman-rake console command worked to correct it.
Updated by Marek Hulán over 7 years ago
- Related to Feature #19260: Add clean up job added
Updated by Marek Hulán over 7 years ago
- Related to Feature #3588: Uninstall plugins - from GUI or command line added
Updated by Daniel Lobato Garcia almost 7 years ago
bad_settings = [] (0..300).each do |i| begin puts Setting.find(i).name rescue ActiveRecord::SubclassNotFound puts "#{i} wrong subclass" bad_settings << i rescue ActiveRecord::RecordNotFound puts "#{i} not found" end end puts bad_settings Setting.where(:id => bad_settings).delete_all
Recently a user had success fixing this issue with the script above ^
Updated by Stephen Benjamin about 6 years ago
- Has duplicate Bug #25220: Plugin removal can cause Settings to fail transactions added
Updated by Amir Fefer over 3 years ago
- Category changed from Settings to Plugin integration
- Difficulty set to hard
- Triaged changed from No to Yes
Settings is being refactored from its STI approach, this should be moved to another category for a general plugin cleanup
Actions