Nic managed hooks not all queued

Problem:
When the host has multiple managed nics, it is expected that the data given to the nic/managed/destroy script would be an array or be called multiple times (once for each managed interface)

Based on some initial testing, only one (last?) managed nic is passed to the hook. this prevents actions from being taken on each managed nic.

Expected outcome:

either an array or multiple hook events would be queued

Foreman and Proxy versions:
3.9.1
alma 8
puppet 7


looking at possible work arounds using a before destroy event on the host where the nics can be iterated.

Adding some logs

2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on mac 52:54:00:76:1a:c8
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on ip 10.255.201.216
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on type Nic::Managed
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on name 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on host_id 2156
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on subnet_id 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on domain_id 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on attrs {"bindings"=>[{"address"=>"10.255.201.216", "netmask"=>"255.255.255.0", "network"=>"10.255.201.0"}], "bindings6"=>[{"address"=>"fe80::39e9:6c93:54ba:c3ad", "netmask"=>"ffff:ffff:ffff:ffff::", "network"=>"fe80::", "scope6"=>"link", "flags"=>["permanent"]}], "dhcp"=>"10.255.201.1", "duplex"=>"full", "mtu"=>1500, "netmask"=>"255.255.255.0", "netmask6"=>"ffff:ffff:ffff:ffff::", "network"=>"10.255.201.0", "network6"=>"fe80::", "operational_state"=>"up", "physical"=>true, "scope6"=>"link", "speed"=>100}
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on provider 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on username 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on password [redacted]
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on virtual false
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on link true
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on identifier ens1
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on tag 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on attached_to 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on managed false
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on mode balance-rr
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on attached_devices 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on bond_options 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on primary false
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on provision false
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on compute_attributes {}
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on ip6 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on subnet6_id 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18947) destroy event on execution false
2024-01-13T03:24:52 [D|app|08e79479] Observed destroy hook on 
2024-01-13T03:24:52 [D|app|08e79479] Queuing 1 hooks for Nic::Managed#destroy
2024-01-13T03:24:52 [D|app|08e79479] Queuing hook /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py for Nic::Managed#destroy at priority 0010
2024-01-13T03:24:52 [D|app|08e79479] Enqueued task 'Hook: /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py' to 'Host::Managed Main' queue
2024-01-13T03:24:52 [D|app|08e79479] Processing task 'Hook: /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py' from 'Host::Managed Main'
2024-01-13T03:24:52 [D|app|08e79479] Running hook: /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py destroy 
2024-01-13T03:24:52 [W|app|08e79479] Unable to render  (Nic::Managed) using RABL: Cannot find rabl template 'api/v2/nic/manageds/show' within registered (["/usr/share/foreman/app/views", "/usr/share/gems/gems/foreman_puppet-6.1.1/app/views", "/usr/share/gems/gems/foreman_setup-8.0.1/app/views", "/usr/share/gems/gems/foreman_remote_execution-12.0.2/app/views", "/usr/share/gems/gems/foreman_discovery-23.0.0/app/views", "/usr/share/gems/gems/foreman-tasks-9.0.0/app/views", "/usr/share/gems/gems/foreman_templates-9.4.0/app/views", "/usr/share/gems/gems/apipie-dsl-2.6.1/app/views", "/usr/share/gems/gems/apipie-rails-1.2.3/app/views", "/usr/share/foreman/app/views", "/usr/share/gems/gems/foreman_templates-9.4.0/app/views", "/usr/share/gems/gems/foreman_discovery-23.0.0/app/views"]) view paths!
...
2024-01-13T03:24:52 [D|app|08e79479] Hook output: running usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py destroy
 08e79479 | checking host None interface ens1 with ip 10.255.201.216 for reservation
 08e79479 | {'id': 18947, 'mac': '52:54:00:76:1a:c8', 'ip': '10.255.201.216', 'name': None, 'host_id': 2156, 'subnet_id': None, 'domain_id': None, 'attrs': {'bindings': [{'address': '10.255.201.216', 'netmask': '255.255.255.0', 'network': '10.255.201.0'}], 'bindings6': [{'address': 'fe80::39e9:6c93:54ba:c3ad', 'netmask': 'ffff:ffff:ffff:ffff::', 'network': 'fe80::', 'scope6': 'link', 'flags': ['permanent']}], 'dhcp': '10.255.201.1', 'duplex': 'full', 'mtu': 1500, 'netmask': '255.255.255.0', 'netmask6': 'ffff:ffff:ffff:ffff::', 'network': '10.255.201.0', 'network6': 'fe80::', 'operational_state': 'up', 'physical': True, 'scope6': 'link', 'speed': 100}, 'created_at': '2024-01-12T22:24:26.922-05:00', 'updated_at': '2024-01-12T22:24:26.922-05:00', 'provider': None, 'username': None, 'password': None, 'virtual': False, 'link': True, 'identifier': 'ens1', 'tag': '', 'attached_to': '', 'managed': False, 'mode': 'balance-rr', 'attached_devices': '', 'bond_options': '', 'primary': False, 'provision': False, 'compute_attributes': {}, 'ip6': None, 'subnet6_id': None, 'execution': False}
 08e79479 | completed usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py
 08e79479 | 
2024-01-13T03:24:52 [I|app|08e79479] Processed 1 tasks from queue 'Host::Managed Main', completed 1/1
2024-01-13T03:24:52 [D|app|08e79479] Task 'Hook: /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py' *completed*
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on mac 52:54:00:93:ff:5c
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on ip 10.255.201.206
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on type Nic::Managed
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on name validate-0016.<validate>
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on host_id 2156
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on subnet_id 127
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on domain_id 51
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on attrs {"bindings"=>[{"address"=>"10.255.201.206", "netmask"=>"255.255.255.0", "network"=>"10.255.201.0"}], "bindings6"=>[{"address"=>"fe80::5054:ff:fe93:ff5c", "netmask"=>"ffff:ffff:ffff:ffff::", "network"=>"fe80::", "scope6"=>"link", "flags"=>["permanent"]}], "dhcp"=>"10.255.201.1", "mtu"=>1500, "netmask"=>"255.255.255.0", "netmask6"=>"ffff:ffff:ffff:ffff::", "network"=>"10.255.201.0", "network6"=>"fe80::", "operational_state"=>"up", "physical"=>true, "scope6"=>"link"}
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on provider 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on username 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on password [redacted]
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on virtual false
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on link true
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on identifier eth0
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on tag 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on attached_to 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on managed true
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on mode balance-rr
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on attached_devices 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on bond_options 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on primary true
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on provision true
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on compute_attributes {"type"=>"bridge", "bridge"=>"br-vm-mgmt", "model"=>"virtio"}
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on ip6 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on subnet6_id 
2024-01-13T03:24:52 [I|aud|08e79479] Nic::Managed (18944) destroy event on execution true
2024-01-13T03:24:52 [D|app|08e79479] Observed destroy hook on validate-0016.<redacted>
2024-01-13T03:24:52 [D|app|08e79479] Queuing 1 hooks for Nic::Managed#destroy
2024-01-13T03:24:52 [D|app|08e79479] Queuing hook /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py for Nic::Managed#destroy at priority 0010
2024-01-13T03:24:52 [D|app|08e79479] Task 'Hook: /usr/share/foreman/config/hooks/nic/managed/destroy/0010_dhcp_reservation.py' already in 'Host::Managed Main' queue

@ofedoren