Bug #15368

refresh_facts on a renamed discovered host creating second discovered host record

Added by Christopher Chase 11 months ago. Updated 10 months ago.

Status:Closed
Priority:Normal
Assigned To:Lukas Zapletal
Category:Discovery plugin
Target version:Plugin 6.0
Difficulty: Pull request:https://github.com/theforeman/foreman_discovery/pull/276
Bugzilla link:1347023
Story points-
Velocity based estimate-

Description

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.

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 found. At this point repeating the process will not create a copy since one 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.

Associated revisions

Revision 7dc5b8d4
Added by Lukas Zapletal 10 months ago

Fixes #15368 - refresh existing discovered host

History

#1 Updated by Lukas Zapletal 10 months ago

  • Category set to Discovery plugin
  • Target version set to Plugin 6.0

Thanks for report.

#2 Updated by Lukas Zapletal 10 months ago

If you want this to be fixed in Satellite 6.2, create linked BZ and request 6.2.z flag. I will fix this for upstream only for now.

#3 Updated by The Foreman Bot 10 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Lukas Zapletal
  • Pull request https://github.com/theforeman/foreman_discovery/pull/275 added

#4 Updated by The Foreman Bot 10 months ago

  • Pull request https://github.com/theforeman/foreman_discovery/pull/276 added

#5 Updated by Christopher Chase 10 months ago

Created https://bugzilla.redhat.com/show_bug.cgi?id=1347023
Not allowed to edit the Bugzilla Link field, though

#6 Updated by Marek Hulán 10 months ago

  • Bugzilla link set to 1347023

#7 Updated by Lukas Zapletal 10 months ago

  • Pull request deleted (https://github.com/theforeman/foreman_discovery/pull/275)

#8 Updated by Anonymous 10 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF