Skip to content

chore(rest-api): Apply our FromProto/ToProto modeling to InfiniBandPartition#2116

Open
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:proto-infinibandpartition-receivers
Open

chore(rest-api): Apply our FromProto/ToProto modeling to InfiniBandPartition#2116
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:proto-infinibandpartition-receivers

Conversation

@chet
Copy link
Copy Markdown
Contributor

@chet chet commented Jun 2, 2026

Description

This is NVIDIA/infra-controller-rest#594, re-opened over here (and had already gone through @coderabbitai feedback loops, curious to see what happens here).

Brings InfiniBandPartition in line with the proto-modeling changes. The handler keeps its REST surface; Create and Update route through ToProto on the API request types and the entity gains the full round-trip plus a delete-request builder. The entity also picks up the typed Labels field per the InstanceType reference in #540 -- it reaches Labels.ToProto() / Labels.FromProto(...) directly.

Primary callouts are:

  • API request side: APIInfiniBandPartitionCreateRequest.ToProto(ibp) and APIInfiniBandPartitionUpdateRequest.ToProto(ibp); both source corresponding fields via ibp.ToProto().
  • Entity side: InfiniBandPartition.ToProto, FromProto, and ToDeletionRequestProto. There's also a new InfiniBandPartition.Validate() so site-driven FromProto callers can do FromProto + Validate -- mirroring the MachineCapability pattern (which went in at fix: health service health-report now uses coalescing queue #569).
  • InfiniBandPartitionStatus is now a typed string with its own .FromProto(state) and .Message() methods, replacing the InfiniBandPartitionStatusFromProto(state) helper that split a single proto state into (status, message). The workflow activity caller is just a two-liner now.
  • Handler simplified to one-liners, and the inline cwssaws / model/util imports drop.

As part of the new typed InfiniBandPartitionStatus (and the already-typed Labels), the typing propagates through the API and DAO layers, but nothing changes on the wire -- JSON serialization of type X string is identical to string, the OpenAPI spec still just says "string", and the SDK is unaffected.

Tests added!

Signed-off-by: Chet Nichols III chetn@nvidia.com

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

Related Issues (Optional)

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

Summary by CodeRabbit

  • Bug Fixes

    • Corrected InfiniBand partition status handling in test scenarios.
  • Refactor

    • Improved internal type safety for InfiniBand partition status management.
    • Enhanced validation for InfiniBand partition operations and request parameters.

@chet chet requested a review from a team as a code owner June 2, 2026 18:09
@chet chet requested a review from thossain-nv June 2, 2026 18:10
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🔐 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-06-02 18:11:28 UTC | Commit: 0c75763

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
nico-flow 66 4 34 18 2 8
nico-nsm 82 2 28 43 9 0
nico-psm 67 4 35 18 2 8
nico-rest-api 100 6 53 30 3 8
nico-rest-cert-manager 65 4 34 18 1 8
nico-rest-db 66 4 34 18 2 8
nico-rest-site-agent 65 4 34 18 1 8
nico-rest-site-manager 65 4 34 18 1 8
nico-rest-workflow 67 4 35 18 2 8
TOTAL 643 36 321 199 23 64

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

@chet chet changed the title chore: Apply the new FromProto/ToProto modeling to InfiniBandPartition chore(rest-api): Apply our FromProto/ToProto modeling to InfiniBandPartition Jun 2, 2026
@chet
Copy link
Copy Markdown
Contributor Author

chet commented Jun 2, 2026

@coderabbitai There is a .coderabbit.yaml in rest-api/.coderabbit.yaml in this repo that you can use, with a rest-api/AGENTS.md with general guidelines. This PR actually should be good to go based on previous work we've done, but looping you in for funsies anyway.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== .coderabbit.yaml ==="
fd -i '.coderabbit.yaml' rest-api/ | xargs cat 2>/dev/null || cat rest-api/.coderabbit.yaml 2>/dev/null || echo "NOT FOUND"

