Skip to content

Conversation

@cadejacobson
Copy link
Contributor

@cadejacobson cadejacobson commented Nov 3, 2025

Proposed Commit Message

fix(azure): ensure ephemeral networking uses primary NIC

When ephemeral networking is brought up in Azure, the selected interface
(`iface`) is `None` under certain conditions. This change introduces 
a helper function `find_primary_nic()` which uses 
`net.find_candidate_nics()` to determine and select the system's primary 
network interface if one is not explicitly set.

Additional improvements:
- Log the MAC address and driver of the selected NIC for easier debugging.
- Ensure the DHCP retry loop updates `iface` to the current primary NIC before
  retrying to obtain a lease.

Fixes 6558 

Updated Output

After these changes, the output for creating a VM reads:

2025-11-04 21:47:15,765 - azure.py[DEBUG]: Bringing up ephemeral networking with iface=eth0 mac=7c:1e:52:e8:55:f9 driver=hv_netvsc : [('lo', '00:00:00:00:00:00', None, None), ('eth1', '7c:1e:52:e8:5e:80', 'hv_netvsc', '0x3'), ('eth0', '7c:1e:52:e8:55:f9', 'hv_netvsc', '0x3')]

Merge type

  • Squash merge using "Proposed Commit Message"

Fixes #6558

@cadejacobson cadejacobson changed the title Cade/log iface fix(azure): use primary NIC when iface is None in ephemeral DHCP setup Nov 3, 2025
@holmanb
Copy link
Member

holmanb commented Nov 4, 2025

Thanks for the contribution.

Please link this to the bug that this is supposed to fix. If none exists, one should be created containing full context (logs where this happened with any other relevant details).

When ephemeral networking is brought up in Azure, the selected interface
(iface) may be None under certain conditions.

Which conditions? Were those conditions reproducable and was this demonstrated to fix the problem when that occurs?

@cadejacobson
Copy link
Contributor Author

Thanks for the contribution.

Please link this to the bug that this is supposed to fix. If none exists, one should be created containing full context (logs where this happened with any other relevant details).

When ephemeral networking is brought up in Azure, the selected interface
(iface) may be None under certain conditions.

Which conditions? Were those conditions reproducable and was this demonstrated to fix the problem when that occurs?

Sounds good! I will get a bug made with the relevant context. For a very short overview here, three out of four calls to the _setup_ephemeral_networking() function do not provide an explicit interface in the parameters so it defaults to None. When we enter the ephemeral networking function and log which interface we are bringing up networking on, the log is simply Bringing up ephemeral networking with iface=None. I will get more verbose logs and these conditions mapped out in the issue and link it back here!

Thank you for the guidance 😁 this is my first PR to Cloud-init, so I left this as a draft while I get the required materials compiled for a proper review.

@holmanb
Copy link
Member

holmanb commented Nov 4, 2025

@cadejacobson Thanks for filing the bug. No worries - and welcome!

@cadejacobson cadejacobson marked this pull request as ready for review November 4, 2025 21:42
@cadejacobson
Copy link
Contributor Author

@holmanb I have gotten this work to its final state. Could I please have you run the pipelines one more time to verify we do not need minor changes? Thanks so much!

@holmanb
Copy link
Member

holmanb commented Nov 20, 2025

It looks like this is waiting for updates per the latest review, so I'll hold off on reviewing it for now.

Copy link
Contributor

@cjp256 cjp256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great, a few minor and optional nitpicks. Integration test results (internal) look great. The one thing I would like to see is a test covering update_primary_nic=True where the interface does change.

@cadejacobson cadejacobson requested a review from cjp256 December 1, 2025 22:53
Copy link
Contributor

@cjp256 cjp256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes to test and LGTM!

@cadejacobson cadejacobson requested a review from cjp256 December 5, 2025 16:18
Copy link
Contributor

@cjp256 cjp256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@holmanb holmanb self-assigned this Dec 8, 2025
@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Dec 23, 2025
@canonical canonical deleted a comment from github-actions bot Dec 24, 2025
@blackboxsw blackboxsw removed the stale-pr Pull request is stale; will be auto-closed soon label Dec 24, 2025
@mentos1386
Copy link

Hi all, when can we expect this to be merged/released?

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @cadejacobson. One nit, otherwise this looks good to me.

@cadejacobson cadejacobson requested a review from holmanb January 5, 2026 23:38
@cadejacobson
Copy link
Contributor Author

Hi all, when can we expect this to be merged/released?
@mentos1386

This is ready for merge on our end! I got the feedback from @holmanb addressed.

@holmanb holmanb merged commit ec44db2 into canonical:main Jan 6, 2026
20 checks passed
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.

[azure] Ephemeral networking interface shows None in cloud-init.log

5 participants