Skip to content

chore(rest-api): Update machine gRPC call to use structured fields (config/status) - #4377

Draft
nvlitagaki wants to merge 5 commits into
NVIDIA:mainfrom
nvlitagaki:agent/remove-deprecated-machine-fields
Draft

chore(rest-api): Update machine gRPC call to use structured fields (config/status)#4377
nvlitagaki wants to merge 5 commits into
NVIDIA:mainfrom
nvlitagaki:agent/remove-deprecated-machine-fields

Conversation

@nvlitagaki

Copy link
Copy Markdown
Contributor

Recently there were changes made in Core (#2847) that reworked the Machine gRPC proto to better conform to convention by sending config, status and metadata information as structs rather than a bunch of flat fields. This PR transitions the REST API to use these new structured fields and ignore the now deprecated flat fields.

Related issues

#2793

Type of Change

  • Change - Changes in existing functionality

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

@nvlitagaki nvlitagaki added this to the v2.2 milestone Jul 30, 2026
@nvlitagaki
nvlitagaki requested a review from a team as a code owner July 30, 2026 15:54
@nvlitagaki nvlitagaki added the rest-api Add this label when an issue or PR concerns NICo REST API label Jul 30, 2026
@nvlitagaki
nvlitagaki marked this pull request as draft July 30, 2026 15:55
@copy-pr-bot

copy-pr-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8c543980-8d9c-4fbd-a408-605e271fe6a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Summary by CodeRabbit

  • Bug Fixes

    • Improved machine and DPU data processing to accurately reflect status, health, hardware discovery, interfaces, capabilities, and maintenance information.
    • Corrected NVLink domain and associated DPU machine identification handling.
    • Improved reliability when displaying machine metadata, including chassis details, firmware settings, health alerts, and reboot information.
  • Tests

    • Updated coverage to validate the revised machine status and configuration data handling.

Walkthrough

Machine data handling is updated to read nested protobuf Status and Config fields through getters across REST API models, workflow activities, NICo mappings, mock servers, and tests. NVLink test data and extraction are aligned with the same representation.

Changes

Machine status and config migration

Layer / File(s) Summary
Workflow machine processing
rest-api/workflow/pkg/activity/machine/machine.go
Machine synchronization, capability processing, interface reconciliation, and NICo status evaluation now use nested status and config getters.
Workflow fixtures and validation
rest-api/workflow/pkg/activity/machine/machine_test.go
Inventory fixtures and assertions now construct and validate nested status, config, capability, health, and maintenance data.
API and NICo mappings
rest-api/api/pkg/api/model/*, rest-api/flow/internal/nicoapi/*, rest-api/site-workflow/pkg/grpc/server/*
API models, NICo mappings, and mock machines now read or provide discovery, health, reboot, capability, observation, firmware, and associated-DPU data through nested protobuf fields.
NVLink status alignment
rest-api/api/pkg/api/handler/instancebatch.go, rest-api/api/pkg/api/handler/instancebatch_test.go
NVLink domain extraction and test data now use nested machine status fields.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: migrating machine gRPC handling to structured config and status fields.
Description check ✅ Passed The description is directly aligned with the PR, explaining the move from flat machine fields to structured config, status, and metadata.
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.

@nvlitagaki

Copy link
Copy Markdown
Contributor Author

/ok to test f9b2681

@nvlitagaki

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown

@github-actions

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-07-30 16:00:08 UTC | Commit: f9b2681

@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 (5)
rest-api/workflow/pkg/activity/machine/machine_test.go (1)

1102-1140: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the expected capabilities set into a local.

The assertions are correct and index-aligned with the fixture, but the machineInfo1.Machine.GetStatus().GetCapabilities() chain is repeated nine times inside the loop. A single local hoisted above the loop would read considerably better.

♻️ Suggested refactor
expectedCaps := machineInfo1.Machine.GetStatus().GetCapabilities()
// ...then use expectedCaps.Gpu[0], expectedCaps.Memory[1], expectedCaps.Infiniband[0], etc.
🤖 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 `@rest-api/workflow/pkg/activity/machine/machine_test.go` around lines 1102 -
1140, Extract machineInfo1.Machine.GetStatus().GetCapabilities() into a local
expectedCaps variable before the capability iteration, then replace the repeated
chain references inside the loop with expectedCaps while preserving all existing
assertions and indexes.
rest-api/workflow/pkg/activity/machine/machine.go (3)

1026-1027: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant nil guards around a range loop.

Ranging over a nil slice is a no-op, and the generated getters are nil-receiver safe, so the entire double guard collapses to a single loop.

♻️ Suggested simplification
-	if controllerMachineStatus.GetHealth() != nil && controllerMachineStatus.GetHealth().Alerts != nil {
-		for _, alert := range controllerMachineStatus.GetHealth().Alerts {
+	for _, alert := range controllerMachineStatus.GetHealth().GetAlerts() {

Remember to unindent the loop body and drop the now-orphaned closing brace.

🤖 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 `@rest-api/workflow/pkg/activity/machine/machine.go` around lines 1026 - 1027,
In the alert-processing code using controllerMachineStatus.GetHealth().Alerts,
remove the redundant GetHealth and Alerts nil guards and iterate directly over
the alerts slice. Unindent the loop body and remove the orphaned closing brace,
preserving the existing alert-processing behavior.

766-772: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hoist the capabilities set into a local to reduce chain repetition.

The nil-safe chains are correct, but repeating GetStatus().GetCapabilities() seven times is needlessly verbose — and inconsistent with the local-variable pattern introduced in UpdateMachinesInDB.

♻️ Suggested refactor
-	controllerCapsCpu := controllerMachine.GetStatus().GetCapabilities().GetCpu()
-	controllerCapsGpu := controllerMachine.GetStatus().GetCapabilities().GetGpu()
-	controllerCapsDpu := controllerMachine.GetStatus().GetCapabilities().GetDpu()
-	controllerCapsMemory := controllerMachine.GetStatus().GetCapabilities().GetMemory()
-	controllerCapsInfiniband := controllerMachine.GetStatus().GetCapabilities().GetInfiniband()
-	controllerCapsNetwork := controllerMachine.GetStatus().GetCapabilities().GetNetwork()
-	controllerCapsStorage := controllerMachine.GetStatus().GetCapabilities().GetStorage()
+	controllerCaps := controllerMachine.GetStatus().GetCapabilities()
+
+	controllerCapsCpu := controllerCaps.GetCpu()
+	controllerCapsGpu := controllerCaps.GetGpu()
+	controllerCapsDpu := controllerCaps.GetDpu()
+	controllerCapsMemory := controllerCaps.GetMemory()
+	controllerCapsInfiniband := controllerCaps.GetInfiniband()
+	controllerCapsNetwork := controllerCaps.GetNetwork()
+	controllerCapsStorage := controllerCaps.GetStorage()
🤖 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 `@rest-api/workflow/pkg/activity/machine/machine.go` around lines 766 - 772, In
the capability assignments near the machine update logic, store
controllerMachine.GetStatus().GetCapabilities() in a local variable once, then
use that local for the CPU, GPU, DPU, memory, InfiniBand, network, and storage
lookups. Preserve the existing nil-safe behavior and follow the local-variable
pattern used by UpdateMachinesInDB.

285-294: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inconsistent controllerMachineConfig access convention across both maintenance blocks. Both sites gate on the nil-safe GetMaintenanceStartTime() and then read MaintenanceReference as a raw field — one site adds a redundant != nil guard, the other omits it. Neither can panic (a nil *MachineConfig receiver returns nil from the getter), but the divergent style invites future misreading. Settle on one convention.

  • rest-api/workflow/pkg/activity/machine/machine.go#L285-L294: use GetMaintenanceReference() (or add the explicit nil guard) and hoist the duplicated GetInterfaces() call into a local.
  • rest-api/workflow/pkg/activity/machine/machine.go#L1052-L1057: drop the unreachable-false controllerMachineConfig != nil check and match whichever accessor style is chosen above.
🤖 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 `@rest-api/workflow/pkg/activity/machine/machine.go` around lines 285 - 294,
The maintenance handling in controllerMachineConfig uses inconsistent nil-check
and accessor conventions. At
rest-api/workflow/pkg/activity/machine/machine.go:285-294, use the nil-safe
GetMaintenanceReference() accessor and hoist the duplicated
controllerMachineStatus.GetInterfaces() call into a local; at
rest-api/workflow/pkg/activity/machine/machine.go:1052-1057, remove the
redundant controllerMachineConfig != nil check and apply the same accessor
convention.
rest-api/api/pkg/api/model/dpumachine_test.go (1)

32-79: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend assertions to cover Interfaces and Health.

The fixture now populates Interfaces and Health under the new nested Status, but no assertion verifies dpuMachine.Interfaces or dpuMachine.Health were actually mapped by FromProto. Since this is precisely the migrated path, add coverage to catch any regression in the new getter wiring.

✅ Suggested additional assertions
 	assert.Equal(t, "test-sys-vendor", *dpuMachine.DMIData.SysVendor)
+	require.Len(t, dpuMachine.Interfaces, 1)
+	assert.Equal(t, "test-interface-id", dpuMachine.Interfaces[0].ID)
+	require.NotNil(t, dpuMachine.Health)
+	assert.Equal(t, "test-health-source", dpuMachine.Health.Source)

Also applies to: 108-118

🤖 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 `@rest-api/api/pkg/api/model/dpumachine_test.go` around lines 32 - 79, Extend
the FromProto test assertions for the populated nested Status fixture to verify
dpuMachine.Interfaces and dpuMachine.Health, including their representative IDs
and health fields. Add these checks alongside the existing mapped-field
assertions so regressions in the migrated getter wiring are detected.
🤖 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 `@rest-api/api/pkg/api/model/dpumachine_test.go`:
- Around line 32-79: Extend the FromProto test assertions for the populated
nested Status fixture to verify dpuMachine.Interfaces and dpuMachine.Health,
including their representative IDs and health fields. Add these checks alongside
the existing mapped-field assertions so regressions in the migrated getter
wiring are detected.

In `@rest-api/workflow/pkg/activity/machine/machine_test.go`:
- Around line 1102-1140: Extract
machineInfo1.Machine.GetStatus().GetCapabilities() into a local expectedCaps
variable before the capability iteration, then replace the repeated chain
references inside the loop with expectedCaps while preserving all existing
assertions and indexes.

In `@rest-api/workflow/pkg/activity/machine/machine.go`:
- Around line 1026-1027: In the alert-processing code using
controllerMachineStatus.GetHealth().Alerts, remove the redundant GetHealth and
Alerts nil guards and iterate directly over the alerts slice. Unindent the loop
body and remove the orphaned closing brace, preserving the existing
alert-processing behavior.
- Around line 766-772: In the capability assignments near the machine update
logic, store controllerMachine.GetStatus().GetCapabilities() in a local variable
once, then use that local for the CPU, GPU, DPU, memory, InfiniBand, network,
and storage lookups. Preserve the existing nil-safe behavior and follow the
local-variable pattern used by UpdateMachinesInDB.
- Around line 285-294: The maintenance handling in controllerMachineConfig uses
inconsistent nil-check and accessor conventions. At
rest-api/workflow/pkg/activity/machine/machine.go:285-294, use the nil-safe
GetMaintenanceReference() accessor and hoist the duplicated
controllerMachineStatus.GetInterfaces() call into a local; at
rest-api/workflow/pkg/activity/machine/machine.go:1052-1057, remove the
redundant controllerMachineConfig != nil check and apply the same accessor
convention.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 84b2a598-d224-4484-9ac9-31053b2b9c66

📥 Commits

Reviewing files that changed from the base of the PR and between 8d7f986 and f9b2681.

📒 Files selected for processing (11)
  • rest-api/api/pkg/api/handler/instancebatch.go
  • rest-api/api/pkg/api/handler/instancebatch_test.go
  • rest-api/api/pkg/api/model/dpumachine.go
  • rest-api/api/pkg/api/model/dpumachine_test.go
  • rest-api/api/pkg/api/model/machine.go
  • rest-api/api/pkg/api/model/machine_test.go
  • rest-api/flow/internal/nicoapi/grpc.go
  • rest-api/flow/internal/nicoapi/model.go
  • rest-api/site-workflow/pkg/grpc/server/nico_test_server.go
  • rest-api/workflow/pkg/activity/machine/machine.go
  • rest-api/workflow/pkg/activity/machine/machine_test.go

Signed-off-by: Leah Itagaki <litagaki@nvidia.com>
Signed-off-by: Leah Itagaki <litagaki@nvidia.com>

Copy link
Copy Markdown
Contributor Author

/ok to test 5ea041d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rest-api Add this label when an issue or PR concerns NICo REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant