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
Actions