Bug #32492
closed
Unable to delete old host "PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".
Added by Oliver Weinmann almost 4 years ago.
Updated about 3 years ago.
Description
Hi,
Running up to date Katello 3.18.2. I'm not able to delete old hosts. When trying to delete an old host, the following error is shown:
"PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".
Deleting newly created hosts is possible.
Googling for the error came up with this:
https://community.theforeman.org/t/cant-delete-any-hosts-after-upgrade-to-katello-3-18/21998
which lead me to a reported bug.
https://projects.theforeman.org/issues/31669
Unfortunately the fix doesn't work for me.
Best Regards,
Oliver
- Target version set to Katello 3.18.4
- Triaged changed from No to Yes
Hi Oliver. Are you able to delete the hosts after doing a complete restart of foreman services? foreman-maintain service restart is the command to run on your server
- Status changed from New to Need more information
- Target version deleted (
Katello 3.18.4)
- Triaged changed from Yes to No
- Project changed from Katello to Foreman
Hi Jonathon,
sorry for my late reply. I did restart katello a couple of times due to some other issues I have. This morning I tried to delete the host again and it still fails. I checked the dynflow console and the subtasks and the error is still the same:
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets"
DETAIL: Key (id)=(40) is still referenced from table "registration_facets".
So it is failing to unregister the host as content host. I manually trid to unregister it but as expected, this also fails. I renamed the host, but this also doesn't work.
Best Regards,
Oliver
- Status changed from Need more information to Resolved
I can't remeber how, but I managed to get rid of the host. Ticket closed. :)
Hi,
sorry I have to open this one again. The problem still persists. I must have mistakenly reported the machine as deleted. I'm now running latest Katello 3.18 and the problem still exists. I have recreated the VM and registered it as content host. Tried deleting -> doesn't work, same error.
PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".
It is not a big problem but it would be nice to get rid of the machine. :)
Best Regards,
Oliver
Hi there,
Here's something that should get you going:
1. Take a backup of your instance
2. Log in as root and run 'foreman-admin'
3. Find the registration facet that's referring to your host: ForemanRegister::RegistrationFacet.where(host_id: $HOST_ID)
Verify that you get one result
4. Then, delete that registration facet: ForemanRegister::RegistrationFacet.where(host_id: $HOST_ID).destroy_all
That should work for you for now! I don't know the root cause of the bug but I think it's been fixed. Definitely recommend updating to 4.1 at least since 3.18 is no longer supported. In the future, please inquire about support in our community forum: https://community.theforeman.org/c/support/10 as you can get support from a much wider audience of folks!
Jonathon
Hi Jonathon,
thanks a lot. I didn't have "foreman-admin" but I used "foreman-rake console" instead. All fixed now. :)
Actually I do make use of the community a lot. But I didn't want to duplicate my problem. I just recently had my journey upgrading to Pulp3, this took me ages to fix. :) I would love to upgrade to Katello 4.x but we are still relying on a couple of puppet modules and have to replace them with ansible roles first. As if I understood correctly from the docs in Katello 4.x puppet repos are no longer supported. But that is a bit off topic now.
Best Regards,
Oliver
Also available in: Atom
PDF