Skip adapter rename when set-name is not explicitly provided#190
Draft
maxpain wants to merge 1 commit intocloudbase:masterfrom
Draft
Skip adapter rename when set-name is not explicitly provided#190maxpain wants to merge 1 commit intocloudbase:masterfrom
maxpain wants to merge 1 commit intocloudbase:masterfrom
Conversation
a335e66 to
abd0f44
Compare
When using network-config v2 with match.macaddress, cloudbase-init always renames the adapter to the ethernets dict key name. This causes failures on Windows because: 1. The WMI rename call (MSFT_NetAdapter.rename) is unreliable during early boot — the new name is not immediately queryable, causing "Network interface not found" errors (cloudbase#101, cloudbase#151) 2. The rename can hang for minutes on some Windows versions (cloudbase#82) 3. Multiple adapters can cause name collisions This aligns with cloud-init (Linux) behavior where the ethernets dict key is just an opaque identifier when match is present, and only set-name triggers an actual rename. The fix checks link.id vs link.name: when they match (no set-name was provided), the adapter is used with its current Windows name instead of being renamed. When set-name is explicitly provided (link.id != link.name), rename proceeds as before. Signed-off-by: Max Makarov <maxpain@linux.com>
abd0f44 to
b983b1d
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.
Summary
When using network-config v2 with
match.macaddress, cloudbase-init renames the network adapter to the ethernets dict key name. This causes failures on Windows:MSFT_NetAdapter.rename()succeeds but the new name is not immediately queryable by subsequent WMI calls, causing"Network interface with name '...' not found"errors (Network interface renaming is not working on Win Server 2022 Core #101, WMI issue may break cloudbase-init adapter rename at VM node bootstrapping #151)netsh-based rename can hang for ~9 minutes on Windows Server 2022 (Windows Server 22 deployment stuck at renaming NIC #82){Object Exists}when another adapter already has the target nameThis PR aligns cloudbase-init behavior with cloud-init (Linux), where the ethernets dict key is an opaque identifier when
matchis present, and onlyset-nametriggers an actual rename.How it works
The v2 parser stores
link.id= dict key andlink.name=set-name(or dict key if not provided). Whenlink.id == link.name(noset-name), the adapter found by MAC is used with its current Windows name. Whenlink.id != link.name(set-namewas explicitly provided), rename proceeds as before.Example
Testing