echo ""
echo "=== AGENTS.md ==="
cat rest-api/AGENTS.md 2>/dev/null || echo "NOT FOUND"

Length of output: 28384


⚙️ CodeRabbit configuration inspected

Length of output: 6441



@chet Got it — I've read through rest-api/AGENTS.md and internalized the guidelines. I'll apply them during the review: proto round-trip receiver methods, ValidateToProto pairing, named types owning their own proto behavior, cdb.WithTx/WithTxResult transaction patterns, range-based iteration preferences, and the split assign-and-condition error style. The .coderabbit.yaml at rest-api/.coderabbit-yaml didn't show up in the tree, but the AGENTS.md has everything I need.

Kicking off the review now!


✏️ Learnings added
Learnt from: chet
URL: https://github.com/NVIDIA/infra-controller/pull/2116

Timestamp: 2026-06-02T19:06:09.901Z
Learning: In the `infra-controller-rest` codebase (Go, Echo v4), proto conversion follows strict receiver-method conventions documented in `rest-api/AGENTS.md`:
1. Primary entity ↔ proto: `(*T).ToProto(...)` and `(*T).FromProto(p *protoT, ...)` on DB models in `db/pkg/db/model/`.
2. API request → proto: `(*APIXCreateRequest).ToProto(...)` and `(*APIXUpdateRequest).ToProto(...)` on API request types in `api/pkg/api/model/`.
3. Entity-only proto shapes (delete, maintenance): `(*T).ToDeletionRequestProto()`, `(*T).ToMaintenanceRequestProto(...)` on DB models.
`ToProto` does not return errors — validation lives in `(req *APIX).Validate() error` which must be called before `ToProto`. `Vpc` is the reference for rules 1–3; `InstanceType` is the reference for everything else (typed slice, typed map, ozzo composition).

Learnt from: chet
URL: https://github.com/NVIDIA/infra-controller/pull/2116

Timestamp: 2026-06-02T19:06:09.901Z
Learning: In `infra-controller-rest` (Go), named types own their proto behavior — `map`, `slice`, or other primitive composites representing domain concepts get named types with methods, not free functions. Examples: `db/pkg/db/model.Labels` (`type Labels map[string]string` with `ToProto`/`FromProto`), `MachineCapabilityType`/`MachineCapabilityDeviceType` (`type X string` with typed proto enum round-trip). Free functions like `LabelsToProto(m map[string]string)` are an anti-pattern.

Learnt from: chet
URL: https://github.com/NVIDIA/infra-controller/pull/2116

Timestamp: 2026-06-02T19:06:09.901Z
Learning: In `infra-controller-rest` (Go), DB handler code uses closure-based transaction helpers `cdb.WithTx` / `cdb.WithTxResult` from `db/pkg/db`, never manual `BeginTx`/`Commit`/`Rollback`. Key rules: reads that are pure input-validation belong outside the tx; advisory locks go at the top of the closure for TOCTOU-prone flows; workflow-trigger flows use the `timeoutResp` pattern; inside the closure return `cutil.NewAPIError(code, msg, nil)`, outside return `cutil.NewAPIErrorResponse(c, code, msg, nil)`; never leak raw DB errors to clients (pass `nil` as data arg). Instance handlers in `api/pkg/api/handler/instance.go` are the reference.

Learnt from: chet
URL: https://github.com/NVIDIA/infra-controller/pull/2116

Timestamp: 2026-06-02T19:06:09.901Z
Learning: In `infra-controller-rest` (Go), the module is on Go 1.25. Prefer range-based iteration: `for i := range n` for counting loops, `slices.Backward` for reverse loops, plain `range` for index loops over slices. Keep C-style `for` only for byte-wise string scans, look-ahead/behind index mutations, 1-indexed or offset-start loops, and generated code. See `rest-api/AGENTS.md` for full guidelines.

