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

Also available in: Atom PDF