Ignore IPv6 link local addresses
Prevent IPA from picking up the IPv6 link-local address
as a callback_url in cases where it gets tried before other
addressing methods havn't complete yet. In this scenario IPA
sleeps for 10 seconds and then retries giving the nic a chance to
configure its routable IP address.
Change-Id: Ic53334c630180f0d77bb0231e548d2c44bfe55ca
Closes-Bug: #1732692
(cherry picked from commit 214790d17e
)
This commit is contained in:
parent
c6b579dbf6
commit
07050db1d1
|
@ -21,6 +21,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
from wsgiref import simple_server
|
from wsgiref import simple_server
|
||||||
|
|
||||||
|
import netaddr
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
@ -214,7 +215,12 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return out.strip().split('\n')[0].split('src')[1].split()[0]
|
source = out.strip().split('\n')[0].split('src')[1].split()[0]
|
||||||
|
if netaddr.IPAddress(source).is_link_local():
|
||||||
|
LOG.info('Ignoring link-local source to %(dest)s: %(rec)s',
|
||||||
|
{'dest': dest, 'rec': out})
|
||||||
|
return
|
||||||
|
return source
|
||||||
except IndexError:
|
except IndexError:
|
||||||
LOG.warning('No route to host %(dest)s, route record: %(rec)s',
|
LOG.warning('No route to host %(dest)s, route record: %(rec)s',
|
||||||
{'dest': dest, 'rec': out})
|
{'dest': dest, 'rec': out})
|
||||||
|
|
|
@ -504,6 +504,14 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest):
|
||||||
source = self.agent._get_route_source('XXX')
|
source = self.agent._get_route_source('XXX')
|
||||||
self.assertEqual('1:2::3:4', source)
|
self.assertEqual('1:2::3:4', source)
|
||||||
|
|
||||||
|
@mock.patch.object(utils, 'execute', autospec=True)
|
||||||
|
def test_get_route_source_ipv6_linklocal(self, mock_execute):
|
||||||
|
mock_execute.return_value = (
|
||||||
|
'XXX src fe80::1234:1234:1234:1234 metric XXX\n cache', None)
|
||||||
|
|
||||||
|
source = self.agent._get_route_source('XXX')
|
||||||
|
self.assertIsNone(source)
|
||||||
|
|
||||||
@mock.patch.object(agent, 'LOG', autospec=True)
|
@mock.patch.object(agent, 'LOG', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(utils, 'execute', autospec=True)
|
||||||
def test_get_route_source_indexerror(self, mock_execute, mock_log):
|
def test_get_route_source_indexerror(self, mock_execute, mock_log):
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixes the issue where link-local IP addresses were sometimes used as part
|
||||||
|
of the callback URL given to ironic. The routable address is used instead.
|
||||||
|
See `bug 1732692 <https://bugs.launchpad.net/ironic-python-agent/+bug/1732692>`_
|
||||||
|
for more details.
|
Loading…
Reference in New Issue