Oh now I understand, looks like a new bug. I am not able to reproduce
with FDI 3.4.1 and develop Foreman. The code responsible for finding
existing record is here:

https://github.com/theforeman/foreman_discovery/blob/develop/app/models/host/discovered.rb#L53-L62

Theoretically if you changed configuration of bootif fact in settings,
this could happen. But I assume you haven't. Was it also the same FDI
version, just in case facter changed facts?

If you visit the original discovery host in the UI, do you see
Interfaces list? What MAC address is there? Is it detected as the
primary interface there?

Do you still have both records in the DB? Can you run rake console and
try these statements? Or insert Rails.logger.info statements there to
see the code flow.

On Tue, Oct 10, 2017 at 8:01 PM, 'Konstantin Orekhov' via Foreman
users <[email protected]> wrote:
>
>>
>> Name has already been taken - this usually means that host (either
>> discovered or managed or unmanaged) of that name "macXXXXXXXXX" already
>> exist. Same mac address? You can change easily how discovered hosts are
>> being named, by default it is "mac" + MAC address, you can change that to
>> random number or any different fact you want. See settings and our
>> documentation. Try to add a random number at the end if that helps.
>
>
> Well, no, that's the same host. It was discovered at some point back (8 days
> ago as you can see in the screenshot above). Then it got rebooted/crashed,
> PXE-booted again and started sending its discovery payload again, but gets
> 422. Usually, if it is the same host, Foreman just updates existing entry
> with new facts, or at least, the time of last report. But in the case above,
> that did not happen as for some reason Foreman created another record in a
> DB (with a different ID) for the same host. Unless I remove both of the
> records, 422s will continue to happen. I was hoping that a gist I provided
> gives you enough info on what could have caused that double-record situation
> for the same host.
>
> Here are my DB entries for the above host:
>
> [root@spc03 ~]# mysql -u foreman -p$DB_PASS foreman -e "SELECT * from hosts
> where type = 'Host::Discovered' and NAME = 'mac90e2baea5d58'\G;"
> *************************** 1. row ***************************
>                   id: 446735
>                 name: mac90e2baea5d58
>         last_compile: NULL
>          last_report: 2017-10-02 05:49:35
>           updated_at: 2017-10-02 05:49:46
>           created_at: 2017-09-15 22:44:42
>            root_pass: NULL
>      architecture_id: NULL
>   operatingsystem_id: NULL
>       environment_id: NULL
>            ptable_id: NULL
>            medium_id: NULL
>                build: 0
>              comment: NULL
>                 disk: NULL
>         installed_at: NULL
>             model_id: 6
>         hostgroup_id: NULL
>             owner_id: 10
>           owner_type: User
>              enabled: 1
>   puppet_ca_proxy_id: NULL
>              managed: 0
>            use_image: NULL
>           image_file: NULL
>                 uuid: NULL
>  compute_resource_id: NULL
>      puppet_proxy_id: NULL
>             certname: NULL
>             image_id: NULL
>      organization_id: NULL
>          location_id: NULL
>                 type: Host::Discovered
>                  otp: NULL
>             realm_id: NULL
>   compute_profile_id: NULL
>     provision_method: NULL
>            grub_pass:
>        global_status: 0
> lookup_value_matcher: NULL
>    discovery_rule_id: NULL
>        salt_proxy_id: NULL
>  salt_environment_id: NULL
>           pxe_loader: NULL
> *************************** 2. row ***************************
>                   id: 456978
>                 name: mac90e2baea5d58
>         last_compile: NULL
>          last_report: 2017-10-10 16:04:20
>           updated_at: 2017-10-10 16:04:20
>           created_at: 2017-10-07 07:13:19
>            root_pass: NULL
>      architecture_id: NULL
>   operatingsystem_id: NULL
>       environment_id: NULL
>            ptable_id: NULL
>            medium_id: NULL
>                build: 0
>              comment: NULL
>                 disk: NULL
>         installed_at: NULL
>             model_id: NULL
>         hostgroup_id: NULL
>             owner_id: NULL
>           owner_type: NULL
>              enabled: 1
>   puppet_ca_proxy_id: NULL
>              managed: 0
>            use_image: NULL
>           image_file: NULL
>                 uuid: NULL
>  compute_resource_id: NULL
>      puppet_proxy_id: NULL
>             certname: NULL
>             image_id: NULL
>      organization_id: NULL
>          location_id: NULL
>                 type: Host::Discovered
>                  otp: NULL
>             realm_id: NULL
>   compute_profile_id: NULL
>     provision_method: NULL
>            grub_pass:
>        global_status: 0
> lookup_value_matcher: NULL
>    discovery_rule_id: NULL
>        salt_proxy_id: NULL
>  salt_environment_id: NULL
>           pxe_loader: NULL
>
> --
> You received this message because you are subscribed to the Google Groups
> "Foreman users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/foreman-users.
> For more options, visit https://groups.google.com/d/optout.



-- 
Later,
  Lukas @lzap Zapletal

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to