rubygem-staypuft: Can't remove a host from staypuft: ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(18) is still referenced from table "tokens". Environment: openstack-puppet-modules-2014.2.8-1.el7ost.noarch ruby193-rubygem-foreman_openstack_simplify-0.0.6-8.el7ost.noarch openstack-foreman-installer-3.0.8-1.el7ost.noarch rhel-osp-installer-0.5.4-1.el7ost.noarch ruby193-rubygem-staypuft-0.5.9-1.el7ost.noarch rhel-osp-installer-client-0.5.4-1.el7ost.noarch Steps to reproduce: 1. Install rhel-osp-installer. 2. Attempt to discover/deploy/delete hosts several times. Result: At some point the issue appears, can't delete some host from the UI. I get: ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(18) is still referenced from table "tokens". Full trace: PGError ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(18) is still referenced from table "tokens". app/controllers/hosts_controller.rb:401:in `block in submit_multiple_destroy' app/controllers/hosts_controller.rb:401:in `submit_multiple_destroy' app/models/concerns/foreman/thread_session.rb:33:in `clear_thread' lib/middleware/catch_json_parse_errors.rb:9:in `call' In the foreman logs I have: ==> /var/log/foreman-proxy/proxy.log <== ==> /var/log/foreman/production.log <== Started GET "/hosts" for 10.10.57.157 at 2014-12-24 14:25:37 +0000 Processing by HostsController#index as HTML Rendered hosts/_list.html.erb (29.5ms) Rendered hosts/index.html.erb within layouts/application (36.2ms) Rendered common/_searchbar.html.erb (8.6ms) Rendered home/_user_dropdown.html.erb (2.0ms) Read fragment views/tabs_and_title_records-3 (0.2ms) Rendered home/_topbar.html.erb (3.2ms) Rendered layouts/base.html.erb (5.2ms) Completed 200 OK in 74ms (Views: 51.5ms | ActiveRecord: 5.8ms) Started DELETE "/hosts/mac000af7799318.example.com" for 10.10.57.157 at 2014-12-24 14:25:42 +0000 Processing by HostsController#destroy as HTML Parameters: {"authenticity_token"=>"dDBCa3y0KzynOCieQ/jOhZtsHrklRWkqLzPiqyU2Ppc=", "id"=>"mac000af7799318.example.com"} Operation FAILED: ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(18) is still referenced from table "tokens". Rendered common/500.html.erb within layouts/application (7.5ms) Rendered layouts/base.html.erb (2.2ms) Completed 500 Internal Server Error in 86ms (Views: 11.9ms | ActiveRecord: 18.9ms) Expected result: Should always be able to delete any host.
As a workaround: 1. moved the host to production environment (from Discovery) 2. assigned it to "base_RedHat_7" host group 3. turned the host to "managed" in the UI and then was able to delete it. Probably a single step from above could do the trick