Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete host after disabling foreman_puppet (after using it) #331

Open
nadjaheitmann opened this issue Feb 2, 2023 · 10 comments
Open
Assignees

Comments

@nadjaheitmann
Copy link
Collaborator

https://community.theforeman.org/t/unable-to-delete-host-after-disabling-puppet/32112/8

@nadjaheitmann
Copy link
Collaborator Author

Looks like the DB structures are not deleted correctly after the foreman_puppet plugin was in use for some time and the table fills up with data.

@ronnybremer
Copy link

Puppet was enabled by default when we installed F/K. After a few years I disabled the plugin and ran the command

foreman-maintain plugin purge-puppet --remove-all-data

according to the documentation. Also ran

foreman-rake purge:puppet

to make sure all is cleaned out.

However, I still find this in the Postgres DB:

foreman=# select count(*) FROM host_puppet_facets;
 count
-------
    19
(1 row)

And apparently an entry in that table prevents a host from being deleted, as the Puppet code (which I assume normally takes care of the cascaded delete) is no longer run.

@nadjaheitmann
Copy link
Collaborator Author

Which initial version of Foreman/Katello did you install?

@ronnybremer
Copy link

Ohhh... that was a long time ago, I think F 2.x and K 3.1?

@nadjaheitmann
Copy link
Collaborator Author

Ah, okay. Then the data was already there in the old Foreman and was ported to the plugin once you upgraded Foreman to 3.0.

@nadjaheitmann
Copy link
Collaborator Author

nadjaheitmann commented Feb 23, 2023

I had a look at the issue but it is somehow difficult to reproduce. Host and hostgroups are being deleted without any errors on my test system.

What I found is that (for some reason I could NOT find), the foreman-maintain command that removes the puppet tables from the database (https://github.com/theforeman/foreman_maintain/blob/v1.0.x/definitions/procedures/puppet/remove_puppet.rb#L15) does not drop the tables for host_puppet_facets and hostgroup_puppet_facets - although the foreman-maintain log tells me that they were dropped. When I check the database, the tables are still there. But when I execute foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet manually, all tables are dropped from the database as they should.

@nadjaheitmann
Copy link
Collaborator Author

@ronnybremer Did you try to remove the host_puppet_facets and hostgroup_puppet_facets tables manually?

I am not sure if we can reproduce your issue that easily. Do you remember which Foreman version you were on when removing Puppet?

@ronnybremer
Copy link

Did you try to remove the host_puppet_facets and hostgroup_puppet_facets tables manually?

No, I only removed the offending records for the one host I tried to remove. The rest is still untouched. Furthermore, I only had a dependency issue with the host_puppet_facets table, but I also didn't try to delete a host group.

@nadjaheitmann
Copy link
Collaborator Author

I think it should be safe to remove the puppet facets tables. If you don't use Puppet and the rest of the plugin is gone anyways, they are no good. Could you check whether there are other artifacts from foreman_puppet that were not removed? Or you can simply post a list of the tables that are available in your setup if that is okay for you.

@nadjaheitmann
Copy link
Collaborator Author

@stejskalleos Could you find someone to test this issue? We could not reproduce. From my perspective, this seems to be a one-time issue with an older system that has used Puppet before transitioning to the foreman_puppet plugin but I'd like someone to double-check.

@stejskalleos stejskalleos self-assigned this Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants