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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.15.0
    • None
    • Fact
    • Important

      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.

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

              Created:
              Updated:
              Resolved: