Skip to content

bug: 2822: Use interface associated with boot interface id if host is booted with non-DPU interface.#3416

Open
abvarshney-nv wants to merge 1 commit into
NVIDIA:mainfrom
abvarshney-nv:issue_2822
Open

bug: 2822: Use interface associated with boot interface id if host is booted with non-DPU interface.#3416
abvarshney-nv wants to merge 1 commit into
NVIDIA:mainfrom
abvarshney-nv:issue_2822

Conversation

@abvarshney-nv

@abvarshney-nv abvarshney-nv commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Use interface associated with boot interface id if host is booted with non-DPU interface

Related issues

Issue 2822

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

@abvarshney-nv abvarshney-nv requested a review from a team as a code owner July 13, 2026 04:14
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately summarizes the main fix: selecting the boot-associated interface for non-DPU host discovery.
Description check ✅ Passed The description is directly related to the changeset and matches the boot-interface selection fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@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.

🧹 Nitpick comments (3)
crates/api-core/src/handlers/machine_discovery.rs (1)

162-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log the swallowed find_one error.

The fallback correctly gates on !is_dpu() and avoids a redundant lookup when the cmdline id matches the resolved interface. However, db::machine_interface::find_one(&mut txn, cmdline_id).await errors are silently discarded by the let Ok(...) chain — this masks genuine DB failures (not just the expected "not found" case), making such failures invisible in logs.

🩹 Proposed fix: log the failure before discarding it
     if !hardware_info.is_dpu()
         && interface.machine_id.is_none()
         && let Some(cmdline_id) = interface_id.filter(|id| *id != interface.id)
