Foreman and Proxy versions:
Foreman nightly
Proxy 2.0.0-develop
Foreman and Proxy plugin versions:
Distribution and version:
Debian Buster
Other relevant data:
foreman-rake console
Host.find_by_name("Loading production environment (Rails 5.2.1)
irb(main):001:0>
irb(main):002:0>
irb(main):003:0> Host.find_by_name(“pc1.mycompany.net”).destroy
Traceback (most recent call last):
2: from lib/tasks/console.rake:5:in `block in <top (required)>’
1: from (irb):3
ActiveRecord::InvalidForeignKey (PG::ForeignKeyViolation: ERROR: update or delete on table “hosts” violates foreign key constraint “targeting_hosts_host_id” on table “targeting_hosts”)
DETAIL: Key (id)=(105) is still referenced from table “targeting_hosts”.
: DELETE FROM “hosts” WHERE “hosts”.“id” = $1
Is it possible that you at one time had foreman_remote_execution plugin installed and then removed it? That is where this foreign key relation is defined, but it is defines that association to be destroyed when destroying a host so its odd that it didn’t get removed properly when you destroyed the host.
There are quite a few tables, columns and associations created by it. Unfortunately we don’t have a good clean-up mechanism for plugin removals currently. You could try going over all migrations in https://github.com/theforeman/foreman_remote_execution/tree/master/db/migrate and reverting them manually, but it is untested. Another approach could be installing remote execution and not using it (and hopefully the concurrent ruby issue will be resolved eventually).
If you are installing using the installer, run foreman-installer --enable-foreman-plugin-remote-execution. If you are installing from packages, run apt-get install ruby-foreman-remote-execution. Note this means you will have remote execution in your menus but it will not be functional until you have a proxy that includes the remote execution function enabled.
By installing only ruby-foreman-remote-execution the foreman-proxy will restart normally. Cool!
Then, the bug occurs by installing ruby-smart-proxy-remote-execution-ssh.
From what I could see on the concurrent ruby’s github, they have already solved the problem with debian. On the foreman’s part there is still something to do. Do you know if they’re already working on it?
Well, yes and no. They made a pre-release which should fix things and as far as I can tell it looks good, but noone packaged it yet. I’m not really a packaging guy, but I think we’re waiting for a proper (non pre-) release to be released.