Learnt from: chet
URL: https://github.com/NVIDIA/infra-controller/pull/2116

Timestamp: 2026-06-02T19:06:09.901Z
Learning: In `infra-controller-rest` (Go), error handling convention inside `cdb.WithTx` closures prefers split assign-and-condition over combined form: `derr := someDAO.Action(...)\nif derr != nil { ... }` rather than `if derr := someDAO.Action(...); derr != nil { ... }`. This is a consistent reviewer preference across the codebase.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Actions performed

Review triggered.

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the CodeRabbit config and AGENTS.md guidelines
echo "=== rest-api/.coderabbit.yaml ==="
cat rest-api/.coderabbit.yaml 2>/dev/null || echo "FILE NOT FOUND"

echo ""
echo "=== rest-api/AGENTS.md ==="
cat rest-api/AGENTS.md 2>/dev/null || echo "FILE NOT FOUND"

echo ""
echo "=== PR diff (files changed) ==="
gh pr diff 2116 --name-only 2>/dev/null

echo ""
echo "=== PR diff ==="
gh pr diff 2116 2>/dev/null

Length of output: 104793



@chet — looks like the prior feedback loop paid off. This lands cleanly against every convention in AGENTS.md:

  • Named types own their proto behaviorInfiniBandPartitionStatus now carries FromProto/Message; Labels reaches its own .ToProto()/.FromProto(...) directly on the field. ✓
  • Entity↔proto surfaceToProto, FromProto, ToDeletionRequestProto all live on *InfiniBandPartition as expected. ✓
  • Per-API-request→protoAPIInfiniBandPartitionCreateRequest.ToProto and APIInfiniBandPartitionUpdateRequest.ToProto delegate straight through ibp.ToProto() rather than re-deriving fields. ✓
  • Validate+ToProto cooperationToProto is a pure mapper; validation including the new description-length bounds sits entirely in Validate(). ✓
  • DAO gatesCreate calls ibp.Validate() before insert; Update validates the incoming Status against InfiniBandPartitionStatusMap before accepting it. ✓
  • Handler cleanup — inline proto construction gone, cwssaws/model/util imports dropped, everything is a one-liner now. ✓
  • getInfiniBandPartitionStatus removal — the workflow activity caller is now status.FromProto(...); message := status.Message(). ✓

A couple of things worth naming explicitly since they're easy to miss:

  1. Bonus bug fix — the workflow activity's missing-on-site branch was logging err instead of serr. Caught and fixed here.
  2. Test constant correctionTestInfiniBandInterfaceSQLDAO_Update was assigning InfiniBandPartitionStatusPending to an InfiniBandInterface.Status field; now correctly uses InfiniBandInterfaceStatusPending. The type system enforced this, which is exactly the value of the typed-status approach.
  3. validateInfiniBandPartitionNameWhitespace as a free function in the DB model is the right call — importing api/pkg/api/model/util from db/pkg/db/model would create a dependency cycle.

Nothing to block on. LGTM.

[approve]

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Walkthrough

This PR introduces strong typing for InfiniBand Partition status handling by converting from plain string to a named InfiniBandPartitionStatus enum. The change propagates through the data model, API layers, handlers, workflow integration, and all supporting tests, enabling compile-time safety and clearer intent across status lifecycle management.

Changes

InfiniBand Partition Status Enum and Typed Integration

