Bug 2250397

Summary: Host registration fails with error "Attached to can't be blank" when the VLAN name includes UPPERCASE letters
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: FactAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: sganar
Severity: high Docs Contact:
Priority: high    
Version: 6.13.4CC: addubey, ahumbe, amasolov, gtalreja, lstejska, rlavi
Target Milestone: 6.15.0Keywords: EasyFix, Patch, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2257329 (view as bug list) Environment:
Last Closed: 2024-04-23 17:15:46 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:
Attachments:
Description Flags
Test results none

Description Sayan Das 2023-11-18 04:15:31 UTC
Description of problem:

This is kind of a repetition of https://bugzilla.redhat.com/show_bug.cgi?id=1766344 but under a bit different circumstances and only for VLAN tagged interfaces. 

And the bug affects either registration or interface creation upon facts uploaded from the content hosts.

To explain, Here in https://github.com/theforeman/foreman/blob/develop/app/services/fact_parser.rb#L7 the regex we use to identify VLAN interfaces is 

VLANS = /\A([a-z0-9]+)\.([0-9]+)\Z/

So, it will work as long as the vlan name is something like bond0.1 or datos.306.

But It will not be able to parse it properly if the vlan name would be something like Bond0.1 or Datos.306 i.e. in sentencecase or full uppercase. 

And this patch can fix the issue:

# git diff
diff --git a/app/services/fact_parser.rb b/app/services/fact_parser.rb
index 02dcbe0..473929c 100644
--- a/app/services/fact_parser.rb
+++ b/app/services/fact_parser.rb
@@ -4,7 +4,7 @@ class FactParser
   BRIDGES = /\A(vir|lxc)?br(\d+|-[a-z0-9]+)(_nic)?\Z/
   BONDS = /\A(bond\d+)\Z|\A(lagg\d+)\Z/
   ALIASES = /(\A[a-z0-9\.]+):([a-z0-9]+)\Z/
-  VLANS = /\A([a-z0-9]+)\.([0-9]+)\Z/
+  VLANS = /\A([a-zA-Z0-9]+)\.([0-9]+)\Z/
   VIRTUAL_NAMES = /#{ALIASES}|#{VLANS}|#{VIRTUAL}|#{BRIDGES}|#{BONDS}/
   # spend 500ms per IP on primary interface lookup
   PRIMARY_INTERFACE_RESOLVE_TIMEOUTS = [0.50]



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

Any supported version of satellite (I tested on 6.13.4 )


How reproducible:

100%


Steps to Reproduce:
1. Create a RHEL 8 system with just one normal interface ( ens192 ) and have an IP assigned to it.

2. Create the following file in that system:

# cat /etc/rhsm/facts/03588300.facts
{
 "net.interface.enp98s0f0.mac_address": "00:25:b5:04:00:b7",
 "net.interface.enp98s0f0.permanent_mac_address": "00:25:B5:04:00:B7",
 "net.interface.enp98s0f1.mac_address": "00:25:b5:04:00:b7",
 "net.interface.enp98s0f1.permanent_mac_address": "00:25:B5:04:00:B6",
 "net.interface.enp98s0f2.mac_address": "00:25:b5:04:00:b5",
 "net.interface.enp98s0f2.permanent_mac_address": "00:25:B5:04:00:B5",
 "net.interface.enp98s0f3.mac_address": "00:25:b5:04:00:b5",
 "net.interface.enp98s0f3.permanent_mac_address": "00:25:B5:04:00:B4",
 "net.interface.enp103s0f0.mac_address": "00:25:b5:04:00:b3",
 "net.interface.enp103s0f0.permanent_mac_address": "00:25:B5:04:00:B3",
 "net.interface.enp103s0f1.mac_address": "00:25:b5:04:00:b3",
 "net.interface.enp103s0f1.permanent_mac_address": "00:25:B5:04:00:B2",
 "net.interface.enp103s0f2.mac_address": "00:25:b5:04:00:b1",
 "net.interface.enp103s0f2.permanent_mac_address": "00:25:B5:04:00:B1",
 "net.interface.enp103s0f3.mac_address": "00:25:b5:04:00:b1",
 "net.interface.enp103s0f3.permanent_mac_address": "00:25:B5:04:00:B0",
 "net.interface.bondBK.134.mac_address": "00:25:b5:04:00:b7",
 "net.interface.bondDB.127.mac_address": "00:25:b5:04:00:b8",
 "net.interface.Datos.306.mac_address": "00:25:b5:04:00:b7",
 "net.interface.Datos.306.ipv4_address": "192.168.124.143",
 "net.interface.Datos.306.ipv4_address_list": "192.168.124.143, 192.168.124.144, 192.168.124.148, 192.168.124.149",
 "net.interface.Datos.306.ipv4_netmask": "24",
 "net.interface.Datos.306.ipv4_netmask_list": "24, 24, 24, 24",
 "net.interface.Datos.306.ipv4_broadcast": "192.168.124.255",
 "net.interface.Datos.306.ipv4_broadcast_list": "192.168.124.255, 192.168.124.255, 192.168.124.255, 192.168.124.255",
 "net.interface.Bond1.mac_address": "00:25:b5:04:00:b5",
 "net.interface.Bond3.mac_address": "00:25:b5:04:00:b1",
 "net.interface.HB2.399.mac_address": "00:25:b5:04:00:b1",
 "net.interface.Bond2.mac_address": "00:25:b5:04:00:b3",
 "net.interface.HB1.398.mac_address": "00:25:b5:04:00:b3",
 "net.interface.Robot.172.mac_address": "00:25:b5:04:00:b5"
}


