Skip to content

windows: retry finding the IP interface before setting DHCP - #225

Open
frct1 wants to merge 1 commit into
cloudbase:masterfrom
ib-systems:fix-dhcp-interface-not-found
Open

frct1 wants to merge 1 commit into
cloudbase:masterfrom
ib-systems:fix-dhcp-interface-not-found

Conversation

@frct1

@frct1 frct1 commented Nov 18, 2026

Copy link
Copy Markdown

Problem

NetworkConfigPlugin creates a team NIC for a VLAN link and sets its static address right away. Windows creates the new adapter's IP interface a moment later, so _fix_network_adapter_dhcp finds no MSFT_NetIPInterface, raises ItemNotFoundException, and the plugin fails. The adapter is left on DHCP without its address, so the machine is unreachable on that network.

From a Windows Server 2025 VM, cloudbase-init 1.1.8, a VLAN on a one-card LBFO team:

00:21:39.569 INFO  Creating bond network adapter "net1.1010" on team "bond_net1-team" with VLAN: 1010
00:21:40.064 INFO  Setting static IP configuration on network adapter "net1.1010". IP: 10.0.0.20, prefix length: 24, ...
00:21:40.126 ERROR plugin 'NetworkConfigPlugin' failed with error 'Network interface with name "net1.1010" not found'
  ...
  File "...\cloudbaseinit\osutils\windows.py", line 1000, in _set_static_network_config
    WindowsUtils._fix_network_adapter_dhcp(name, False, family)
  File "...\cloudbaseinit\osutils\windows.py", line 951, in _fix_network_adapter_dhcp
    raise exception.ItemNotFoundException(

It is intermittent: another run of the same image and config, with 2.3 seconds between creating the adapter and setting the address, worked.

Fix

Retry _fix_network_adapter_dhcp on ItemNotFoundException, the same way set_network_adapter_mtu already retries its adapter lookup: up to 10 retries, 1 to 5 seconds apart (about 40 seconds in total).

Tests

  • New test_fix_network_adapter_dhcp_network_adapter_late: the interface appears on the third lookup and DHCP is set.
  • The existing test for a missing interface now checks that it is looked up 11 times before the exception.
  • tox -e py3 -- cloudbaseinit.tests.osutils.test_windows and tox -e pep8 pass; without the fix, the two new checks fail.

Related: #47 (the same class of error for the adapter lookup by MAC address).

🤖 Generated with Claude Code

NetworkConfigPlugin creates a team NIC for a VLAN link and sets its static
address right away. Windows creates the new adapter's IP interface a
moment later, so _fix_network_adapter_dhcp can find no MSFT_NetIPInterface
and the plugin fails, leaving the adapter without its address:

    Creating bond network adapter "net1.1010" on team "bond_net1-team"
      with VLAN: 1010
    plugin 'NetworkConfigPlugin' failed with error 'Network interface
      with name "net1.1010" not found'

Seen on Windows Server 2025 with a VLAN on a one-card LBFO team, half a
second after the team NIC was created; a run with 2.3 seconds in between
worked with the same names.

Retry the lookup on ItemNotFoundException, as set_network_adapter_mtu
already does, for up to about 40 seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ilia Baikov <ilia.baikov@ib.systems>
frct1 added a commit to ib-systems/packer-openstack-images that referenced this pull request Nov 18, 2026
NetworkConfigPlugin sets a static address on a VLAN team NIC before
Windows has created its IP interface and fails with 'Network interface
with name "net1.1010" not found', leaving the server without its
management address (seen in a QEMU dry run, intermittent).
cloudbase/cloudbase-init#225 retries the lookup.

Until a released MSI has it, 03-cloudbase-init-pr225.ps1 replaces the
1.1.8 osutils\windows.py with the one from the PR's commit: windows.py is
the same in 1.1.8 and in the PR's base, so the result is 1.1.8 plus the
retry. Both files are pinned by SHA-256 (line endings aside); the build
fails if the MSI brings another windows.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant