Skip to content

feat(switch): persist and expose NVLink domain UUID - #4473

Merged
jayzhudev merged 2 commits into
NVIDIA:mainfrom
jayzhudev:feat/switch-nvl-domain-uuid
Aug 1, 2026
Merged

feat(switch): persist and expose NVLink domain UUID#4473
jayzhudev merged 2 commits into
NVIDIA:mainfrom
jayzhudev:feat/switch-nvl-domain-uuid

Conversation

@jayzhudev

Copy link
Copy Markdown
Contributor

Switch health metrics and logs need the NVLink domain UUID to identify failures at the cluster level. This PR persists the NVLink domain UUID reported by NMX-C and exposes it through the NICo API.

Related issues

Supports #4397

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

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev jayzhudev self-assigned this Aug 1, 2026
@jayzhudev
jayzhudev requested a review from a team as a code owner August 1, 2026 06:03
@coderabbitai

coderabbitai Bot commented Aug 1, 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: b7e1ecae-6aaa-4fa4-9638-5513a81c4672

📥 Commits

Reviewing files that changed from the base of the PR and between a8a5a81 and 05e1502.

⛔ Files ignored due to path filters (1)
  • rest-api/proto/core/gen/v1/nico_nico.pb.go is excluded by !**/*.pb.go, !**/gen/**, !rest-api/**/*.pb.go
📒 Files selected for processing (1)
  • rest-api/proto/core/src/v1/nico_nico.proto

Summary by CodeRabbit

  • New Features
    • Added NVLink domain information to switch records and API responses.
    • Rack-associated hosts are now grouped into rack-specific NVLink domains.
    • Switches can display the NVLink domain associated with their rack.
  • Bug Fixes
    • Preserved previously reported domain information when discovery fails or returns an empty value.
    • Excluded deleted switches from domain updates and avoided unnecessary repeat updates.
  • Tests
    • Added coverage for rack grouping, domain discovery, updates, replacements, and unavailable domain data.

Walkthrough

The change adds nullable NVLink domain UUID tracking to switches. Rack monitoring performs NMX-C Hello operations, persists valid domain UUIDs for active rack switches, preserves prior values for nil or failed observations, and exposes the value through RPC.

Changes

NVLink domain tracking

Layer / File(s) Summary
Switch domain persistence
crates/api-db/migrations/..., crates/api-model/src/switch/mod.rs, crates/api-db/src/switch.rs
The switches table and Switch model now store an optional nvlink_domain_uuid. Rack-scoped persistence updates active switches when the observed domain changes and retains existing values for repeated observations.
Rack domain publication
crates/nvlink-manager/src/lib.rs
Rack-associated hosts use rack-scoped NMX-C groups. The monitor resolves rack endpoints, performs Hello calls, validates domain UUIDs, and publishes valid values before partition processing. Rack-only observations run separately, while nil UUIDs and publication failures do not overwrite stored values or stop reconciliation.
RPC switch exposure
crates/rpc/proto/forge.proto, rest-api/proto/core/src/v1/nico_nico.proto, crates/rpc/src/model/switch.rs
The RPC and REST protobuf Switch messages and RPC conversion now carry nvlink_domain_uuid. Tests cover populated and absent UUID values.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Monitor as NVLink monitor
  participant Endpoint as NMX-C endpoint
  participant Database as Switch database
  Monitor->>Endpoint: Resolve rack endpoint and send Hello
  Endpoint-->>Monitor: Return domain UUID
  Monitor->>Database: Persist UUID for active rack switches
Loading

Possibly related PRs

Suggested labels: rest-api

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes persisting and exposing the NVLink domain UUID, which is the main change.
Description check ✅ Passed The description directly explains the NVLink domain UUID feature, API exposure, purpose, issue link, and testing.
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.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔐 TruffleHog Secret Scan

No secrets or credentials found!

Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉

🔗 View scan details

🕐 Last updated: 2026-08-01 06:06:42 UTC | Commit: a8a5a81

@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 (2)
crates/nvlink-manager/src/lib.rs (2)

1385-1393: 🚀 Performance & Scalability | 🔵 Trivial

Consider bounding and parallelising the standalone Hello fan-out.

This loop contacts each rack endpoint serially. The iteration duration therefore grows linearly with the number of racks that have no managed hosts, while the iteration still holds ITERATION_WORK_KEY. The existing partition loops are also serial, so this matches current behavior and is not a regression.

If the rack count grows, run these observations concurrently with a bounded degree, for example a JoinSet capped by a semaphore, so a large site does not stretch the monitor cadence. A per-call timeout would also stop one unresponsive NMX-C endpoint from delaying every remaining rack.