-        && let Ok(cmdline_interface) = db::machine_interface::find_one(&mut txn, cmdline_id).await
+        && let Ok(cmdline_interface) = db::machine_interface::find_one(&mut txn, cmdline_id)
+            .await
+            .inspect_err(|e| tracing::debug!(%cmdline_id, error=%e, "kernel-cmdline interface lookup failed during host fallback"))
         && cmdline_interface.machine_id.is_some()
     {
Based on coding guidelines: "Avoid using `let _unused = foo();` to discard errors... If you don't care about the errors a function produces, prefer using `.ok()`."
🤖 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/api-core/src/handlers/machine_discovery.rs` around lines 162 - 186,
Update the fallback lookup around find_one in the non-DPU interface reassignment
block to capture and log any database error before treating the lookup as
unavailable. Preserve the existing behavior of only replacing interface when the
returned cmdline interface has a machine, while making genuine find_one failures
visible through tracing.

Source: Coding guidelines

crates/api-core/src/tests/machine_discovery.rs (1)

270-317: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Solid regression test for the happy path — consider covering the negative branches too.

This locks in the case where the cmdline interface exists and is machine-associated. The handler's fallback also has two branches this doesn't exercise: the cmdline interface not existing/lookup failing, and the cmdline interface existing but itself being unassociated (cmdline_interface.machine_id.is_none()) — in both cases discovery should still fail with the original "machine_id not found" behavior. All the fixtures needed (host_discover_machine_from_remote_ip, validate_existing_mac_and_create) are already in place, so this is a cheap addition to guard against regressions in the fallback's guard conditions.

🤖 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/api-core/src/tests/machine_discovery.rs` around lines 270 - 317,
Extend test_host_discovery_falls_back_to_cmdline_interface_when_ip_unassociated
with negative cases covering a missing/unresolvable cmdline interface and an
existing cmdline interface whose machine_id is None. Assert both discovery
attempts fail with the original “machine_id not found” behavior, reusing
host_discover_machine_from_remote_ip and validate_existing_mac_and_create
fixtures.
crates/api-core/src/tests/common/api_fixtures/host.rs (1)

155-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the shared DiscoveryInfo/AttestKeyInfo boilerplate.

This is now the third fixture (host_discover_machine, host_discover_machine_with_reporter, and this one) that builds an identical DiscoveryInfo + AttestKeyInfo block. A small shared helper would remove the triplicated setup and keep each fixture focused on what makes it distinct (reporter fields vs. remote-IP metadata).

♻️ Proposed refactor
+fn discovery_info_with_attest_key(host_config: &ManagedHostConfig) -> DiscoveryInfo {
+    let mut discovery_info = DiscoveryInfo::try_from(HardwareInfo::from(host_config)).unwrap();
+    discovery_info.attest_key_info = Some(AttestKeyInfo {
+        ek_pub: EK_PUB_SERIALIZED.to_vec(),
+        ak_pub: AK_PUB_SERIALIZED.to_vec(),
+        ak_name: AK_NAME_SERIALIZED.to_vec(),
+    });
+    discovery_info
+}
+
 pub async fn host_discover_machine_from_remote_ip(
     env: &TestEnv,
     host_config: &ManagedHostConfig,
     machine_interface_id: MachineInterfaceId,
     remote_ip: std::net::IpAddr,
 ) -> Result<MachineId, tonic::Status> {
-    let mut discovery_info = DiscoveryInfo::try_from(HardwareInfo::from(host_config)).unwrap();
-    discovery_info.attest_key_info = Some(AttestKeyInfo {
-        ek_pub: EK_PUB_SERIALIZED.to_vec(),
-        ak_pub: AK_PUB_SERIALIZED.to_vec(),
-        ak_name: AK_NAME_SERIALIZED.to_vec(),
-    });
+    let discovery_info = discovery_info_with_attest_key(host_config);

     let mut request = Request::new(MachineDiscoveryInfo {
Based on path instructions (CONTRIBUTING.md, matched by `**`): "Does an existing workspace dependency or local helper already solve it?"
🤖 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/api-core/src/tests/common/api_fixtures/host.rs` around lines 155 -
186, Extract the repeated DiscoveryInfo and AttestKeyInfo construction into a
shared helper in the host fixture module, then reuse it from
host_discover_machine, host_discover_machine_with_reporter, and
host_discover_machine_from_remote_ip. Keep each fixture’s distinct reporter
fields and X-Forwarded-For metadata setup unchanged.

Source: Path instructions

🤖 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.

Nitpick comments:
In `@crates/api-core/src/handlers/machine_discovery.rs`:
- Around line 162-186: Update the fallback lookup around find_one in the non-DPU
interface reassignment block to capture and log any database error before
treating the lookup as unavailable. Preserve the existing behavior of only
replacing interface when the returned cmdline interface has a machine, while
making genuine find_one failures visible through tracing.

In `@crates/api-core/src/tests/common/api_fixtures/host.rs`:
- Around line 155-186: Extract the repeated DiscoveryInfo and AttestKeyInfo
construction into a shared helper in the host fixture module, then reuse it from
host_discover_machine, host_discover_machine_with_reporter, and
host_discover_machine_from_remote_ip. Keep each fixture’s distinct reporter
fields and X-Forwarded-For metadata setup unchanged.

In `@crates/api-core/src/tests/machine_discovery.rs`:
- Around line 270-317: Extend
test_host_discovery_falls_back_to_cmdline_interface_when_ip_unassociated with
negative cases covering a missing/unresolvable cmdline interface and an existing
cmdline interface whose machine_id is None. Assert both discovery attempts fail
with the original “machine_id not found” behavior, reusing
host_discover_machine_from_remote_ip and validate_existing_mac_and_create
fixtures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3be88b59-2384-4bac-92e7-495e4f6184fb

📥 Commits

Reviewing files that changed from the base of the PR and between 767219e and da602c0.

📒 Files selected for processing (3)
  • crates/api-core/src/handlers/machine_discovery.rs
  • crates/api-core/src/tests/common/api_fixtures/host.rs
  • crates/api-core/src/tests/machine_discovery.rs

@chet

chet commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

I just left a comment in the GH issue -- just double checking the background. I think the answer might be that as of today you need to set dpu_mode: no_dpu.

@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 257 13 32 79 7 126
machine-validation-runner 803 40 237 296 36 194
machine_validation 803 40 237 296 36 194
machine_validation-aarch64 803 40 237 296 36 194
nvmetal-carbide 803 40 237 296 36 194
TOTAL 3475 173 980 1269 151 902

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

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.

discover_machine: host registration not-found when interface unassociated; add match-by-serial fallback

3 participants