Bug 1528193 - subscription-manager register facts create duplicate interface with wrong mac for bond
Summary: subscription-manager register facts create duplicate interface with wrong mac...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Provisioning
Version: 6.2.12
Hardware: All
OS: Linux
high
high
Target Milestone: 6.7.0
Assignee: satellite6-bugs
QA Contact: Roman Plevka
URL:
Whiteboard:
: 1743432 (view as bug list)
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2017-12-21 09:02 UTC by Peter Vreman
Modified: 2023-10-06 17:42 UTC (History)
10 users (show)

Fixed In Version: tfm-rubygem-katello-3.14.0-0.4.rc2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:22:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 28036 0 High Closed subscription-manager register facts creates duplicate interface with wrong mac for bond 2021-01-22 14:01:25 UTC
Red Hat Product Errata RHSA-2020:1454 0 None None None 2020-04-14 13:22:43 UTC

Internal Links: 2077757

Description Peter Vreman 2017-12-21 09:02:42 UTC
Description of problem:
When subscription-manager (re)registers it will update the hosts interfaces from the subscription-manager facts. When the host has a bond with physical slaves the subscription-manger facts contain in the field mac_address the 'virtual' mac address of the bond (being the mac of the primary interface). The real physical mac address of the interface is in field permanent_mac_address. 

The puppet facts always the permanent mac address in the mac_address field.

The rhsm fact parser only uses the field mac_address and creates the interface with this virtual mac. This results either of the following problems:
- duplicate interface created for the slave with the new mac address of the primary. Where puppet has created the slave with the correct permanent address
- omits one of the interfaces, because it renames the existing interface that has the same mac address

This is all independent if the host is already pre-created in Sat6. It also happens on re-registration using e.g. 'subscription-manager register --force'



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


How reproducible:


Steps to Reproduce:
1. Create Client with a bond0 interface
2. (Optional) Create host in Sat6
3. Client: Register using subscription-manager register --org=.. --actkey=..
4. Sat6: Dump interfaces: sudo -u hoici hammer host interface list --host=...
5. Client: Run Puppet to upload facts: puppet agent -t -v --tags=dummy
6. Sat6: Dump interfaces: sudo -u hoici hammer host interface list --host=...
7. Client: Re-Register using subscription-manager register --org=.. --actkey=.. --force
8. Sat6: Dump interfaces: sudo -u hoici hammer host interface list --host=...

Actual results:
In Step 4 not all slaves are included
In Step 5 a duplicate identifier of a slave might exists, one with the mac of the bond0 (added by s-m facts) and the other with the permanent mac (added by 
puppet facts)
Step 7 might fail with 'invalid interfaces error'
In Step 8 a duplicate identifier of a slave might exists, one with the mac of the bond0 (added by s-m facts) and the other with the permanent mac (added by 
puppet facts)

Expected results:
Subscription-manager parsed facts correctly adds slave interfaces with physical address

Additional info:

Comment 1 Peter Vreman 2017-12-21 09:03:44 UTC
Start situation: 
- Host is correctly added and has puppet facts correctly parsed

Failures:
- subscription-manager does nto create interface ens4f1
- subscription-manager creates a duplicate ens7f1 interface with incorrect MAC address

Input facts:
-----------------------------------------------------------------
	  
vrempet@li-lc-1681 ~
$ sudo facter -p | grep -E '(interfaces|mac)'
interfaces => bond0,bond0_107,ens4f0,ens4f1,ens7f0,ens7f1,lo
macaddress => 1c:98:ec:61:83:30
macaddress_bond0 => 1c:98:ec:61:83:30
macaddress_bond0_107 => 1c:98:ec:61:83:30
macaddress_ens4f0 => 1c:98:ec:61:83:28
macaddress_ens4f1 => 1C:98:EC:61:83:30
macaddress_ens7f0 => 1c:98:ec:61:24:28
macaddress_ens7f1 => 1C:98:EC:61:24:30

vrempet@li-lc-1681 ~
$ sudo subscription-manager facts | grep -E 'net.interface.(bond|ens)'
net.interface.bond0.107.ipv4_address: 10.92.14.169
net.interface.bond0.107.ipv4_address_list: 10.92.14.169
net.interface.bond0.107.ipv4_broadcast: 10.92.14.255
net.interface.bond0.107.ipv4_broadcast_list: 10.92.14.255
net.interface.bond0.107.ipv4_netmask: 24
net.interface.bond0.107.ipv4_netmask_list: 24
net.interface.bond0.107.mac_address: 1C:98:EC:61:83:30
net.interface.bond0.mac_address: 1C:98:EC:61:83:30
net.interface.ens4f0.mac_address: 1C:98:EC:61:83:28
net.interface.ens4f1.mac_address: 1C:98:EC:61:83:30
net.interface.ens4f1.permanent_mac_address: 1C:98:EC:61:83:30
net.interface.ens7f0.mac_address: 1C:98:EC:61:24:28
net.interface.ens7f1.mac_address: 1C:98:EC:61:83:30
net.interface.ens7f1.permanent_mac_address: 1C:98:EC:61:24:30
...
-----------------------------------------------------------------

