Consider missing MTU invalid metadata

A bug was observed in nova behavior of interacting with ironic where
metadata could be missing in the payload to Ironic. While not great
it is also not awful. In any event, If there happens to be no DHCP
the lack of an MTU can be very problematic and result in a mismatch
between environment configuration and node state.

Closes-Bug: 2110322
Change-Id: Iea85ac4789d646dc85d0d8b22aa8e596b246234b
This commit is contained in:
Julia Kreger
2025-05-09 13:59:46 -07:00
parent b18d581e0f
commit c33f12329c
4 changed files with 43 additions and 5 deletions

View File

@@ -35,7 +35,9 @@ def is_invalid_network_metadata(network_data):
:param network_data: A dictionary object containing network_metadata,
with three sub-fields, 'links', 'networks',
and 'services'. Returns True if the document is
invalid and missing network metadata.
invalid and missing network metadata, or when
specific other issues such as null MTU values
are detected.
:returns: True when the data supplied is invalid.
"""
try:
@@ -45,14 +47,20 @@ def is_invalid_network_metadata(network_data):
# likely just declare missing MTU as a qualifier to rebuild, but
# that is likely to then trigger far more often. Maybe that means
# it is an even better idea...
return (not network_data.get('links', [])
and not network_data.get('networks', [])
and not network_data.get('services', []))
if (not network_data.get('links', [])
and not network_data.get('networks', [])
and not network_data.get('services', [])):
return True
if not CONF.conductor.disable_metadata_mtu_check:
for link in network_data.get('links', []):
if link.get('mtu') is None:
return True
except AttributeError:
# Got called with None or something else lacking the attribute.
# NOTE(TheJulia): If we ever want to inject metadata if missing
# here is where we would add it.
return True
return False
def check_and_patch_configdrive(task, configdrive):

View File

@@ -627,6 +627,12 @@ opts = [
'the data, Ironic will do so transparently. Setting '
'this option to True will disable this '
'functionality.')),
cfg.BoolOpt('disable_metadata_mtu_check',
default=False,
mutable=True,
help=_('Option to disable consideration of supplied '
'network_data.json link MTU values as basis to '
'regenerate the supplied metadata.'))
]

View File

@@ -49,11 +49,25 @@ class MetadataUtilsTestCase(db_base.DbTestCase):
self.assertTrue(cd_utils.is_invalid_network_metadata([]))
def test_is_invalid_network_metadata_valid(self):
valid = {'links': [{'foo': 'bar'}],
valid = {'links': [{'foo': 'bar', 'mtu': 1500}],
'services': [],
'networks': [{'bar': 'baz'}]}
self.assertFalse(cd_utils.is_invalid_network_metadata(valid))
def test_invalid_network_metadata_null_mtu(self):
invalid = {'links': [{'mtu': None}],
'servies': [],
'networks': [{'foo': 'bar'}]}
self.assertTrue(cd_utils.is_invalid_network_metadata(invalid))
def test_invalid_network_metadata_null_mtu_disables(self):
CONF.set_override('disable_metadata_mtu_check', True,
group='conductor')
invalid = {'links': [{'mtu': None}],
'servies': [],
'networks': [{'foo': 'bar'}]}
self.assertFalse(cd_utils.is_invalid_network_metadata(invalid))
@mock.patch.object(cd_utils, 'is_invalid_network_metadata',
autospec=True)
@mock.patch.object(cd_utils, 'generate_instance_network_data',

View File

@@ -0,0 +1,10 @@
---
fixes:
- |
Fixes an issue where a "null" or missing MTU value for network_data.json
payloads in configuration drives forces a regeneration of the configuration
drive. This behavior is enabled by default, and can be disabled by using the
``[conductor]disable_metadata_mtu_check`` configuration option by setting the
option value to ``True``.
For more information, see
`bug 2110322 <https://bugs.launchpad.net/ironic/+bug/2110322>`_.