Fix: ignore resolve error while looking up node

Log a warning instead of throwing an exception if an address of some node
cannot be resolved, so new nodes can be registered in ironic.

This solves the problem that if an address of any other node is not
resolvable, no new node can be registered, even if its own address is
resolvable.

Closes-bug: #2072544
Change-Id: If7f65bcac2bb23c148ba27d45166d4a978df1e79
Signed-off-by: Robert Hoffmann <robert.hoffmann@uhurutec.com>
This commit is contained in:
Robert Hoffmann 2024-07-31 11:07:40 +02:00 committed by Julia Kreger
parent 43248710fa
commit 2318bf75f6
3 changed files with 9 additions and 13 deletions

View File

@ -137,11 +137,8 @@ def get_ipmi_address(node):
elif family == socket.AF_INET6: elif family == socket.AF_INET6:
ipv6 = ip ipv6 = ip
except socket.gaierror: except socket.gaierror:
msg = _('Failed to resolve the hostname (%(value)s)' LOG.warning('Failed to resolve the hostname (%s)'
' for node %(uuid)s') ' for node %s', value, node.id, node_info=node)
raise utils.Error(msg % {'value': value,
'uuid': node.id},
node_info=node)
return (value, ipv4, ipv6) if ipv4 or ipv6 else none_address return (value, ipv4, ipv6) if ipv4 or ipv6 else none_address
return none_address return none_address

View File

@ -71,14 +71,6 @@ class TestGetIpmiAddress(base.BaseTest):
mock_socket.assert_called_once_with(self.ipmi_address, None, 0, 0, mock_socket.assert_called_once_with(self.ipmi_address, None, 0, 0,
socket.SOL_TCP) socket.SOL_TCP)
@mock.patch('socket.getaddrinfo', autospec=True)
def test_bad_hostname_errors(self, mock_socket):
node = mock.Mock(spec=['driver_info', 'uuid'],
driver_info={'ipmi_address': 'meow'},
id='uuid1')
mock_socket.side_effect = socket.gaierror('Boom')
self.assertRaises(utils.Error, ir_utils.get_ipmi_address, node)
def test_additional_fields(self): def test_additional_fields(self):
node = mock.Mock(spec=['driver_info', 'uuid'], node = mock.Mock(spec=['driver_info', 'uuid'],
driver_info={'foo': self.ipmi_ipv4}) driver_info={'foo': self.ipmi_ipv4})

View File

@ -0,0 +1,7 @@
---
fixes:
- |
No longer throws an exception if an address of some node cannot be
resolved, but just logs a warning instead. This fixes the issue that
if an address of any other node is not resolvable, no new node can be
registered, even if its own address is resolvable.