-----------------------------------------------------------------
[crash/LI] root@li-lc-1017:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hosts/207/interfaces | jq . | grep -E '(identifier|mac)'
      "identifier": "bond0",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "ens4f0",
      "mac": "1c:98:ec:61:83:28",
      "identifier": "ens7f0",
      "mac": "1c:98:ec:61:24:28",
      "identifier": "ens7f1",
      "mac": "1c:98:ec:61:24:30",
      "identifier": "bond0.202",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "bond0.402",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "bond0.107",
      "mac": "1c:98:ec:61:83:30",

////////////////////// Client //////////////////////
vrempet@li-lc-1681 ~
$ sudo subscription-manager clean
All local data removed

vrempet@li-lc-1681 ~
$ sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
The system has been registered with ID: 5ef4483a-0da9-4599-b63f-7177fd51c7a3
...
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed
//////////////////////

	  
[crash/LI] root@li-lc-1017:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hosts/207/interfaces | jq . | grep -E '(identifier|mac)'
      "identifier": "ens7f1",             <--------------- DUPLICATE 'ens7f1'
      "mac": "1c:98:ec:61:83:30",         <--------------- INCORRECT MAC from Bond0 instead of PermanentMAC
      "identifier": "bond0",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "ens4f0",
      "mac": "1c:98:ec:61:83:28",
      "identifier": "ens7f0",
      "mac": "1c:98:ec:61:24:28",
      "identifier": "ens7f1",             <----- This was created correctly with Puppet before
      "mac": "1c:98:ec:61:24:30",
      "identifier": "bond0.202",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "bond0.402",
      "mac": "1c:98:ec:61:83:30",
      "identifier": "bond0.107",
      "mac": "1c:98:ec:61:83:30",
                   <--------------- MISSING 'ens4f1' (overridden by the incorrect ens7f1)
-----------------------------------------------------------------

Comment 2 Peter Vreman 2017-12-21 09:05:10 UTC
Patch for the rhsm fact parser to prefer permanent_mac_address if it exists:

[crash/LI] root@li-lc-1017:/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.157/app# diff -u ./models/katello/rhsm_fact_parser.rb.171220-1 ./models/katello/rhsm_fact_parser.rb
--- ./models/katello/rhsm_fact_parser.rb.171220-1       2017-10-10 09:31:26.000000000 +0000
+++ ./models/katello/rhsm_fact_parser.rb        2017-12-20 20:02:33.695692075 +0000
@@ -20,9 +20,15 @@
     end

     def get_facts_for_interface(interface)
+      # 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"
+      else
+        mackey="net.interface.#{interface}.mac_address"
+      end
       {
         'link' => true,
-        'macaddress' => facts["net.interface.#{interface}.mac_address"],
+        'macaddress' => facts[mackey],
         'ipaddress' => facts["net.interface.#{interface}.ipv4_address"]
       }
     end

Comment 3 Peter Vreman 2017-12-21 09:29:39 UTC
Before Patch:
-------------------
vrempet@li-lc-1681 ~
$ sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
The system has been registered with ID: 4b5a644d-2678-41cf-840e-6c6f3fadcd44

Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

[crash/LI] root@li-lc-1017:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------
ID   | IDENTIFIER | TYPE                           | MAC ADDRESS       | IP ADDRESS   | DNS NAME
-----|------------|--------------------------------|-------------------|--------------|-------------------------
1114 | ens7f1     | interface                      | 1c:98:ec:61:83:30 |              |
1115 | ens4f0     | interface                      | 1c:98:ec:61:83:28 |              |
1116 | ens7f1     | interface                      | 1c:98:ec:61:24:30 |              |
1117 | ens7f0     | interface                      | 1c:98:ec:61:24:28 |              |
980  | bond0      | bond                           | 1c:98:ec:61:83:30 |              |
981  | bond0.107  | interface (primary, provision) | 1c:98:ec:61:83:30 | 10.92.14.169 | li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------

vrempet@li-lc-1681 ~
$ sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
The system with UUID 4b5a644d-2678-41cf-840e-6c6f3fadcd44 has been unregistered
Validation failed: Interfaces some interfaces are invalid
-------------------

