Bug 1384146

Summary: [RFE] Discovery should not create an entry if the mac/serialnumber already exists as managed
Product: Red Hat Satellite Reporter: Josh Foots <jfoots>
Component: Discovery PluginAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Radovan Drazny <rdrazny>
Severity: high Docs Contact:
Priority: medium    
Version: 6.2.2CC: bbuckingham, bkearney, jcallaha, jfoots, jhutar, jscalf, rdrazny
Target Milestone: UnspecifiedKeywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 12:35:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Josh Foots 2016-10-12 16:22:10 UTC
Description of problem:

Discovery image should not create an entry in the discovered hosts table if the mac/serialnumber already exists in the hosts table.

Comment 1 Lukas Zapletal 2016-10-21 12:14:52 UTC
Josh, can you describe the motivation in more detail? You can encounter two MAC addresses in one deployment, I don't see a reason why to prevent from that. If the host will be provisioned in a different subnet, than this constraint could be problem.

Not sure about serial number, not all servers provide those.

Comment 6 Lukas Zapletal 2017-02-24 14:37:02 UTC
This bug will be part of Satellite NEXT (stable is 6.2 at the moment).

Comment 7 Satellite Program 2017-04-22 06:18:47 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16890 has been resolved.

Comment 9 Satellite Program 2017-06-01 20:29:54 UTC
1439850

Comment 10 Radovan Drazny 2017-10-18 13:09:01 UTC
Verified on Satellite 6.3 Snap 20. 

Using the foreman-discovery-image-3.1.1-22, doing PXEless discovery:

1. Have some previously registered (content) host
2. Boot a virtual system using the foreman-discovery image, go through the discovery process, and check the Hosts->Discovered hosts table. The system that was just discovered should be present.
3. Just to be sure, modify the virtual system HW (add some memory or virtual HDD), and try to re-run the discovery procedure. The discovered system should be updated, not duplicated.
4. Remove the discovered host.
5. Edit previously registered host, and change its MAC address to MAC address of the virtual system. 
6. Try to re-run the discovery process on the virtual system. Instead of the success message, the process will loop back to the start of the IP address configuration wizard. There is the following message in /var/log/foreman/production.log:

Host discovery failed, facts: {"lib"=>"/usr/share/fdi/facts:/opt/extension/facts", "virtual"=>"kvm", "is_virtual"=>true, "architecture"=>"x86_64", "hardwaremodel"=>"x86_64", "os"=>{"name"=>"RedHat"
, "family"=>"RedHat", "release"=>{"major"=>"7", "minor"=>"3", "full"=>"7.3"}}, "network_ens9"=>"192.168.122.0", "network_lo"=>"127.0.0.0", "hardwareisa"=>"x86_64", "physicalprocessorcount"=>1, "netmask"=>"255.255.255.0", "memorysize"=>"
992.57 MB", "memorysize_mb"=>"992.57", "ps"=>"ps -ef", "fqdn"=>"fdi", "uniqueid"=>"a8c07b7a", "dhcp_servers"=>{"system"=>"192.168.122.1", "ens9"=>"192.168.122.1"}, "hostname"=>"fdi", "macaddress"=>"52:54:00:b4:c4:03", "bios_vendor"=>"Se
aBIOS", "bios_version"=>"1.10.2-1.fc26", "bios_release_date"=>"04/01/2014", "manufacturer"=>"QEMU", "productname"=>"Standard PC (i440FX + PIIX, 1996)", "serialnumber"=>"Not Specified", "uuid"=>"9C322EB1-C718-4816-98C2-11C81247857A", "ty
pe"=>"Other", "selinux"=>false, "interfaces"=>"ens9,lo", "ipaddress_ens9"=>"192.168.122.123", "macaddress_ens9"=>"52:54:00:b4:c4:03", "netmask_ens9"=>"255.255.255.0", "mtu_ens9"=>1500, "ipaddress_lo"=>"127.0.0.1", "netmask_lo"=>"255.0.0
.0", "mtu_lo"=>65536, "gid"=>"root", "id"=>"root", "ipaddress"=>"192.168.122.123", "processors"=>{"models"=>["Intel Core Processor (Haswell, no TSX)"], "count"=>1, "physicalcount"=>1}, "processor0"=>"Intel Core Processor (Haswell, no TS
X)", "processorcount"=>1, "facterversion"=>"2.4.6", "blockdevice_sr0_size"=>218103808, "blockdevice_sr0_vendor"=>"QEMU", "blockdevice_sr0_model"=>"QEMU DVD-ROM", "blockdevice_vda_size"=>3221225472, "blockdevice_vda_vendor"=>"0x1af4", "b
lockdevices"=>"sr0,vda", "discovery_version"=>"3.1.1", "discovery_release"=>"20170323.1", "discovery_bootif"=>"52:54:00:b4:c4:03", "discovery_bootip"=>"192.168.122.123", "speed_ens9"=>"100", "duplex_ens9"=>"full", "port_ens9"=>"MII", "a
uto_negotiation_ens9"=>"true", "wol_ens9"=>false, "link_ens9"=>"true", "link_lo"=>"true", "discovery_kexec"=>"kexec-tools 2.0.7 released 05 September 2016\n", "discovery_ip_cidr"=>"192.168.122.123/24", "discovery_ip"=>"192.168.122.123",
 "discovery_netmask"=>"255.255.255.0", "discovery_gateway"=>"192.168.122.1", "discovery_dns"=>"192.168.122.1", ""=>""}

7. Change the MAC address of the previously registered host to the original value.
8. Re-run the discovery process on the virtual system. It will be successful this time.

VERIFIED

Comment 13 errata-xmlrpc 2018-02-21 12:35:52 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