3. Register the system with satellite while monitoring production.log in satellite server.


Actual results:

Step 3: 

Registration would fail with an error like this:

~~
HTTP error (422 - Unknown): Validation failed: Attached to can't be blank
~~

When all the active interface with IPs are VLAN tagged and has at least one UPPERCASE letter in their name.


Registration would pass for my testing as i would still have ens192 active but production.log in satellite will clearly show this:

2023-11-18T09:18:19 [I|app|12339203] Import facts for 'rhel8.example.com' completed. Added: 222, Updated: 0, Deleted 0 facts
2023-11-18T09:18:19 [I|app|12339203] ForemanWebhooks::EventSubscriber: host_updated.event.foreman event received
2023-11-18T09:18:19 [I|aud|12339203] Nic::Managed (291) update event on mac , 00:50:56:b4:b3:ae
2023-11-18T09:18:19 [I|aud|12339203] Nic::Managed (291) update event on identifier , ens192
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving bondBK.134 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving bondDB.127 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving Datos.306 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving HB2.399 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving HB1.398 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Not queueing Nic::Managed: ["Attached to can't be blank"]
2023-11-18T09:18:19 [W|app|12339203] Saving Robot.172 NIC for host rhel8.example.com failed, skipping because:
2023-11-18T09:18:19 [W|app|12339203]  Attached to can't be blank


Which translates to the same error. 



Expected results:

No such issues. 


Additional info:

To prove my point, I just did 

sed -i 's/Datos.306/datos.306/g' /etc/rhsm/facts/03588300.facts

And then re-registered my system and that created the datos.306 interface this time. 

So I created this patch and applied it on /usr/share/foreman/app/services/fact_parser.rb that allows both uppercase and lowercase letters in the VLAN regex 

diff --git a/app/services/fact_parser.rb b/app/services/fact_parser.rb
index 02dcbe0..473929c 100644
--- a/app/services/fact_parser.rb
+++ b/app/services/fact_parser.rb
@@ -4,7 +4,7 @@ class FactParser
   BRIDGES = /\A(vir|lxc)?br(\d+|-[a-z0-9]+)(_nic)?\Z/
   BONDS = /\A(bond\d+)\Z|\A(lagg\d+)\Z/
   ALIASES = /(\A[a-z0-9\.]+):([a-z0-9]+)\Z/
-  VLANS = /\A([a-z0-9]+)\.([0-9]+)\Z/
+  VLANS = /\A([a-zA-Z0-9]+)\.([0-9]+)\Z/
   VIRTUAL_NAMES = /#{ALIASES}|#{VLANS}|#{VIRTUAL}|#{BRIDGES}|#{BONDS}/
   # spend 500ms per IP on primary interface lookup
   PRIMARY_INTERFACE_RESOLVE_TIMEOUTS = [0.50]

And then after restarting the foreman and httpd services , I re-registered the same system and every single interface got created without any errors whatsoever. 


Attaching a file that shows my testing and respective logs from production.log file.

Comment 1 Sayan Das 2023-11-18 04:16:09 UTC
Created attachment 2000089 [details]
Test results

Comment 5 Ron Lavi 2023-11-20 14:05:31 UTC
Created redmine issue https://projects.theforeman.org/issues/36934 from this bug

Comment 6 Bryan Kearney 2023-11-20 16:02:44 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36934 has been resolved.

Comment 8 sganar 2023-12-20 06:30:17 UTC
Verified.

Tested on Satellite 6.15.0 Snap 3.0

