Discovery status failure (422 unable to find primary NIC)

Problem:
discovery status failure (422 unable to find primary NIC)

Expected outcome:

Foreman and Proxy versions:
2.3

Foreman and Proxy plugin versions:
discovery 15 (last version)

Distribution and version:
CentOS 7.9

Other relevant data:

Machines are vsphere VMs (both foreman server and the server aimed to be discovered/installed.

Thank you for your support.

Hey, can you get me output of facter --json from that host? This should work.

Hello,
Unfortunately :slight_smile:

Oh right sorry.

scl enable tfm -- facter --json

Or (I can’t remember):

scl enable rh-ruby25 -- facter --json

Is the command now.

After changed the sheband of the facter file to #!/usr/bin/tfm-ruby
I’ve succeed to produce the json file:

{
  "discovery_bootif": "00:50:56:ac:18:b6",
  "discovery_release": "20210122.1",
  "discovery_version": "3.7.3",
  "disks": {
    "sda": {
      "model": "Virtual disk",
      "size": "16.00 GiB",
      "size_bytes": 17179869184,
      "type": "hdd",
      "vendor": "VMware"
    },
    "sr0": {
      "model": "VMware SATA CD00",
      "size": "1.00 GiB",
      "size_bytes": 1073741312,
      "type": "hdd",
      "vendor": "NECVMWar"
    }
  },
  "dmi": {
    "bios": {
      "release_date": "12/12/2018",
      "vendor": "Phoenix Technologies LTD",
      "version": "6.00"
    },
    "board": {
      "manufacturer": "Intel Corporation",
      "product": "440BX Desktop Reference Platform",
      "serial_number": "None"
    },
    "chassis": {
      "asset_tag": "No Asset Tag",
      "type": "Other"
    },
    "manufacturer": "VMware, Inc.",
    "product": {
      "name": "VMware Virtual Platform",
      "serial_number": "VMware-42 2c f9 6e 36 77 8a f9-42 ea 64 01 82 62 bc 16",
      "uuid": "6EF92C42-7736-F98A-42EA-64018262BC16"
    }
  },
  "efi": false,
  "ethtool": {
    "ens192": {
      "auto_negotiation": "false",
      "duplex": "full",
      "link": "true",
      "port": "Twisted Pair",
      "speed": "10000",
      "wol": false
    },
    "lo": {
      "link": "true"
    }
  },
  "facterversion": "4.0.44",
  "filesystems": "ext2,ext3,ext4,iso9660,squashfs",
  "fips_enabled": false,
  "hypervisors": {
    "vmware": {
      "version": "ESXi 6.7"
    }
  },
  "identity": {
    "gid": 0,
    "group": "root",
    "privileged": true,
    "uid": 0,
    "user": "root"
  },
  "is_virtual": "true",
  "kernel": "Linux",
  "kernelmajversion": "3.10",
  "kernelrelease": "3.10.0-1160.11.1.el7.x86_64",
  "kernelversion": "3.10.0",
  "lib": "/usr/share/fdi/facts:/opt/extension/facts",
  "lldp_neighbor_chassisid_ens192": null,
  "lldp_neighbor_mngaddr_ipv4_ens192": null,
  "lldp_neighbor_mngaddr_ipv6_ens192": null,
  "lldp_neighbor_mtu_ens192": null,
  "lldp_neighbor_portid_ens192": null,
  "lldp_neighbor_pvid_ens192": null,
  "lldp_neighbor_sysname_ens192": null,
  "load_averages": {
    "15m": 0.05,
    "1m": 0.0,
    "5m": 0.03
  },
  "memory": {
    "system": {
      "available": "3.33 GiB",
      "available_bytes": 3580538880,
      "capacity": "13.56%",
      "total": "3.86 GiB",
      "total_bytes": 4142460928,
      "used": "535.89 MiB",
      "used_bytes": 561922048
    }
  },
  "networking": {
    "domain": "install.pox.com",
    "fqdn": "fdi.install.pox.com",
    "hostname": "fdi",
    "interfaces": {
      "ens192": {
        "bindings": [
          {
            "address": "10.28.236.10",
            "netmask": "255.255.255.0",
            "network": "10.28.236.0"
          }
        ],
        "bindings6": [
          {
            "address": "fe80::250:56ff:feac:18b6",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "dhcp": "10.28.236.3",
        "mac": "00:50:56:ac:18:b6",
        "mtu": 1500,
        "scope6": "link"
      },
      "lo": {
        "bindings": [
          {
            "address": "127.0.0.1",
            "netmask": "255.0.0.0",
            "network": "127.0.0.0"
          }
        ],
        "bindings6": [
          {
            "address": "::1",
            "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
            "network": "::1"
          }
        ],
        "mtu": 65536,
        "scope6": "host"
      }
    }
  },
  "nmprimary_802-3-ethernet_auto-negotiate": "no",
  "nmprimary_802-3-ethernet_cloned-mac-address": "",
  "nmprimary_802-3-ethernet_duplex": "",
  "nmprimary_802-3-ethernet_generate-mac-address-mask": "",
  "nmprimary_802-3-ethernet_mac-address": "00:50:56:AC:18:B6",
  "nmprimary_802-3-ethernet_mac-address-blacklist": "",
  "nmprimary_802-3-ethernet_mtu": "auto",
  "nmprimary_802-3-ethernet_port": "",
  "nmprimary_802-3-ethernet_s390-nettype": "",
  "nmprimary_802-3-ethernet_s390-options": "",
  "nmprimary_802-3-ethernet_s390-subchannels": "",
  "nmprimary_802-3-ethernet_speed": "0",
  "nmprimary_802-3-ethernet_wake-on-lan": "default",
  "nmprimary_802-3-ethernet_wake-on-lan-password": "",
  "nmprimary_connection_auth-retries": "-1",
  "nmprimary_connection_autoconnect": "yes",
  "nmprimary_connection_autoconnect-priority": "1",
  "nmprimary_connection_autoconnect-retries": "-1",
  "nmprimary_connection_autoconnect-slaves": "-1",
  "nmprimary_connection_gateway-ping-timeout": "0",
  "nmprimary_connection_id": "primary",
  "nmprimary_connection_interface-name": "",
  "nmprimary_connection_lldp": "default",
  "nmprimary_connection_llmnr": "-1",
  "nmprimary_connection_master": "",
  "nmprimary_connection_mdns": "-1",
  "nmprimary_connection_metered": "unknown",
  "nmprimary_connection_multi-connect": "0",
  "nmprimary_connection_permissions": "",
  "nmprimary_connection_read-only": "no",
  "nmprimary_connection_secondaries": "",
  "nmprimary_connection_slave-type": "",
  "nmprimary_connection_stable-id": "",
  "nmprimary_connection_timestamp": "1612539016",
  "nmprimary_connection_type": "802-3-ethernet",
  "nmprimary_connection_uuid": "a4a73866-67c5-11eb-b420-005056ac18b6",
  "nmprimary_connection_zone": "",
  "nmprimary_dhcp4_option_broadcast_address": "10.28.236.255",
  "nmprimary_dhcp4_option_dhcp_lease_time": "43200",
  "nmprimary_dhcp4_option_dhcp_message_type": "5",
  "nmprimary_dhcp4_option_dhcp_server_identifier": "10.28.236.3",
  "nmprimary_dhcp4_option_domain_name": "install.pox.com",
  "nmprimary_dhcp4_option_domain_name_servers": "10.28.236.3",
  "nmprimary_dhcp4_option_expiry": "1612581618",
  "nmprimary_dhcp4_option_filename": "pxelinux.0",
  "nmprimary_dhcp4_option_fqdn": null,
  "nmprimary_dhcp4_option_ip_address": "10.28.236.10",
  "nmprimary_dhcp4_option_network_number": "10.28.236.0",
  "nmprimary_dhcp4_option_next_server": "10.28.236.3",
  "nmprimary_dhcp4_option_requested_broadcast_address": "1",
  "nmprimary_dhcp4_option_requested_classless_static_routes": "1",
  "nmprimary_dhcp4_option_requested_domain_name": "1",
  "nmprimary_dhcp4_option_requested_domain_name_servers": "1",
  "nmprimary_dhcp4_option_requested_domain_search": "1",
  "nmprimary_dhcp4_option_requested_host_name": "1",
  "nmprimary_dhcp4_option_requested_interface_mtu": "1",
  "nmprimary_dhcp4_option_requested_ms_classless_static_routes": "1",
  "nmprimary_dhcp4_option_requested_nis_domain": "1",
  "nmprimary_dhcp4_option_requested_nis_servers": "1",
  "nmprimary_dhcp4_option_requested_ntp_servers": "1",
  "nmprimary_dhcp4_option_requested_rfc3442_classless_static_routes": "1",
  "nmprimary_dhcp4_option_requested_root_path": "1",
  "nmprimary_dhcp4_option_requested_routers": "1",
  "nmprimary_dhcp4_option_requested_static_routes": "1",
  "nmprimary_dhcp4_option_requested_subnet_mask": "1",
  "nmprimary_dhcp4_option_requested_time_offset": "1",
  "nmprimary_dhcp4_option_requested_wpad": "1",
  "nmprimary_dhcp4_option_subnet_mask": "255.255.255.0",
  "nmprimary_general_con-path": "/org/freedesktop/NetworkManager/Settings/1",
  "nmprimary_general_dbus-path": "/org/freedesktop/NetworkManager/ActiveConnection/1",
  "nmprimary_general_default": "no",
  "nmprimary_general_default6": "no",
  "nmprimary_general_devices": "ens192",
  "nmprimary_general_master-path": "",
  "nmprimary_general_name": "primary",
  "nmprimary_general_spec-object": "",
  "nmprimary_general_state": "activated",
  "nmprimary_general_uuid": "a4a73866-67c5-11eb-b420-005056ac18b6",
  "nmprimary_general_vpn": "no",
  "nmprimary_general_zone": "",
  "nmprimary_ip4_address": "10.28.236.10/24",
  "nmprimary_ip4_dns": "10.28.236.3",
  "nmprimary_ip4_domain": "install.pox.com",
  "nmprimary_ip4_gateway": "",
  "nmprimary_ip4_route": "dst = 10.28.236.0/24, nh = 0.0.0.0, mt = 100",
  "nmprimary_ip6_address": "fe80::250:56ff:feac:18b6/64",
  "nmprimary_ip6_gateway": "",
  "nmprimary_ip6_route": "dst = fe80::/64, nh = ::, mt = 100",
  "nmprimary_ipv4_addresses": "",
  "nmprimary_ipv4_dad-timeout": "-1",
  "nmprimary_ipv4_dhcp-client-id": "",
  "nmprimary_ipv4_dhcp-fqdn": "",
  "nmprimary_ipv4_dhcp-hostname": "",
  "nmprimary_ipv4_dhcp-send-hostname": "no",
  "nmprimary_ipv4_dhcp-timeout": "300",
  "nmprimary_ipv4_dns": "",
  "nmprimary_ipv4_dns-options": " ",
  "nmprimary_ipv4_dns-priority": "0",
  "nmprimary_ipv4_dns-search": "",
  "nmprimary_ipv4_gateway": "",
  "nmprimary_ipv4_ignore-auto-dns": "no",
  "nmprimary_ipv4_ignore-auto-routes": "no",
  "nmprimary_ipv4_may-fail": "yes",
  "nmprimary_ipv4_method": "auto",
  "nmprimary_ipv4_never-default": "no",
  "nmprimary_ipv4_route-metric": "-1",
  "nmprimary_ipv4_route-table": "0",
  "nmprimary_ipv4_routes": "",
  "nmprimary_ipv4_routing-rules": "",
  "nmprimary_ipv6_addr-gen-mode": "eui64",
  "nmprimary_ipv6_addresses": "",
  "nmprimary_ipv6_dhcp-duid": "",
  "nmprimary_ipv6_dhcp-hostname": "",
  "nmprimary_ipv6_dhcp-send-hostname": "yes",
  "nmprimary_ipv6_dns": "",
  "nmprimary_ipv6_dns-options": " ",
  "nmprimary_ipv6_dns-priority": "0",
  "nmprimary_ipv6_dns-search": "",
  "nmprimary_ipv6_gateway": "",
  "nmprimary_ipv6_ignore-auto-dns": "no",
  "nmprimary_ipv6_ignore-auto-routes": "no",
  "nmprimary_ipv6_ip6-privacy": "-1",
  "nmprimary_ipv6_may-fail": "yes",
  "nmprimary_ipv6_method": "auto",
  "nmprimary_ipv6_never-default": "no",
  "nmprimary_ipv6_route-metric": "-1",
  "nmprimary_ipv6_route-table": "0",
  "nmprimary_ipv6_routes": "",
  "nmprimary_ipv6_routing-rules": "",
  "nmprimary_ipv6_token": "",
  "nmprimary_proxy_browser-only": "no",
  "nmprimary_proxy_method": "none",
  "nmprimary_proxy_pac-script": "",
  "nmprimary_proxy_pac-url": "",
  "nmprimary_ptr": null,
  "nmprimary_vlan_egress-priority-map": "",
  "nmprimary_vlan_flags": "1",
  "nmprimary_vlan_id": "0",
  "nmprimary_vlan_ingress-priority-map": "",
  "nmprimary_vlan_parent": "",
  "os": {
    "architecture": "x86_64",
    "family": "RedHat",
    "hardware": "x86_64",
    "name": "CentOS",
    "release": {
      "full": "7.9.2009",
      "major": "7",
      "minor": "9"
    },
    "selinux": {
      "enabled": true
    }
  },
  "partitions": {
    "/dev/loop0": {
      "backing_file": "/fdi.iso (deleted)",
      "filesystem": "iso9660",
      "label": "CDROM",
      "size": "226.22 MiB",
      "size_bytes": 237211648,
      "uuid": "2021-01-22-12-40-51-00"
    },
    "/dev/loop1": {
      "backing_file": "/run/initramfs/live/LiveOS/squashfs.img",
      "filesystem": "squashfs",
      "size": "225.86 MiB",
      "size_bytes": 236834816
    },
    "/dev/loop2": {
      "backing_file": "/LiveOS/ext3fs.img",
      "filesystem": "ext4",
      "label": "_fdi",
      "size": "1.56 GiB",
      "size_bytes": 1677721600,
      "uuid": "c6918a11-44b8-4659-bc52-19f8aa7fc43a"
    },
    "/dev/loop3": {
      "backing_file": "/overlay (deleted)",
      "filesystem": "DM_snapshot_cow",
      "size": "512.00 MiB",
      "size_bytes": 536870912
    },
    "/dev/loop4": {
      "backing_file": "/dev/dm-0",
      "filesystem": "ext4",
      "label": "_fdi",
      "size": "1.56 GiB",
      "size_bytes": 1677721600,
      "uuid": "c6918a11-44b8-4659-bc52-19f8aa7fc43a"
    },
    "/dev/mapper/live-base": {
      "filesystem": "ext4",
      "label": "_fdi",
      "size": "1.56 GiB",
      "size_bytes": 1677721600,
      "uuid": "c6918a11-44b8-4659-bc52-19f8aa7fc43a"
    },
    "/dev/mapper/live-rw": {
      "filesystem": "ext4",
      "label": "_fdi",
      "size": "1.56 GiB",
      "size_bytes": 1677721600,
      "uuid": "c6918a11-44b8-4659-bc52-19f8aa7fc43a"
    }
  },
  "path": "/opt/rh/rh-ruby25/root/usr/local/bin:/opt/rh/rh-ruby25/root/usr/bin:/opt/theforeman/tfm/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/extension/bin:/root/bin",
  "processors": {
    "count": 2,
    "isa": "x86_64",
    "models": [
      "Intel(R) Xeon(R) CPU E5-2667 v2 @ 3.30GHz",
      "Intel(R) Xeon(R) CPU E5-2667 v2 @ 3.30GHz"
    ],
    "physicalcount": 2,
    "speed": "3.29 GHz"
  },
  "ruby": {
    "platform": "x86_64-linux",
    "sitedir": "/opt/rh/rh-ruby25/root/usr/local/share/ruby/site_ruby",
    "version": "2.5.5"
  },
  "ssh": {
    "ecdsa": {
      "fingerprints": {
        "sha1": "SSHFP 3 1 382f7d62d396fe559091f00b3320c6b56cbe065d",
        "sha256": "SSHFP 3 2 b97ddd80dc08d2f6ddee3ad3beac5da8ce496c0eb47b09d4257f401e9934b4b2"
      },
      "key": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHaX110SuKwYBujV1b9zOhqo7KwGKzhPyZ+QxmJceEVaHY1hogYIhwJt+xsWdPLwUnMP8EXcnpXE4XqkQsTP89c=",
      "type": "ecdsa-sha2-nistp256"
    },
    "ed25519": {
      "fingerprints": {
        "sha1": "SSHFP 4 1 a0a9def0b18b71ce44033494826b96ea7a8c60b2",
        "sha256": "SSHFP 4 2 4428936d012dcde334ef8ff9be7bc3db66ecee2dba2cac229c6e5a4514dbd1ec"
      },
      "key": "AAAAC3NzaC1lZDI1NTE5AAAAIHS5cgBXViocE769MH9e74Wl7Emo75Z0ZNvv87SMvlmd",
      "type": "ssh-ed25519"
    },
    "rsa": {
      "fingerprints": {
        "sha1": "SSHFP 1 1 da8a9b006002c9cb4e4c4b9da91cbe22f4b59cf1",
        "sha256": "SSHFP 1 2 fbf82405fbba9423e65f3e3625b3657a71033786500c8f33d2c5d36656c74c2b"
      },
      "key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQD9YqhFRT8rgUIuP7voCwwVdbZIcC5l8MRreJFSFrmyWsAL5RKsgtVUrj2+kbYNLY53LPKDdZpdUlmzl6WxrcsIEF2NC7l436/kMPE0e3ofd6tPvV2VVSS8L+UlhmtUBzrmOg5SYImwJwnv5RDdFcMOiIISWvvnut0WM6IU8zG9mOz+kGfQxEztjydV/UDe99syc1WmDP3O/qfatTlrp4E9Ec3vas0wPN+ZFwG49to/0tP1Rj+POpf8V61NXii6qK2flsW0kGdqvjjp3QQXO/OAoWJkT96xvPHA8d58szg7HYycpGtoPwIQSMzoV+cYFfYCT+Y6BTvT5KfiDMAAI199",
      "type": "ssh-rsa"
    }
  },
  "system_uptime": {
    "days": 0,
    "hours": 0,
    "seconds": 661,
    "uptime": "0:11 hours"
  },
  "timezone": "UTC",
  "virtual": "vmware"
}

I have some bad news, discovery with facter 4.x seems to be not compatible with our primary interface parsing code both in core and in discovery plugin.

https://projects.theforeman.org/issues/31826

It’s completely broken, you can workaround this using an older version of discovery which still has facter 0.2x. Let me know which version did work for you.

I would like to correct this. It is only the discovery image 3.7 that is causing the above issue in their configuration.

I can confirm that
Foreman 2.3.2
Discovery 16.3.4
w/ Discovery Image 3.7

causes the above issue. However, downgrading only Discovery Image to 3.5 resolves this issue. This is a significantly easier fix than downgrading the discovery plugin as a whole.

The following command from here resolves the above issue: Foreman :: Plugin Manuals

wget http://downloads.theforeman.org/discovery/releases/3.5/fdi-image-latest.tar \
-O - | tar x --overwrite -C /var/lib/tftpboot/boot
1 Like

Addendum. You may need to clean your foreman discovery MAC address cache. Apparently when the above issue occurs, the host gets partially registered prior to failure, which causes foreman to respond with “name already taken” but there are no hosts present. I haven’t bothered to look at exactly which section causes this, but if you can cycle your mac address on the machine you can do that.

For some technical reasons we can’t use SQL transactions during discovery, when a host fails to be discovered it stays in the database in an incorrect state (usually without any taxonomy set). Then it’s causing those issues.

Some transaction compensation should be implemented deleting the unfinished host.

Thanks for confirmation, this really looks like upgrade to facter4 causes the problem.

FYI: that contained facter 2.x, not 0.2x.

Facter 4 can produce the legacy facts, but doesn’t by default:
scl enable tfm -- facter --json --show-legacy

However, from a code perspective it looks like it does enable them by default

require 'facter'
fail unless Facter.to_hash.include?("interfaces")
Facter::Options[:show_legacy] = true
fail unless Facter.to_hash.include?("interfaces")

Where did you take this code from? I don’t think we have that in the FDI right now. That could be a nice workaround until we finalize fact parsing in core.

Oh I get it now, you say it does send them by default.

Well I think the problem might be in fact that “interfaces” was previously list of device names, now it’s a hash.

I took a quick look through GitHub - puppetlabs/facter-ng: Collect and display system facts and grepped for legacy.

Indeed

interfaces is a a string. networking.interfaces is a hash.

Hello,
Tried the 3.5 and now got this

I’m trying to cycle or it or to remove from the database (don’t know for know how to do it).

Switch to Any Org - Any Loc and you should see those discovered hosts. Delete them.

I will prepare a core PR to recognize this difference.

Okay I think the problem is that Facter 4.x no longer provides networking->ip and ip6 facts. This is what we have in our test suite for Facter 3.x:

    "networking": {
      "dhcp": "10.10.1.2",
      "domain": "dmz-ext.example.org",
      "fqdn": "freckles.dmz-ext.example.org",
      "hostname": "freckles",
      "interfaces": {

      },
      "ip": "10.10.254.25",
      "ip6": "fe80::250:56ff:fe93:96d",
      "mac": "00:50:56:93:09:6d",
      "mtu": 1500,
      "netmask": "255.255.255.0",
      "netmask6": "ffff:ffff:ffff:ffff::",
      "network": "10.10.254.0",
      "network6": "fe80::",
      "primary": "ens160",
      "scope6": "link"
    },

However the example that OP posted does not contain it at all:

  "networking": {
    "domain": "example.com",
    "fqdn": "fdi.example.com",
    "hostname": "fdi",
    "interfaces": {
      "ens192": {
        "bindings": [
        ],
        "mtu": 65536,
        "scope6": "host"
      }
    }

It’s weird because when I run Facter 4.x locally, I do see networking->ip or ip6 facts myself. I don’t know why it’s not reported on the FDI. Need to try to boot an FDI.