Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-22354

Host registration fails with error "Attached to can't be blank" when the VLAN name includes UPPERCASE letters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • None
    • None
    • Fact

      +++ This bug was initially created as a clone of Bug #2250397 +++

      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:

      1. 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}

        /

      1. 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.

      — Additional comment from on 2023-11-18T04:16:09Z

      Created attachment 2000089
      Test results

      — Additional comment from on 2023-11-18T04:30:18Z

      I don't want to hurry and send a PR here as I am not sure if my approach is correct or not.

      If someone can check the BZ + the code change suggested and then confirm, that would be great. If there is a better way to fix or handle this error, I'm all ears.

      CC @Leos

      — Additional comment from on 2023-11-18T08:04:16Z

      JFYI, I am aware of https://bugzilla.redhat.com/show_bug.cgi?id=2016717 which is caused due to - or _ in the names and for them, we can request customers to follow a specific pattern.

      But i believe we can accommodate for uppercase and lowercase nic names in the names (perhaps easily) from satellite end.

      — Additional comment from on 2023-11-19T22:13:57Z

      We should be able to handle NIC names in upper and lower cases or mixed. Having auto-correction enabled on all modern devices makes writing in a browser tricky if you need to enter something case-sensitive. If we want it to be enforced then we need to start giving a warning about it.

      — Additional comment from on 2023-11-20T14:05:31Z

      Created redmine issue https://projects.theforeman.org/issues/36934 from this bug

      — Additional comment from on 2023-11-20T16:02:44Z

      Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36934 has been resolved.

      — Additional comment from on 2023-11-21T11:59:40Z

      PR has been merged, should be available in snap 39

      — Additional comment from on 2023-12-20T06:30:17Z

      Verified.

      Tested on Satellite 6.15.0 Snap 3.0

      Steps followed:
      1. On a RHEL8 system, create the following file

      1. 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.

      1. 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:

            jira-bugzilla-migration RH Bugzilla Integration
            jira-bugzilla-migration RH Bugzilla Integration
            Shweta Singh Shweta Singh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: