Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1528377

Summary: subscription-manager register mixed case interface enPxpxsxfx facts missing mac address
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: FactAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Radovan Drazny <rdrazny>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2.12CC: inecas, mhulan
Target Milestone: UnspecifiedKeywords: 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: 2019-06-05 14:35:53 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:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2017-12-21 16:23:49 UTC
Description of problem:
See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-understanding_the_predictable_network_interface_device_names that also enPxpxsxfx is a correct interface name

Puppet (and there also Foreman) normilazes interface names to be always lowercase.

This is lowercasing of interface names is not done in the subscription-manager facts, see below real world output:

--------------
vrempet@li-lc-1876 ~
$ sudo subscription-manager facts | grep -E 'net.interface.(en)'
net.interface.enP3p1s0f0.mac_address: 00:E0:ED:72:18:A4
net.interface.enP3p1s0f0.permanent_mac_address: 00:E0:ED:72:18:A4
net.interface.enP3p1s0f1.mac_address: 00:E0:ED:72:18:A5
...
--------------

When Foreman is parsing the facts it uses the normalized (lowercased) name to index the subscription-manager facts to retrieve ip address and mac address.
For the mac address this is a critical failure, because it is the unique indexing useed in Foreman. In case of not matching case a nil value is returned and a record with empty mac address is created.

Later then when puppet uploads its facts report a duplicate entry is created with a valid mac address. Which later in a validation process will give failures because of the duplicate identifier name



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:

1. Prepare facts of to simulate the complex interface names:
echo <<EOF > /etc/rhsm/facts/net.facts
{
  "net.interface.enP3p3s0f0.mac_address": "00:E0:ED:57:1F:04",
  "net.interface.enP3p3s0f1.ipv4_address": "192.168.2.1",
  "net.interface.enP3p3s0f1.ipv4_broadcast": "192.168.2.255",
  "net.interface.enP3p3s0f1.ipv4_netmask": 24,
  "net.interface.enP3p3s0f1.mac_address": "00:E0:ED:57:1F:05",
  "net.interface.enP3p4s0f0.mac_address": "00:E0:ED:6F:1E:84",
  "net.interface.enP3p4s0f1.mac_address": "00:E0:ED:57:2B:F4"
}
EOF
sudo subscription-manager facts | grep -E 'net.interface.(en)'

2. Re-register: sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
3. Check sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=

Actual results:
Empty mac address for interface enPxpxsxfx
Only 1 enPxpxsxfx interface instead of 4

Expected results:
4 enPxpxsxfx interfaces with correct mac address

Additional info:
Ofcourse we can also discuss that fact parsing shall never be allowed to insert a row with a duplicate identifier that at other stages will create a validation failure. But that is an additional improvement

Comment 1 Peter Vreman 2017-12-21 16:27:42 UTC
Patch for 6.3Beta, on top of my other BZ https://bugzilla.redhat.com/show_bug.cgi?id=1528193 to fix bond slaves:

--- /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.25/app/models/katello/rhsm_fact_parser.rb.171221-2       2017-12-21 09:42:52.734316952 +0000
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.25/app/models/katello/rhsm_fact_parser.rb        2017-12-21 16:11:25.214453420 +0000
@@ -21,16 +21,18 @@
     end

     def get_facts_for_interface(interface)