Layer / File(s) Summary
DB Model Status Enum Type and Validation
rest-api/db/pkg/db/model/infinibandpartition.go, rest-api/db/pkg/db/model/helper_test.go
Introduces InfiniBandPartitionStatus enum with typed constants (Pending, Provisioning, Ready, Configuring, Error, Deleting), typed InfiniBandPartitionStatusMap, and proto conversion helpers (FromProto, Message). Updates InfiniBandPartition model and input struct field types. Adds validation in DAO Create and Update methods.
API Request/Response Model Updates
rest-api/api/pkg/api/model/infinibandpartition.go, rest-api/api/pkg/api/model/infinibandpartition_test.go
Changes APIInfiniBandPartition.Status and APIInfiniBandPartitionSummary.Status fields from string to cdbm.InfiniBandPartitionStatus. Converts Validate methods to pointer receivers. Adds ToProto methods for both create and update requests that construct workflow proto objects from persisted DB entities. Extends validation and proto conversion test coverage.
API Handler Implementation Refactoring
rest-api/api/pkg/api/handler/infinibandpartition.go
Refactors Create, GetAll, Update, and Delete handlers to use ToProto/ToDeletionRequestProto methods instead of manually building proto requests. Removes inline proto construction utilities. Updates status-detail creation to use typed enum values. Adjusts status query validation to cast incoming string to enum type.
API Handler and Integration Tests
rest-api/api/pkg/api/handler/infinibandpartition_test.go, rest-api/api/pkg/api/handler/instance_test.go, rest-api/api/pkg/api/handler/instancebatch_test.go, rest-api/api/pkg/api/handler/infinibandinterface_test.go, rest-api/api/pkg/api/handler/nvlinkinterface_test.go
Updates test fixtures across multiple handler tests to construct InfiniBand partition status pointers using cdb.Ptr(cdbm.InfiniBandPartitionStatus...) instead of cdb.GetStrPtr(...). Updates test helpers and seeding logic to use typed status values. Expands instance update tests with additional partition fixtures for comprehensive interface wiring.
DB Model Conversion and Validation Tests
rest-api/db/pkg/db/model/infinibandpartition_test.go, rest-api/db/pkg/db/model/infinibandinterface_test.go
Adds comprehensive tests for proto conversions, status mapping, and validation. Updates DAO tests to use typed status pointers in fixtures and filter inputs. Changes test struct field types to InfiniBandPartitionStatus. Adds negative test cases for invalid status values with early-return flow on errors. Corrects interface status assertion in Update test.
Workflow Activity Status Persistence
rest-api/workflow/pkg/activity/infinibandpartition/infinibandpartition.go, rest-api/workflow/pkg/util/testing.go
Refactors UpdateInfiniBandPartitionsInDB to use InfiniBandPartitionStatus.FromProto() for proto-to-enum conversion. Updates updateIBPStatusInDB helper to accept *cdbm.InfiniBandPartitionStatus instead of *string, simplifying status-detail persistence. Updates workflow test helper to use typed status parameter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A typed enum hops through the stack,
From DB to API, keeping status on track,
Workflows convert with proto precision true,
Where once strings roamed, strong types now brew!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.63% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: applying FromProto/ToProto modeling patterns to InfiniBandPartition, which is the core refactor across multiple files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rest-api/api/pkg/api/handler/infinibandpartition.go (1)

1102-1104: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Pass the literal workflow name to TerminateWorkflowOnTimeOut.

The workflow name argument should be "DeleteInfiniBandPartitionV2" (matching the workflow executed on line 1076) rather than the shortened "Delete" label. As per coding guidelines, "Pass the literal workflow name to common.TerminateWorkflowOnTimeOut (e.g., "CreateInstanceV2"), not shortened action labels".

Proposed fix
 				timeoutResp = func() error {
-					return common.TerminateWorkflowOnTimeOut(c, logger, stc, wid, wferr, "InfiniBandPartition", "Delete")
+					return common.TerminateWorkflowOnTimeOut(c, logger, stc, wid, wferr, "InfiniBandPartition", "DeleteInfiniBandPartitionV2")
 				}
