No, the hostname of the servers which have issues, doesn’t exist in Foreman, have the issues since Katello 3.18, I deleted them to resolve the issues, but it did not work, then I thought it would resolve after upgrading to Katello 4.0.1 and upgraded, but the issues still there.
I searched through the organization(in this environment there is only one Organization in the location), I searched using admin account, still no luck. I have 3 hosts with same issues and they are RHEL 6.10.
I’m sorry, I’m out of ideas. Perhaps looks at the database - hosts table and see if there’s this name already used. The validation error is pretty clear, for some reason it thinks there’s already host with such name.
I ran the command as you recommended and I see the hosts with problems listed along with other hosts. Attached is the command output screen shot, I highlighted the hosts in yellow which have the error "Validation failed: Name has already been taken”.
This worked and the issue was resolved by running “Host::Base.where(id: [233, 265, 274]).destroy_all” in foreman-rake console, there was no Host::Base in the output table for the command “sudo -u postgres psql foreman -c ‘select id, name, type, organization_id, location_id from hosts;’”, but the problematic hosts showing blank in the type column, whereas working hosts are showing “Host::Managed” in type column.