Steps followed: 
1. On a RHEL8 system, create the following file
# cat /etc/rhsm/facts/03588300.facts
{
 "net.interface.enp98s0f0.mac_address": "00:25:b5:04:00:b7",
 "net.interface.enp98s0f0.permanent_mac_address": "00:25:B5:04:00:B7",
 "net.interface.enp98s0f1.mac_address": "00:25:b5:04:00:b7",
 "net.interface.enp98s0f1.permanent_mac_address": "00:25:B5:04:00:B6",
 "net.interface.enp98s0f2.mac_address": "00:25:b5:04:00:b5",
 "net.interface.enp98s0f2.permanent_mac_address": "00:25:B5:04:00:B5",
 "net.interface.enp98s0f3.mac_address": "00:25:b5:04:00:b5",
 "net.interface.enp98s0f3.permanent_mac_address": "00:25:B5:04:00:B4",
 "net.interface.enp103s0f0.mac_address": "00:25:b5:04:00:b3",
 "net.interface.enp103s0f0.permanent_mac_address": "00:25:B5:04:00:B3",
 "net.interface.enp103s0f1.mac_address": "00:25:b5:04:00:b3",
 "net.interface.enp103s0f1.permanent_mac_address": "00:25:B5:04:00:B2",
 "net.interface.enp103s0f2.mac_address": "00:25:b5:04:00:b1",
 "net.interface.enp103s0f2.permanent_mac_address": "00:25:B5:04:00:B1",
 "net.interface.enp103s0f3.mac_address": "00:25:b5:04:00:b1",
 "net.interface.enp103s0f3.permanent_mac_address": "00:25:B5:04:00:B0",
 "net.interface.bondBK.134.mac_address": "00:25:b5:04:00:b7",
 "net.interface.bondDB.127.mac_address": "00:25:b5:04:00:b8",
 "net.interface.Datos.306.mac_address": "00:25:b5:04:00:b7",
 "net.interface.Datos.306.ipv4_address": "192.168.124.143",
 "net.interface.Datos.306.ipv4_address_list": "192.168.124.143, 192.168.124.144, 192.168.124.148, 192.168.124.149",
 "net.interface.Datos.306.ipv4_netmask": "24",
 "net.interface.Datos.306.ipv4_netmask_list": "24, 24, 24, 24",
 "net.interface.Datos.306.ipv4_broadcast": "192.168.124.255",
 "net.interface.Datos.306.ipv4_broadcast_list": "192.168.124.255, 192.168.124.255, 192.168.124.255, 192.168.124.255",
 "net.interface.Bond1.mac_address": "00:25:b5:04:00:b5",
 "net.interface.Bond3.mac_address": "00:25:b5:04:00:b1",
 "net.interface.HB2.399.mac_address": "00:25:b5:04:00:b1",
 "net.interface.Bond2.mac_address": "00:25:b5:04:00:b3",
 "net.interface.HB1.398.mac_address": "00:25:b5:04:00:b3",
 "net.interface.Robot.172.mac_address": "00:25:b5:04:00:b5"
}
2. Register the system with satellite and monitor the production.log

Observation: 
The host registered succesfully without any issues.

# hammer host info --id 29
Id:                       29
Name:                     rhel.localdomain
Organization:             QzJEEivIzs
Location:                 rGCZbFn
Cert name:                rhel.localdomain
Managed:                  no
Installed at:             2023/12/20 05:59:04
Last report:              
Uptime (seconds):         1307
Status:                   
    Global Status: Warning
    Build Status:  Installed
Network:                  
    IPv4 address: 10.1.4.183
    MAC:          fa:16:3e:bd:bc:8b
Network interfaces:       
 1) Id:          60
    Identifier:  Bond1
    Type:        interface
    MAC address: 00:25:b5:04:00:b5
    FQDN:
 2) Id:          62
    Identifier:  Bond2
    Type:        interface
    MAC address: 00:25:b5:04:00:b3
    FQDN:
 3) Id:          64
    Identifier:  Bond3
    Type:        interface
    MAC address: 00:25:b5:04:00:b1
    FQDN:
 4) Id:          66
    Identifier:  bondBK.134
    Type:        interface
    MAC address: 00:25:b5:04:00:b7
    FQDN:
 5) Id:          67
    Identifier:  bondDB.127
    Type:        interface
    MAC address: 00:25:b5:04:00:b8
    FQDN:
 6) Id:           68
    Identifier:   Datos.306
    Type:         interface
    MAC address:  00:25:b5:04:00:b7
    IPv4 address: 192.168.124.143
    FQDN:
 7) Id:          63
    Identifier:  enp103s0f1
    Type:        interface
    MAC address: 00:25:b5:04:00:b2
    FQDN:
 8) Id:          65
    Identifier:  enp103s0f3
    Type:        interface
    MAC address: 00:25:b5:04:00:b0
    FQDN:
 9) Id:          58
    Identifier:  enp98s0f0
    Type:        interface
    MAC address: 00:25:b5:04:00:b7
    FQDN:
 10)Id:          59
    Identifier:  enp98s0f1
    Type:        interface
    MAC address: 00:25:b5:04:00:b6
    FQDN:
 11)Id:          61
    Identifier:  enp98s0f3
    Type:        interface
    MAC address: 00:25:b5:04:00:b4
    FQDN:
 12)Id:           57
    Identifier:   eth0
    Type:         interface (primary, provision, execution)
    MAC address:  fa:16:3e:bd:bc:8b
    IPv4 address: 10.1.4.179
    FQDN:         rhel.localdomain
 13)Id:          70
    Identifier:  HB1.398
    Type:        interface
    MAC address: 00:25:b5:04:00:b3
    FQDN:
 14)Id:          69
    Identifier:  HB2.399
    Type:        interface
    MAC address: 00:25:b5:04:00:b1
    FQDN:
 15)Id:          71
    Identifier:  Robot.172
    Type:        interface
    MAC address: 00:25:b5:04:00:b5
    FQDN:

Comment 11 errata-xmlrpc 2024-04-23 17:15:46 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 (Important: Satellite 6.15.0 release), 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-2024:2010