🤖 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/handler/infinibandpartition.go` around lines 1102 -
1104, The call to common.TerminateWorkflowOnTimeOut inside the timeoutResp
closure uses the shortened action label "Delete" but should pass the literal
workflow name; update the argument passed to common.TerminateWorkflowOnTimeOut
in the timeoutResp definition to "DeleteInfiniBandPartitionV2" (matching the
workflow executed earlier) so the signature used by TerminateWorkflowOnTimeOut
accurately reflects the workflow name.
🧹 Nitpick comments (2)
rest-api/db/pkg/db/model/infinibandpartition_test.go (2)

876-918: ⚡ Quick win

Assert the invalid-status failure explicitly.

Line 916 and Line 1052 only check that some error occurred, so these cases still pass on unrelated setup or DAO failures. Pin the regression to the validation path with require.ErrorContains(..., "invalid InfiniBandPartition Status").

Suggested tightening
-			require.Equal(t, tt.wantErr, err != nil)
-			if tt.wantErr {
-				return
-			}
+			if tt.wantErr {
+				require.ErrorContains(t, err, "invalid InfiniBandPartition Status")
+				return
+			}
+			require.NoError(t, err)

Also applies to: 1015-1055

🤖 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/infinibandpartition_test.go` around lines 876 - 918,
The test currently only asserts an error occurred for invalid status cases;
change the assertion to explicitly check the validation error message from
InfiniBandPartitionSQLDAO.Create by using require.ErrorContains(err, "invalid
InfiniBandPartition Status") (or the exact validation text returned by Create)
when tt.wantErr is true, so replace the generic require.Equal(t, tt.wantErr, err
!= nil) + return with a targeted require.ErrorContains check; apply the same
change to the other identical test block around the 1015–1055 region.

1057-1057: ⚡ Quick win

Drop the debug print from the update test.

Line 1057 writes to stdout on every passing run and adds CI log noise without improving the assertion set.

Suggested cleanup
-			fmt.Printf("\ngot ID: %v, Created: %v, Updated: %v", got.ID.String(), got.Created, got.Updated)
🤖 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/infinibandpartition_test.go` at line 1057, Remove
the stray debug fmt.Printf call in the update test in
infinibandpartition_test.go (the line printing "got ID: ... Created: ...
Updated: ..."); delete that printf so the test no longer writes to stdout on
success and noise the CI logs while leaving all assertions intact.
🤖 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/api/pkg/api/handler/instance_test.go`:
- Around line 4105-4106: The InfiniBand partition fixture ibp5 is created on st2
but the "doesn't have InfiniBand Capability" update case uses an instance on
st1, causing the test to fail for a site mismatch before hitting the capability
check; fix by creating ibp5 on st1 instead (update the testBuildIBPartition call
that constructs ibp5 to pass st1 rather than st2) so the test exercises the
capability-check branch as intended.

In `@rest-api/workflow/pkg/activity/infinibandpartition/infinibandpartition.go`:
- Around line 204-210: The code compares the partition's status against the
wrong "deleting" constant causing deleted partitions to be resurrected; replace
those checks so they use cdbm.InfiniBandPartitionStatusDeleting when comparing
the local status variable and ibp.Status before calling mibp.updateIBPStatusInDB
(and in the second occurrence near the later ibp.Status comparison), ensuring
both delete-state gates use cdbm.InfiniBandPartitionStatusDeleting rather than
the interface-deleting constant.

---

Outside diff comments:
In `@rest-api/api/pkg/api/handler/infinibandpartition.go`:
- Around line 1102-1104: The call to common.TerminateWorkflowOnTimeOut inside
the timeoutResp closure uses the shortened action label "Delete" but should pass
the literal workflow name; update the argument passed to
common.TerminateWorkflowOnTimeOut in the timeoutResp definition to
"DeleteInfiniBandPartitionV2" (matching the workflow executed earlier) so the
signature used by TerminateWorkflowOnTimeOut accurately reflects the workflow
name.

---

Nitpick comments:
In `@rest-api/db/pkg/db/model/infinibandpartition_test.go`:
- Around line 876-918: The test currently only asserts an error occurred for
invalid status cases; change the assertion to explicitly check the validation
error message from InfiniBandPartitionSQLDAO.Create by using
require.ErrorContains(err, "invalid InfiniBandPartition Status") (or the exact
validation text returned by Create) when tt.wantErr is true, so replace the
generic require.Equal(t, tt.wantErr, err != nil) + return with a targeted
require.ErrorContains check; apply the same change to the other identical test
block around the 1015–1055 region.
- Line 1057: Remove the stray debug fmt.Printf call in the update test in
infinibandpartition_test.go (the line printing "got ID: ... Created: ...
Updated: ..."); delete that printf so the test no longer writes to stdout on
success and noise the CI logs while leaving all assertions intact.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 98bed9c4-0cfd-4a01-b6a0-d3870cc76d95

📥 Commits

Reviewing files that changed from the base of the PR and between 73c97dd and 0c75763.

📒 Files selected for processing (14)
  • rest-api/api/pkg/api/handler/infinibandinterface_test.go
  • rest-api/api/pkg/api/handler/infinibandpartition.go
  • rest-api/api/pkg/api/handler/infinibandpartition_test.go
  • rest-api/api/pkg/api/handler/instance_test.go
  • rest-api/api/pkg/api/handler/instancebatch_test.go
  • rest-api/api/pkg/api/handler/nvlinkinterface_test.go
  • rest-api/api/pkg/api/model/infinibandpartition.go
  • rest-api/api/pkg/api/model/infinibandpartition_test.go
  • rest-api/db/pkg/db/model/helper_test.go
  • rest-api/db/pkg/db/model/infinibandinterface_test.go
  • rest-api/db/pkg/db/model/infinibandpartition.go
  • rest-api/db/pkg/db/model/infinibandpartition_test.go
  • rest-api/workflow/pkg/activity/infinibandpartition/infinibandpartition.go
  • rest-api/workflow/pkg/util/testing.go

Comment thread rest-api/api/pkg/api/handler/instance_test.go
@chet chet force-pushed the proto-infinibandpartition-receivers branch from 0c75763 to 80e5a26 Compare June 2, 2026 22:42
Brings `InfiniBandPartition` in line with the proto-modeling changes. The handler keeps its REST surface; Create and Update route through `ToProto` on the API request types and the entity gains the full round-trip plus a delete-request builder. The entity also picks up the typed `Labels` field per the `InstanceType` reference in NVIDIA#540 -- it reaches `Labels.ToProto()` / `Labels.FromProto(...)` directly.

Primary callouts are:
- API request side: `APIInfiniBandPartitionCreateRequest.ToProto(ibp)` and `APIInfiniBandPartitionUpdateRequest.ToProto(ibp)`; both source corresponding fields via `ibp.ToProto()`.
- Entity side: `InfiniBandPartition.ToProto`, `FromProto`, and `ToDeletionRequestProto`. There's also a new `InfiniBandPartition.Validate()` so site-driven `FromProto` callers can do `FromProto` + `Validate` -- mirroring the MachineCapability pattern (which went in at NVIDIA#569).
- `InfiniBandPartitionStatus` is now a typed string with its own `.FromProto(state)` and `.Message()` methods, replacing the `InfiniBandPartitionStatusFromProto(state)` helper that split a single proto state into `(status, message)`. The workflow activity caller is just a two-liner now.
- Handler simplified to one-liners, and the inline `cwssaws` / `model/util` imports drop.

As part of the new typed `InfiniBandPartitionStatus` (and the already-typed `Labels`), the typing propagates through the API and DAO layers, but nothing changes on the wire -- JSON serialization of `type X string` is identical to `string`, the OpenAPI spec still just says "string", and the SDK is unaffected.

Tests added!

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet chet force-pushed the proto-infinibandpartition-receivers branch from 80e5a26 to 6b63e27 Compare June 2, 2026 23:49
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.

1 participant