Description of problem: Trying to refresh facts on an existing discovered host creates a new discovered host. The new host has the same information but a name based on mac address. Version-Release number of selected component (if applicable): How reproducible: 100% Steps to Reproduce: 1. Discover a host 2. Update the name on the discovered host to something other than mac address based name 3. refresh_facts 4. Refresh discovered hosts page or data. I was doing this through the api calls to discovered hosts, but was also able to reproduce on the console: ::Host::Discover.count dh = ::Host::Discovered.find(<id>) dh.name = 'copyme' dh.save dh.refresh_facts ::Host::Discover.count Actual results: A new discovered host with a name based on mac address was created. At this point repeating the process will not create another copy since one with a mac address based name already exists. Expected results: The facts on the host would be refreshed without creating a new host. Additional info: It looked like refresh_facts calling Host::Discovered.import_host would find_by_name and come up empty and create a new host.
TRIAGE NOTES: Blocker for FUSOR team, z-stream candidate, small change, low impact. QA NOTES: To test this, discover host when there is existing one with same name and with different name (rename it using the technique above). Host should only be updated. Upstream patch pending review.
Moving to POST since upstream bug http://projects.theforeman.org/issues/15368 has been closed
*** Bug 1371231 has been marked as a duplicate of this bug. ***
VERIFIED Version Tested: Satellite-6.3 Snap 26 steps: 1. hammer> discovery list ---|--------------------------------------|-------------------|------|--------|------------|------------|----------------------------|-------------------- ID | NAME | MAC | CPUS | MEMORY | DISK COUNT | DISKS SIZE | SUBNET | LAST REPORT ---|--------------------------------------|-------------------|------|--------|------------|------------|----------------------------|-------------------- 16 | 1fbe13b4-9f6a-4fbf-b9ac-b3ee6be44c73 | 52:54:00:c5:f5:3e | 1 | 993 | 1 | 10240 | foreman (192.168.100.0/24) | 2017/11/28 12:37:39 15 | 52540035f97e | 52:54:00:35:f9:7e | 1 | 993 | 1 | 10240 | foreman (192.168.100.0/24) | 2017/11/28 12:26:45 ---|--------------------------------------|-------------------|------|--------|------------|------------|----------------------------|--- 2. # foreman-rake console Loading production environment (Rails 4.2.6) irb(main):001:0> ::Host::Discovered.count => 2 irb(main):002:0> dh = ::Host::Discovered.find(16) => #<Host::Discovered id: 16, name: "1fbe13b4-9f6a-4fbf-b9ac-b3ee6be44c73", last_compile: nil, last_report: "2017-11-28 12:37:39", update d_at: "2017-11-28 12:37:39", created_at: "2017-11-28 12:17:48", root_pass: nil, architecture_id: nil, operatingsystem_id: nil, environmen t_id: nil, ptable_id: nil, medium_id: nil, build: false, comment: nil, disk: nil, installed_at: nil, model_id: 2, hostgroup_id: nil, owne r_id: 1, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: false, use_image: nil, image_file: nil, uuid: nil, compute_ resource_id: nil, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: 1, location_id: 2, type: "Host::Discovered", otp: nil, realm_id: nil, compute_profile_id: nil, provision_method: nil, grub_pass: "", discovery_rule_id: nil, content_view_id: nil, lifecycl e_environment_id: nil, global_status: 0, lookup_value_matcher: nil, pxe_loader: nil, openscap_proxy_id: nil> irb(main):003:0> dh.name = 'test' => "test" irb(main):004:0> dh.save => true irb(main):005:0> dh.refresh_facts => true irb(main):006:0> ::Host::Discovered.count => 2 irb(main):007:0> dh = ::Host::Discovered.find(16) => #<Host::Discovered id: 16, name: "test", last_compile: nil, last_report: "2017-11-29 09:05:06", updated_at: "2017-11-29 09:05:06", created_at: "2017-11-28 12:17:48", root_pass: nil, architecture_id: nil, operatingsystem_id: nil, environment_id: nil, ptable_id: nil, medium_id: nil, build: false, comment: nil, disk: nil, installed_at: nil, model_id: 2, hostgroup_id: nil, owner_id: 1, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: false, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: nil, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: 1, location_id: 2, type: "Host::Discovered", otp: nil, realm_id: nil, compute_profile_id: nil, provision_method: nil, grub_pass: "", discovery_rule_id: nil, content_view_id: nil, lifecycle_environment_id: nil, global_status: 0, lookup_value_matcher: nil, pxe_loader: nil, openscap_proxy_id: nil> 3. hammer> discovery list ---|--------------|-------------------|------|--------|------------|------------|----------------------------|-------------------- ID | NAME | MAC | CPUS | MEMORY | DISK COUNT | DISKS SIZE | SUBNET | LAST REPORT ---|--------------|-------------------|------|--------|------------|------------|----------------------------|-------------------- 16 | test | 52:54:00:c5:f5:3e | 1 | 993 | 1 | 10240 | foreman (192.168.100.0/24) | 2017/11/29 09:05:06 15 | 52540035f97e | 52:54:00:35:f9:7e | 1 | 993 | 1 | 10240 | foreman (192.168.100.0/24) | 2017/11/28 12:26:45 ---|--------------|-------------------|------|--------|------------|------------|----------------------------|--------------------
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2018:0336