🤖 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/nvlink-manager/src/lib.rs` around lines 1385 - 1393, Update the
standalone rack observation loop around
observe_and_record_rack_switch_domain_uuid to perform endpoint calls
concurrently with a bounded degree of parallelism, such as a semaphore-limited
JoinSet. Add a per-call timeout so an unresponsive endpoint cannot delay the
iteration indefinitely, while preserving the existing filter that skips racks
present in managed_host_snapshots_by_rack_id.

1638-1701: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Extract the shared Hello-and-parse sequence.

Lines 1643-1697 repeat the four-step sequence already implemented in process_nmx_c_partition_monitor_group at lines 1443-1523: build Endpoint, create the client, call hello, then parse the domain UUID. The two copies differ only in the failure reaction. The group path queues a PendingNullNvlinkObservation per reason and records metrics. This path only logs.

Extract one helper that returns the failure reason, then let each caller apply its own policy. The reason enum already exists, so the group path keeps its metric and queueing behavior and this path maps the reason to a warn.

♻️ Proposed shape for the shared helper
/// Resolves the NMX-C domain UUID for one endpoint.
///
/// Returns the reason on failure so callers can choose between queueing a
/// null observation and logging only.
async fn observe_domain_uuid(
    &self,
    endpoint_url: &str,
) -> Result<NvLinkDomainId, ChassisNmxCUnreachableReason> {
    let endpoint = Endpoint::new(endpoint_url)
        .map_err(|_| ChassisNmxCUnreachableReason::InvalidEndpointUri)?;
    let mut client = self
        .nmxc_client_pool
        .create_client(endpoint)
        .await
        .map_err(|_| ChassisNmxCUnreachableReason::ClientCreateFailed)?;
    let hello = client
        .hello(NMX_C_GATEWAY_ID)
        .await
        .map_err(|_| ChassisNmxCUnreachableReason::HelloFailed)?;

    domain_uuid_from_nmx_c_hello(&hello)
        .map_err(|_| ChassisNmxCUnreachableReason::DomainUuidParseFailed)
}

Keep the per-step error field in the logs. Either return the error alongside the reason, or log inside the helper before mapping.

🤖 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/nvlink-manager/src/lib.rs` around lines 1638 - 1701, Extract the
repeated Endpoint creation, NMX-C client creation, hello call, and domain UUID
parsing from observe_and_record_rack_switch_domain_uuid and
process_nmx_c_partition_monitor_group into a shared observe_domain_uuid helper
returning Result<NvLinkDomainId, ChassisNmxCUnreachableReason>. Preserve each
caller’s existing failure policy: the group path must retain metrics and
PendingNullNvlinkObservation queueing, while
observe_and_record_rack_switch_domain_uuid logs a warning; retain per-step error
details by returning or otherwise preserving the underlying errors.
🤖 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/nvlink-manager/src/lib.rs`:
- Around line 1385-1393: Update the standalone rack observation loop around
observe_and_record_rack_switch_domain_uuid to perform endpoint calls
concurrently with a bounded degree of parallelism, such as a semaphore-limited
JoinSet. Add a per-call timeout so an unresponsive endpoint cannot delay the
iteration indefinitely, while preserving the existing filter that skips racks
present in managed_host_snapshots_by_rack_id.
- Around line 1638-1701: Extract the repeated Endpoint creation, NMX-C client
creation, hello call, and domain UUID parsing from
observe_and_record_rack_switch_domain_uuid and
process_nmx_c_partition_monitor_group into a shared observe_domain_uuid helper
returning Result<NvLinkDomainId, ChassisNmxCUnreachableReason>. Preserve each
caller’s existing failure policy: the group path must retain metrics and
PendingNullNvlinkObservation queueing, while
observe_and_record_rack_switch_domain_uuid logs a warning; retain per-step error
details by returning or otherwise preserving the underlying errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b48adb77-32fe-4dba-9e26-7a3951f86299

📥 Commits

Reviewing files that changed from the base of the PR and between 5b9a312 and a8a5a81.

📒 Files selected for processing (6)
  • crates/api-db/migrations/20260801001826_switch_nvlink_domain_uuid.sql
  • crates/api-db/src/switch.rs
  • crates/api-model/src/switch/mod.rs
  • crates/nvlink-manager/src/lib.rs
  • crates/rpc/proto/forge.proto
  • crates/rpc/src/model/switch.rs

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

Clean! But yeah [for now] we need to sync up forge.proto for REST too; working on converging down to one.

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev

Copy link
Copy Markdown
Contributor Author

Clean! But yeah [for now] we need to sync up forge.proto for REST too; working on converging down to one.

Ahh, got it. Thanks!

@chet

chet commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Clean! But yeah [for now] we need to sync up forge.proto for REST too; working on converging down to one.

Ahh, got it. Thanks!

Yeah, and then the PR gets huge, haha.

@jayzhudev
jayzhudev merged commit ef4fffb into NVIDIA:main Aug 1, 2026
122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants