Skip to content

feat(rest-api): add VPC config/runtimeStatus response shape with backward compatibility#3350

Draft
hwadekar-nv wants to merge 2 commits into
NVIDIA:mainfrom
hwadekar-nv:feat/deprecate-vpc-config
Draft

feat(rest-api): add VPC config/runtimeStatus response shape with backward compatibility#3350
hwadekar-nv wants to merge 2 commits into
NVIDIA:mainfrom
hwadekar-nv:feat/deprecate-vpc-config

Conversation

@hwadekar-nv

@hwadekar-nv hwadekar-nv commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the REST VPC response to the config/status pattern introduced in Core, while keeping the existing flat VPC fields populated for backward compatibility.
This is the REST-side follow-up to Core PR #2613 for issue #928.

Changes

  • Synced REST Core proto with VpcConfig / structured VpcStatus from Core
  • Updated DB Vpc.ToProto() / FromProto() to populate canonical config/status and mirror deprecated flat fields
  • Added REST response types:
    • config — desired VPC configuration
    • runtimeStatus — observed runtime state (active VNI)
  • Kept existing flat response fields (networkVirtualizationType, requestedVni, vni, networkSecurityGroupId, etc.) populated for existing clients
  • Create/update request bodies remain flat, matching Core behavior
  • Updated workflow VPC reconciliation to read site-reported VPCs via config-first helpers with deprecated-field fallback
  • Updated OpenAPI with VpcConfig and VpcRuntimeStatus; marked superseded flat fields as deprecated
  • Added unit tests for proto conversion, API mapping, and compat helpers

Backward compatibility

  • Existing clients can continue reading top-level VPC fields unchanged
  • New clients can use config and runtimeStatus
  • Lifecycle status (Pending/Ready/etc.) is unchanged; runtimeStatus holds proto-aligned observed VNI

References

Type of Change

  • Add - New feature or capability

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated

Additional Notes

@hwadekar-nv hwadekar-nv self-assigned this Jul 10, 2026
@hwadekar-nv hwadekar-nv requested a review from a team as a code owner July 10, 2026 00:51
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

No Grype artifacts were found to aggregate.

@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-10 00:56:35 UTC | Commit: ee39bac

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features

    • VPC API responses now include structured configuration and runtime status details.
    • Added clearer fields for desired networking settings and the active VNI.
    • Updated API schemas to document the new VPC structure and identify legacy fields.
  • Bug Fixes

    • Improved compatibility when reading and writing VPC data across structured and legacy formats.
    • Ensured reported VPC settings and runtime identifiers are consistently synchronized.
  • Documentation

    • Updated protocol terminology and resource definitions to reflect current naming and compatibility requirements.

Walkthrough

The change adds structured VPC configuration and runtime status mappings across API, database, workflow, and OpenAPI layers. It also updates core protobuf imports, compatibility contracts, generated type names, legacy domain messages, and Forge-related documentation.

Changes

VPC compatibility

Layer / File(s) Summary
VPC API contract
rest-api/openapi/spec.yaml
Adds VpcConfig and VpcRuntimeStatus schemas, wires them into VPC responses, and deprecates corresponding flat fields.
VPC persistence compatibility
rest-api/db/pkg/db/model/vpc.go, rest-api/db/pkg/db/model/vpc_test.go
Adds structured proto extraction helpers, updates ToProto and FromProto precedence, and tests structured/deprecated field compatibility.
VPC reconciliation and API mapping
rest-api/workflow/pkg/activity/vpc/vpc.go, rest-api/api/pkg/api/handler/vpc.go, rest-api/api/pkg/api/model/*
Uses normalized VPC proto values during workflow updates and exposes nested API configuration and runtime status fields.

Core protobuf contracts

Layer / File(s) Summary
Shared proto imports and generation settings
rest-api/proto/core/src/v1/*_nico.proto
Switches shared imports, removes file-level Go package options, and applies related header and formatting updates.
Domain and resource contracts
rest-api/proto/core/src/v1/dns_nico.proto, rest-api/proto/core/src/v1/nico_nico.proto, rest-api/proto/core/src/v1/site_explorer_nico.proto
Adds legacy domain messages, reserves legacy resource fields, changes inventory and enum contracts, and updates domain and power-state types.
Forge terminology and documentation
rest-api/proto/core/src/v1/mlx_device_nico.proto, rest-api/proto/core/src/v1/nico_nico.proto, rest-api/proto/core/src/v1/fmds_nico.proto
Updates service and field documentation from NICo terminology to Forge, Carbide, and related component names.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Controller as Controller VPC
  participant Helpers as VpcProto helpers
  participant Workflow as UpdateVpcsInDB
  participant Database as VPC database
  Controller->>Helpers: Extract structured config and runtime status
  Helpers->>Workflow: Return normalized reported fields
  Workflow->>Database: Compare and update VPC state
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding VPC config/runtimeStatus response fields with backward compatibility.
Description check ✅ Passed The description is directly aligned with the changeset and accurately describes the VPC response and compatibility updates.
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.

@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: 2

🧹 Nitpick comments (1)
rest-api/db/pkg/db/model/vpc.go (1)

209-223: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the shared pointer converters here

rest-api/db/pkg/db/model/vpc.go:209-223 duplicates cutil.IntPtrToUint32Ptr / cutil.Uint32PtrToIntPtr, and rest-api/db/pkg/db/model already imports rest-api/common/pkg/util elsewhere. Move these calls to the shared helper and delete the local copies so the trusted-cast behavior stays centralized.

🤖 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/db/pkg/db/model/vpc.go` around lines 209 - 223, Replace all uses of
the local intPtrToUint32Ptr and uint32PtrToIntPtr functions in the VPC model
with cutil.IntPtrToUint32Ptr and cutil.Uint32PtrToIntPtr, using the existing
util import; then delete both local converter functions.

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 `@rest-api/proto/core/src/v1/nico_nico.proto`:
- Around line 5161-5164: Rename all generated Go enum references from
InterfaceFunctionType_PHYSICAL_FUNCTION and
InterfaceFunctionType_VIRTUAL_FUNCTION to the constants produced by PHYSICAL and
VIRTUAL, and regenerate the Go bindings from the updated InterfaceFunctionType
definition. Update all in-tree consumers and surrounding field comments to use
the new names while preserving the existing wire values.

In `@rest-api/proto/core/src/v1/nmx_c_nico.proto`:
- Around line 1-14: Remove the contradictory duplicate license header in
nmx_c_nico.proto and retain one SPDX identifier consistent with neighboring
files and the repository’s licensing policy; update the header so it does not
simultaneously declare Apache-2.0 and LicenseRef-NvidiaProprietary.

---

Nitpick comments:
In `@rest-api/db/pkg/db/model/vpc.go`:
- Around line 209-223: Replace all uses of the local intPtrToUint32Ptr and
uint32PtrToIntPtr functions in the VPC model with cutil.IntPtrToUint32Ptr and
cutil.Uint32PtrToIntPtr, using the existing util import; then delete both local
converter functions.
🪄 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: bf84308e-3845-4ab5-91e2-9236f2db2844

📥 Commits

Reviewing files that changed from the base of the PR and between 699951d and c1d8700.

⛔ Files ignored due to path filters (35)
  • rest-api/sdk/standard/client.go is excluded by !rest-api/sdk/standard/client.go
  • rest-api/sdk/standard/model_batch_instance_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_machine.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_machine_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_machine_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_power_shelf.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_power_shelf_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_power_shelf_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_rack.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_rack_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_rack_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_switch.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_switch_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_expected_switch_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_infini_band_partition.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_infini_band_partition_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_infini_band_partition_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance_type.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance_type_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance_type_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_instance_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_interface.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_interface_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_machine.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_machine_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_network_security_group.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_network_security_group_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_network_security_group_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_vpc.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_vpc_config.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_vpc_create_request.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_vpc_runtime_status.go is excluded by !rest-api/sdk/standard/model_*.go
  • rest-api/sdk/standard/model_vpc_update_request.go is excluded by !rest-api/sdk/standard/model_*.go
📒 Files selected for processing (19)
  • rest-api/api/pkg/api/handler/vpc.go
  • rest-api/api/pkg/api/model/vpc.go
  • rest-api/api/pkg/api/model/vpc_test.go
  • rest-api/db/pkg/db/model/vpc.go
  • rest-api/db/pkg/db/model/vpc_test.go
  • rest-api/docs/index.html
  • rest-api/openapi/spec.yaml
  • rest-api/proto/core/src/v1/common_nico.proto
  • rest-api/proto/core/src/v1/dns_nico.proto
  • rest-api/proto/core/src/v1/fmds_nico.proto
  • rest-api/proto/core/src/v1/health_nico.proto
  • rest-api/proto/core/src/v1/machine_discovery_nico.proto
  • rest-api/proto/core/src/v1/measured_boot_nico.proto
  • rest-api/proto/core/src/v1/mlx_device_nico.proto
  • rest-api/proto/core/src/v1/nico_nico.proto
  • rest-api/proto/core/src/v1/nmx_c_nico.proto
  • rest-api/proto/core/src/v1/scout_firmware_upgrade_nico.proto
  • rest-api/proto/core/src/v1/site_explorer_nico.proto
  • rest-api/workflow/pkg/activity/vpc/vpc.go
💤 Files with no reviewable changes (2)
  • rest-api/proto/core/src/v1/common_nico.proto
  • rest-api/proto/core/src/v1/scout_firmware_upgrade_nico.proto

Comment on lines 5161 to 5164
enum InterfaceFunctionType {
PHYSICAL_FUNCTION = 0;
VIRTUAL_FUNCTION = 1;
PHYSICAL = 0;
VIRTUAL = 1;
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "== Go references to the renamed enum constants =="
rg -nP 'InterfaceFunctionType_(PHYSICAL|VIRTUAL)(_FUNCTION)?\b' rest-api/ --type=go

echo "== lingering doc references to old names =="
rg -nP '(PHYSICAL_FUNCTION|VIRTUAL_FUNCTION)' rest-api/proto/core/src/v1/nico_nico.proto

Repository: NVIDIA/infra-controller

Length of output: 5677


Regenerate the Go bindings with this rename The wire values are unchanged, but the generated Go constants change, so any consumer still referring to InterfaceFunctionType_PHYSICAL_FUNCTION / ..._VIRTUAL_FUNCTION will fail to compile. Several in-tree references and the surrounding field comments still use the old names; update them together.

🤖 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/proto/core/src/v1/nico_nico.proto` around lines 5161 - 5164, Rename
all generated Go enum references from InterfaceFunctionType_PHYSICAL_FUNCTION
and InterfaceFunctionType_VIRTUAL_FUNCTION to the constants produced by PHYSICAL
and VIRTUAL, and regenerate the Go bindings from the updated
InterfaceFunctionType definition. Update all in-tree consumers and surrounding
field comments to use the new names while preserving the existing wire values.

Source: Path instructions

Comment on lines +1 to +14
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
//

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Contradictory license headers.

The header now declares two conflicting SPDX identifiers: Apache-2.0 (Line 2) immediately followed by a LicenseRef-NvidiaProprietary block (Lines 5–13) stating that use/redistribution is "strictly prohibited". In an Apache-2.0 open-source repository this dual header is contradictory and will confuse both humans and SPDX tooling. Please retain a single, correct identifier consistent with the rest of the tree.

Proposed correction
 // SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 // SPDX-License-Identifier: Apache-2.0
-
-//
-// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
-//
-// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
-// property and proprietary rights in and to this material, related
-// documentation and any modifications thereto. Any use, reproduction,
-// disclosure or distribution of this material and related documentation
-// without an express license agreement from NVIDIA CORPORATION or
-// its affiliates is strictly prohibited.
-//
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
//
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
🤖 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/proto/core/src/v1/nmx_c_nico.proto` around lines 1 - 14, Remove the
contradictory duplicate license header in nmx_c_nico.proto and retain one SPDX
identifier consistent with neighboring files and the repository’s licensing
policy; update the header so it does not simultaneously declare Apache-2.0 and
LicenseRef-NvidiaProprietary.

@copy-pr-bot

copy-pr-bot Bot commented Jul 10, 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.

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