After Patch:

-------------------
[crash/LI] root@li-lc-1017:~# service foreman-tasks restart
Redirecting to /bin/systemctl restart foreman-tasks.service

vrempet@li-lc-1681 ~
$ sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
The system with UUID 78579c65-19ce-4593-a444-18d5f9518228 has been unregistered
The system has been registered with ID: 7694f421-719f-42df-82f4-62ea69a2e87b

Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

[crash/LI] root@li-lc-1017:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------
ID   | IDENTIFIER | TYPE                           | MAC ADDRESS       | IP ADDRESS   | DNS NAME
-----|------------|--------------------------------|-------------------|--------------|-------------------------
1115 | ens4f0     | interface                      | 1c:98:ec:61:83:28 |              |
1116 | ens7f1     | interface                      | 1c:98:ec:61:24:30 |              |
1117 | ens7f0     | interface                      | 1c:98:ec:61:24:28 |              |
1118 | ens4f1     | interface                      | 1c:98:ec:61:83:30 |              |
980  | bond0      | bond                           | 1c:98:ec:61:83:30 |              |
981  | bond0.107  | interface (primary, provision) | 1c:98:ec:61:83:30 | 10.92.14.169 | li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------
[crash/LI] root@li-lc-1017:~#

vrempet@li-lc-1681 ~
$ sudo subscription-manager register --org=`sudo facter -p foreman_organization` --name=`hostname -f` --activationkey=`sudo facter -p foreman_activationkey` --force
The system with UUID 7694f421-719f-42df-82f4-62ea69a2e87b has been unregistered
The system has been registered with ID: d9eafe49-5dd1-4bbf-ba6e-f0c3a07d4e0a

Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

[crash/LI] root@li-lc-1017:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml host interface list --host=li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------
ID   | IDENTIFIER | TYPE                           | MAC ADDRESS       | IP ADDRESS   | DNS NAME
-----|------------|--------------------------------|-------------------|--------------|-------------------------
1115 | ens4f0     | interface                      | 1c:98:ec:61:83:28 |              |
1116 | ens7f1     | interface                      | 1c:98:ec:61:24:30 |              |
1117 | ens7f0     | interface                      | 1c:98:ec:61:24:28 |              |
1118 | ens4f1     | interface                      | 1c:98:ec:61:83:30 |              |
980  | bond0      | bond                           | 1c:98:ec:61:83:30 |              |
981  | bond0.107  | interface (primary, provision) | 1c:98:ec:61:83:30 | 10.92.14.169 | li-lc-1681.hag.hilti.com
-----|------------|--------------------------------|-------------------|--------------|-------------------------
[crash/LI] root@li-lc-1017:~#
-------------------

Comment 4 Peter Vreman 2017-12-21 09:45:25 UTC
Patch for 6.3Beta

--- /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.25/app/models/katello/rhsm_fact_parser.rb.171221-1       2017-11-02 13:34:02.000000000 +0000
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.4.5.25/app/models/katello/rhsm_fact_parser.rb        2017-12-21 09:40:16.809615920 +0000
@@ -21,9 +21,15 @@
     end

     def get_facts_for_interface(interface)
+      # 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"
+      else
+        mackey="net.interface.#{interface}.mac_address"
+      end
       {
         'link' => true,
-        'macaddress' => facts["net.interface.#{interface}.mac_address"],
+        'macaddress' => facts[mackey],
         'ipaddress' => get_rhsm_ip(interface)
       }
     end

Comment 11 Jeremy Lenz 2019-10-10 16:41:33 UTC
Created redmine issue https://projects.theforeman.org/issues/28036 from this bug

Comment 12 Bryan Kearney 2019-11-04 14:02:03 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this, please do not reopen. Instead, feel free to contact Red Hat Technical Support. Thank you.

Comment 13 Peter Vreman 2019-11-04 14:21:33 UTC
Why is this closed. The customer even provides a small isolated patch that is proven to work in a customer environment for 2+ years.

Comment 17 Bryan Kearney 2019-11-05 20:28:26 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/28036 has been resolved.

Comment 20 Brad Buckingham 2019-11-06 18:45:15 UTC
Peter,

Apologies for the delay and miscommunication.  I had this bugzilla on my team's sprint and we've resolved it in the upstream for inclusion in future Satellite release.

Thanks!

Comment 24 Marek Hulan 2020-03-25 07:59:06 UTC
*** Bug 1743432 has been marked as a duplicate of this bug. ***

Comment 26 errata-xmlrpc 2020-04-14 13:22:23 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-2020:1454


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