Skip to content

feat: DHCP every network interface by default when no custom network-config is set#3708

Open
RajMandaliya wants to merge 12 commits into
NVIDIA:mainfrom
RajMandaliya:feat/default-network-config-all-interfaces
Open

feat: DHCP every network interface by default when no custom network-config is set#3708
RajMandaliya wants to merge 12 commits into
NVIDIA:mainfrom
RajMandaliya:feat/default-network-config-all-interfaces

Conversation

@RajMandaliya

Copy link
Copy Markdown
Contributor

Addresses #3665.

Draft/stacked on #3392 — this branch is built on top of the network_config/extract_network_config work in #3392, which hasn't merged yet, so this diff currently includes those commits too. Will rebase onto main and clean this up once #3392 lands, at which point this should shrink down to just the new default-config logic below.

Problem

cloud-init's own default behavior (no network-config at all) only DHCPs the first network interface it finds. For multi-NIC hosts (e.g. via qcow-imager) where a tenant hasn't provided a custom network: key, every other interface is left unconfigured.

Fix

Adds DEFAULT_NETWORK_CONFIG, served whenever a tenant hasn't supplied their own network: key, that DHCPs every interface matching either the predictable (en*) or legacy (eth*) naming convention.

Testing

Verified against real cloud-init: confirmed the exact constant string (byte-for-byte, written to a real seed directory) produces the
expected netplan config covering both naming conventions. Three new unit tests cover the decision logic directly (default when absent, custom value used when present, default when no cloud-init at all).

Opening as a draft for early visibility/feedback since #3665 was just filed - happy to adjust the interface-matching approach if there's a preference (e.g. whether to include dhcp6, or a different naming convention assumption) before this is ready to merge.

@copy-pr-bot

copy-pr-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8bf2d657-6829-4327-a439-aa803511dad9

📥 Commits

Reviewing files that changed from the base of the PR and between 7855e13 and 45d0cee.

📒 Files selected for processing (1)
  • crates/pxe/src/routes/cloud_init.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/pxe/src/routes/cloud_init.rs

Summary by CodeRabbit

  • New Features

    • Cloud-init now serves a default (non-empty) network configuration when custom network settings aren’t supplied.
    • Default networking includes DHCPv4/DHCPv6 support for both modern and legacy interface naming patterns.
    • Custom network configurations are still applied when provided.
  • Bug Fixes

    • Fixed cases where the network configuration response could be empty instead of returning defaults.
  • Tests

    • Added coverage for defaulting behavior when tenant network data is missing/present and when custom network input is null.

Walkthrough

The PXE cloud-init network-config route now serves a default DHCP-enabled NoCloud configuration when tenant network data is absent, while preserving custom network configuration when provided. Unit tests cover fallback, custom, and absent cloud-init inputs.

Changes

NoCloud network configuration

Layer / File(s) Summary
Network configuration resolution and validation
crates/pxe/src/routes/cloud_init.rs
Adds the default DHCP YAML, resolves tenant-provided network: content when available, updates the route to use the resolver, and tests fallback, custom, and absent-input behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main behavior change: default DHCP for all interfaces when no custom network-config exists.
Description check ✅ Passed The description is directly related to the change and explains the problem, fix, and testing for the new default network config.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

…config is set

cloud-init's own default behavior (no network-config at all) only
DHCPs the first network interface it finds. For multi-NIC hosts using
qcow-imager (or any tenant not providing a custom network: key), this
leaves every other interface unconfigured.

Adds DEFAULT_NETWORK_CONFIG, served whenever a tenant hasn't supplied
their own network: key, that DHCPs every interface matching either
the predictable (en*) or legacy (eth*) naming convention.

Verified against real cloud-init: confirmed the exact constant string
(byte-for-byte, written to a real seed directory) produces the
expected netplan config covering both naming conventions.

Addresses NVIDIA#3665.

Signed-off-by: RajMandaliya <rajmandaliya2249@gmail.com>
@RajMandaliya
RajMandaliya force-pushed the feat/default-network-config-all-interfaces branch from 3eba752 to 647746b Compare July 21, 2026 05:01
@RajMandaliya
RajMandaliya marked this pull request as ready for review July 21, 2026 05:02
@RajMandaliya
RajMandaliya requested a review from a team as a code owner July 21, 2026 05:02
@RajMandaliya

Copy link
Copy Markdown
Contributor Author

This is now rebased cleanly on top of #3392 (merged), so the diff is scoped to just the new default-network-config logic. Ready for review whenever convenient.

Quick summary: cloud-init's own default (no network-config at all) only DHCPs the first interface it finds. This adds a DEFAULT_NETWORK_CONFIG served whenever a tenant hasn't supplied their own network: key, DHCPing every interface under both the predictable (en*) and legacy (eth*) naming conventions — verified against real cloud-init (exact constant, byte-for-byte, confirmed to produce the correct netplan output for both naming conventions).

Addresses #3665.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/pxe/src/routes/cloud_init.rs (1)

837-855: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the resolver tests table-driven.

These tests exercise one input-to-output mapping. Consolidate the Some/missing-key, custom-key, and None cases into check_values or scenarios!; also assert the expected parsed custom configuration rather than only using assert_ne! and a substring check.

As per coding guidelines, use table-driven tests for functions mapping inputs to outputs, errors, or observable results.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/pxe/src/routes/cloud_init.rs` around lines 837 - 855, Convert the
three resolve_network_config tests into a single table-driven test using
check_values or scenarios!, covering missing network key, custom network
configuration, and None input. Define each case with its expected parsed
configuration and assert exact equality with the resolver result, replacing the
assert_ne! and substring checks while preserving DEFAULT_NETWORK_CONFIG
expectations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/pxe/src/routes/cloud_init.rs`:
- Around line 338-342: Update the documentation for resolve_network_config to
state that when no custom network configuration is present, it returns
DEFAULT_NETWORK_CONFIG rather than an empty document. Keep the description of
extracting the tenant’s network configuration and serving NoCloud’s
network-config document accurate.

---

Nitpick comments:
In `@crates/pxe/src/routes/cloud_init.rs`:
- Around line 837-855: Convert the three resolve_network_config tests into a
single table-driven test using check_values or scenarios!, covering missing
network key, custom network configuration, and None input. Define each case with
its expected parsed configuration and assert exact equality with the resolver
result, replacing the assert_ne! and substring checks while preserving
DEFAULT_NETWORK_CONFIG expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3cce5db1-60ac-437c-b2ed-9ff105b7fa98

📥 Commits

Reviewing files that changed from the base of the PR and between 10cc1c8 and 647746b.

📒 Files selected for processing (1)
  • crates/pxe/src/routes/cloud_init.rs

Comment thread crates/pxe/src/routes/cloud_init.rs Outdated
- Consolidate the three resolve_network_config tests into one
  table-driven test, asserting the actual parsed YAML structure for
  the custom-key case (version, ethernets.eth0.addresses) instead of
  a substring check.
- Fix resolve_network_config's stale doc comment, which was a
  leftover from before DEFAULT_NETWORK_CONFIG existed and incorrectly
  said it falls back to cloud-init's own default DHCP behavior.

Signed-off-by: RajMandaliya <rajmandaliya2249@gmail.com>
@mxh-0xbb

Copy link
Copy Markdown
Contributor

/ok to test 7855e13

@github-actions

Copy link
Copy Markdown

Signed-off-by: RajMandaliya <rajmandaliya2249@gmail.com>
@RajMandaliya

Copy link
Copy Markdown
Contributor Author

Sorry for this formatting issue. It's been happening few times now so created my own hook so with every commit it will automatically run for both rust and go files.

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.

2 participants