+      # interface passed is normalized to lowercase, the rhsm fact can be mixed case, e.g. enPxpxsxfx
+      interfacekey=facts.keys.select { |f| f =~ /net\.interface\.#{interface}\.mac_address/i }.first().sub('net.interface.', '').sub('.mac_address', '')
       # if slave then permanent_mac_address contains the physical mac
-      if facts.has_key?("net.interface.#{interface}.permanent_mac_address")
-        mackey="net.interface.#{interface}.permanent_mac_address"
+      if facts.has_key?("net.interface.#{interfacekey}.permanent_mac_address")
+        mackey="net.interface.#{interfacekey}.permanent_mac_address"
       else
-        mackey="net.interface.#{interface}.mac_address"
+        mackey="net.interface.#{interfacekey}.mac_address"
       end
       {
         'link' => true,
         'macaddress' => facts[mackey],
-        'ipaddress' => get_rhsm_ip(interface)
+        'ipaddress' => get_rhsm_ip(interfacekey)
       }
     end

Comment 2 Peter Vreman 2017-12-21 16:32:14 UTC
Using the net.facts from above on a regular VM without patch gives:

[Unknown Hilti Tier] root@li-lc-1578:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=li-lc-1442.hag.hilti.com
----|------------|--------------------------------|-------------------|---------------|-------------------------
ID  | IDENTIFIER | TYPE                           | MAC ADDRESS       | IP ADDRESS    | DNS NAME
----|------------|--------------------------------|-------------------|---------------|-------------------------
56  | eth1       | interface                      | 00:50:56:97:4c:ee | 192.168.123.3 |
55  | eth0       | interface (primary, provision) | 00:50:56:97:74:4b | 10.92.14.90   | li-lc-1442.hag.hilti.com
57  | eth2       | interface                      | 00:50:56:97:48:50 |               |
664 | enp3p3s0f1 | interface                      |                   |               |
----|------------|--------------------------------|-------------------|---------------|-------------------------


With patch:

[Unknown Hilti Tier] root@li-lc-1578:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=li-lc-1442.hag.hilti.com
----|------------|--------------------------------|-------------------|---------------|-------------------------
ID  | IDENTIFIER | TYPE                           | MAC ADDRESS       | IP ADDRESS    | DNS NAME
----|------------|--------------------------------|-------------------|---------------|-------------------------
668 | enp3p4s0f1 | interface                      | 99:99:ed:57:2b:f4 |               |
669 | enp3p4s0f0 | interface                      | 99:99:ed:6f:1e:84 |               |
56  | eth1       | interface                      | 00:50:56:97:4c:ee | 192.168.123.3 |
55  | eth0       | interface (primary, provision) | 00:50:56:97:74:4b | 10.92.14.90   | li-lc-1442.hag.hilti.com
670 | enp3p3s0f0 | interface                      | 99:99:ed:57:1f:04 |               |
57  | eth2       | interface                      | 00:50:56:97:48:50 |               |
671 | enp3p3s0f1 | interface                      | 99:99:ed:57:1f:05 | 192.168.2.1   |
----|------------|--------------------------------|-------------------|---------------|-------------------------
[Unknown Hilti Tier] root@li-lc-1578:~#

Comment 3 Peter Vreman 2017-12-22 07:02:37 UTC
Patch for 6.2.z

--- $ktdir/app/models/katello/rhsm_fact_parser.rb
+++ $ktdir/app/models/katello/rhsm_fact_parser.rb
@@ -20,16 +20,18 @@
     end

     def get_facts_for_interface(interface)
+      # interface passed is normalized to lowercase, the rhsm fact can be mixed case, e.g. enPxpxsxfx
+      interfacekey=facts.keys.select { |f| f =~ /net\.interface\.#{interface}\.mac_address/i }.first().sub('net.interface.', '').sub('.mac_address', '')
       # if slave then permanent_mac_address contains the physical mac
-      if facts.has_key?("net.interface.#{interface}.permanent_mac_address")
-        mackey="net.interface.#{interface}.permanent_mac_address"
+      if facts.has_key?("net.interface.#{interfacekey}.permanent_mac_address")
+        mackey="net.interface.#{interfacekey}.permanent_mac_address"
       else
-        mackey="net.interface.#{interface}.mac_address"
+        mackey="net.interface.#{interfacekey}.mac_address"
       end
       {
         'link' => true,
         'macaddress' => facts[mackey],
-        'ipaddress' => facts["net.interface.#{interface}.ipv4_address"]
+        'ipaddress' => facts["net.interface.#{interfacekey}.ipv4_address"]
       }
     end

Comment 5 Beat Rubischon 2017-12-28 12:54:32 UTC
Steps to Reproduce:

1. provision a simple VM
2. Edit /etc/sysconfig/grub, add "net.ifnames=0 biosdevname=0" to GRUB_CMDLINE_LINUX
3. Rename /etc/sysconfig/network-scripts/ifcfg-eth0 to ifcfg-enP3p1s0f0, change interface names and add correct MAC address

-NAME="eth0"
+NAME="enP3p1s0f0"
-DEVICE="eth0"
+DEVICE="eth0"
+HWADDR="00:00:00:00:00:01"

4. reboot
5. register host to Satellite
6. Check interface page after Puppet run

Comment 7 Peter Vreman 2019-06-05 14:35:53 UTC
With 6.5.0 the problem is gone due with the facter structured data reporting correctly interface names using Uppercase letters