Problem:
Imported a set of servers via the API using a script I wrote (note: not using hammer, but the REST API)
Expected outcome:
Expected that all servers show under /hosts
(UI or API), however a few are missing. None gave an error when adding them. I cannot re-add them because it says they already exist, and I can’t delete them because it says they don’t exist! Perhaps adding them in parallel caused some kind of race condition.
Foreman and Proxy versions:
Version 3.10.0
Distribution and version:
CentOS 8.6
I do see it in the psql db:
foreman=# select * from hosts where name = 'myserver.com';
66 | myserver.com | | | 2024-08-29 19:07:29.983322 | 2024-08-29 19:07:29.983322 | | 1 | 2 | 136 | 18 | f | | | | | 7 | 10 | User | t | 1 | t | |
| | | 1 | | | 1 | 4 | | | | | | | 0 | fqdn=myserver.com | | | | 10 |
but hammer can’t find it:
$ hammer host info --name myserver.com
Error: host not found.
$ hammer host info --id 66
Resource host not found by id '66'
Looks like the host was partially added. I deleted it manually where I could find it in pgsql and was able to re-add:
delete from nics where host_id = 66;
delete from host_puppet_facets where host_id = 66;
delete from hosts where id = 66;
I was then able to re-add it successfully.