Browse Source

Merge "pxe_filter: fix get blacklist error" into stable/rocky

changes/40/661740/1
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
8540dbe9d5
  1. 4
      ironic_inspector/pxe_filter/iptables.py
  2. 18
      ironic_inspector/test/unit/test_iptables.py
  3. 6
      releasenotes/notes/fix-pxe-filter-get-blacklist-2dde59d51c1d010f.yaml

4
ironic_inspector/pxe_filter/iptables.py

@ -226,9 +226,9 @@ def _ib_mac_to_rmac_mapping(ports):
def _get_blacklist(ironic):
ports = [port.address for port in
ports = [port for port in
ir_utils.call_with_retries(ironic.port.list, limit=0,
fields=['address', 'extra'])
if port.address not in node_cache.active_macs()]
_ib_mac_to_rmac_mapping(ports)
return ports
return [port.address for port in ports]

18
ironic_inspector/test/unit/test_iptables.py

@ -343,10 +343,11 @@ class TestGetBlacklist(test_base.BaseTest):
self.mock_ironic = mock.Mock()
def test_active_port(self):
self.mock_ironic.port.list.return_value = [
mock_ports_list = [
mock.Mock(address='foo'),
mock.Mock(address='bar'),
]
self.mock_ironic.port.list.return_value = mock_ports_list
self.mock_active_macs.return_value = {'foo'}
ports = iptables._get_blacklist(self.mock_ironic)
@ -354,16 +355,18 @@ class TestGetBlacklist(test_base.BaseTest):
self.assertEqual(['bar'], ports)
self.mock_ironic.port.list.assert_called_once_with(
limit=0, fields=['address', 'extra'])
self.mock__ib_mac_to_rmac_mapping.assert_called_once_with(ports)
self.mock__ib_mac_to_rmac_mapping.assert_called_once_with(
[mock_ports_list[1]])
@mock.patch('time.sleep', lambda _x: None)
def test_retry_on_port_list_failure(self):
mock_ports_list = [
mock.Mock(address='foo'),
mock.Mock(address='bar'),
]
self.mock_ironic.port.list.side_effect = [
ironic_exc.ConnectionRefused('boom'),
[
mock.Mock(address='foo'),
mock.Mock(address='bar'),
]
mock_ports_list
]
self.mock_active_macs.return_value = {'foo'}
@ -372,4 +375,5 @@ class TestGetBlacklist(test_base.BaseTest):
self.assertEqual(['bar'], ports)
self.mock_ironic.port.list.assert_called_with(
limit=0, fields=['address', 'extra'])
self.mock__ib_mac_to_rmac_mapping.assert_called_once_with(ports)
self.mock__ib_mac_to_rmac_mapping.assert_called_once_with(
[mock_ports_list[1]])

6
releasenotes/notes/fix-pxe-filter-get-blacklist-2dde59d51c1d010f.yaml

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue while mapping port InfiniBand MAC
address to EthernetOverInfiniBand MAC. Prior to this fix,
it will fail to map and raise an exception.
Loading…
Cancel
Save