Project

General

Profile

Actions

Bug #8272

open

Plugins don't cleanup after themselves during uninstallation

Added by Christopher Voltz about 10 years ago. Updated over 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Plugin integration
Target version:
-
Difficulty:
hard
Triaged:
Yes
Fixed in Releases:
Found in Releases:

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

Related issues 4 (2 open2 closed)

Related to Foreman Remote Execution - Bug #17337: after uninstalling remote-execution-plugin i can't create locations anymoreNew11/15/2016Actions
Related to Templates - Feature #19260: Add clean up jobClosedMarek Hulán04/12/2017Actions
Related to Foreman - Feature #3588: Uninstall plugins - from GUI or command lineNew11/06/2013Actions
Has duplicate Katello - Bug #25220: Plugin removal can cause Settings to fail transactionsDuplicateActions
Actions #1

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.

Actions #2

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'
[...]

Actions #3

Updated by Anonymous about 8 years ago

  • Related to Bug #17337: after uninstalling remote-execution-plugin i can't create locations anymore added
Actions #4

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.

Actions #5

Updated by Marek Hulán over 7 years ago

Actions #6

Updated by Marek Hulán over 7 years ago

  • Related to Feature #3588: Uninstall plugins - from GUI or command line added
Actions #7

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 ^

Actions #8

Updated by Stephen Benjamin about 6 years ago

  • Has duplicate Bug #25220: Plugin removal can cause Settings to fail transactions added
Actions #9

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

Also available in: Atom PDF