Bug 1347023 - refresh_facts on a renamed discovered host creating second discovered host record
Summary: refresh_facts on a renamed discovered host creating second discovered host re...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Discovery Plugin
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: Unspecified
Assignee: Lukas Zapletal
QA Contact: Nikhil Kathole
URL: http://projects.theforeman.org/issues...
Whiteboard:
: 1371231 (view as bug list)
Depends On:
Blocks: 1216188 rhci-common-installer
TreeView+ depends on / blocked
 
Reported: 2016-06-15 20:05 UTC by cchase
Modified: 2019-09-26 15:40 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 17:04:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 15368 0 None None None 2016-06-16 12:01:54 UTC
Red Hat Bugzilla 1371231 0 unspecified CLOSED Re-discovering an existing host fails 2021-02-22 00:41:40 UTC

Internal Links: 1371231

Description cchase 2016-06-15 20:05:37 UTC
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.

Comment 1 Lukas Zapletal 2016-06-16 11:21:36 UTC
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.

Comment 3 Bryan Kearney 2016-06-27 10:17:22 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15368 has been closed

Comment 4 Lukas Zapletal 2016-09-06 13:57:18 UTC
*** Bug 1371231 has been marked as a duplicate of this bug. ***

Comment 6 Nikhil Kathole 2017-11-29 09:16:06 UTC
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
---|--------------|-------------------|------|--------|------------|------------|----------------------------|--------------------

Comment 7 Bryan Kearney 2018-02-21 17:04:14 UTC
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


Note You need to log in before you can comment on or make changes to this bug.