fix(net): skip v1 physical entries with no name - #7017
Open
shAsh-cy wants to merge 1 commit into
Open
Conversation
_version_1 skipped entries without a mac_address but not entries without a name, so a None name reached device_driver() and raised TypeError in sys_dev_path(). This crashed wait_for_physdevs while applying network config. Skip nameless entries, matching the existing behaviour of _version_2. This uses the same `if not name` condition as _version_2, so an entry with an empty name is skipped too. That case does not crash today, but an empty name is equally unusable for renaming. Fixes canonicalGH-6982
shAsh-cy
force-pushed
the
fix/6982-physdevs-none-name
branch
from
August 21, 2026 08:29
d54296d to
c7b7f9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/unittests/Proposed Commit Message
Additional Context
The crash. A v1 entry of type
physicalwith amac_addressbut no usablenamereachesdevice_driver(name)withname=None, which raisesTypeErrorinsys_dev_path(). That propagates out ofwait_for_physdevs()inInit.apply_network_config(), which is not wrapped, so network config fails.DataSourceHetzneremits such an entry when a private NIC has not hotplugged yet. Note thatdevice_devid(name)on the following line has the same exposure, so a guard around onlydevice_driverwould have moved the crash rather than fixed it.Why skip rather than guard the lookups. I first considered guarding only the
device_driver/device_devidcalls and letting the row through withname=None, to keep the MAC inwait_for_physdevs'sexpected_macs. Tracing the other consumer showed that is worse.extract_physdevsalso feeds_rename_interfaces()viaapply_network_config_names(). Withdriveranddevice_idboth None,entry_match()falls through to matching on MAC alone, so a nameless row matches a present device and reaches("rename", mac, None, (cur_name, None)). If that device is up and downable it is taken down first, the rename then fails, and the bring-up fails too, leaving the interface down._apply_netcfg_names()wraps all of this inexcept Exceptionand logs a warning, so it would fail silently. Today that path is unreachable because the TypeError fires first. Skipping in_version_1keeps the row out of both consumers.Why this cannot regress. Every v1 config reaching this path with a nameless physical entry crashes today, so there is no working behaviour for the skip to change.
Trade-off. The MAC is no longer waited for in
wait_for_physdevs. If nameless-but-MAC'd v1 entries are considered legitimate input worth waiting for, the alternative is to keep the row and reject it in_rename_interfacesinstead. Happy to do that as a follow-up if preferred.Test Steps
Before this change:
After this change the same call returns
[]. A well-formed v1 entry is unaffected and still resolves to[['86:00:00:3c:5c:43', 'eth0', 'virtio', '0x1000']].New unit test:
TestExtractPhysdevs::test_get_v1_type_physical_skips_if_no_name, placed alongside the existing v2 equivalent. It asserts the entry is skipped and thatdevice_driver/device_devidare never called. The latter matters because the class's autouse fixture mocks both, so the return-value assertion alone would not pin the actual defect.Rebased onto bb81cd0. Full suite: 5744 passed, 5 skipped, 13 xfailed (
tox -e py3).tox -e check_formatpasses.Merge type