Skip to content

feat: nscale api change - #449

Open
ravisoundar wants to merge 2 commits into
mainfrom
rs-nscale
Open

feat: nscale api change#449
ravisoundar wants to merge 2 commits into
mainfrom
rs-nscale

Conversation

@ravisoundar

Copy link
Copy Markdown
Collaborator

Description

Updates the nscale provider to use the list-placement-servers end point instead of the instances api.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • All commits are signed off per DCO (git commit -s).

Signed-off-by: Ravi Shankar <ravish@nvidia.com>
@ravisoundar
ravisoundar requested a review from dmitsh as a code owner August 5, 2026 19:09
@copy-pr-bot

copy-pr-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates the Nscale provider to obtain instance-to-hostname mappings from the placement-servers endpoint instead of the instances endpoint.

  • Adds placementId provider configuration and placement-server API client support.
  • Updates the simulation client, provider tests, error-path coverage, and Nscale documentation.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
pkg/providers/nscale/provider.go Replaces instance enumeration with placement-server lookup, adds placement configuration, and updates the Slurm mapping hook.
pkg/providers/nscale/provider_sim.go Renames the simulated client method to satisfy the updated Nscale client interface.
pkg/providers/nscale/provider_test.go Updates loader and mapping tests for placement IDs, the new endpoint, response fields, and HTTP error handling.
docs/providers/nscale.md Documents placement-server discovery, required placement configuration, and updated request examples.

Sequence Diagram

sequenceDiagram
    participant Engine as Slurm engine
    participant Provider as Nscale provider
    participant Placement as Placement Servers API
    participant Radar as Radar API
    Engine->>Provider: Resolve node mappings
    Provider->>Placement: "GET /api/v2/placements/{placementId}/servers"
    Placement-->>Provider: metadata.id and metadata.name
    Provider-->>Engine: instance ID to hostname map
    Engine->>Provider: Generate topology
    Provider->>Radar: GET /v1/topology
    Radar-->>Provider: topology paths by instance ID
    Provider-->>Engine: generated topology graph
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' into rs-nscale" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Nscale provider discovery now uses placement servers to map instance IDs to hostnames.
    • Added the required placementId configuration parameter.
    • Placement-server metadata is filtered to produce accurate node mappings.
  • Bug Fixes

    • Improved handling and reporting of placement-server API errors, including authorization, missing-resource, and server-error responses.
  • Documentation

    • Updated Nscale setup instructions, prerequisites, configuration examples, API requests, and verification steps.

Walkthrough

The NScale provider replaces regional instance discovery with placement-server discovery. It requires placementId, maps placement-server metadata IDs to names, updates simulator behavior and tests, and revises provider documentation.

Changes

NScale placement discovery

Layer / File(s) Summary
Placement-server client contract
pkg/providers/nscale/provider.go
The client uses /api/v2/placements/%s/servers, adds PlacementID, replaces Instances with PlacementServers, and maps valid server metadata to names.
Provider mapping and validation
pkg/providers/nscale/provider.go, pkg/providers/nscale/provider_sim.go, pkg/providers/nscale/provider_test.go
Instances2NodeMap validates placementId, uses placement-server results, and propagates retrieval errors. The simulator and tests use the updated client contract and response cases.
Placement-server configuration documentation
docs/providers/nscale.md
The documentation updates prerequisites, configuration, payloads, API requests, and hostname verification for placement-server discovery.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: dmitsh

Sequence Diagram(s)

sequenceDiagram
  participant Instances2NodeMap
  participant NScaleClient
  participant PlacementServersAPI
  Instances2NodeMap->>NScaleClient: PlacementServers(placementID)
  NScaleClient->>PlacementServersAPI: GET /api/v2/placements/{placementID}/servers
  PlacementServersAPI-->>NScaleClient: Placement-server metadata
  NScaleClient-->>Instances2NodeMap: ID-to-name map
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change to the Nscale API.
Description check ✅ Passed The description directly explains the endpoint change and confirms related tests and documentation 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rs-nscale

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@docs/providers/nscale.md`:
- Around line 8-10: The documentation describing instanceApiUrl should identify
it as the base URL for the Placement Servers API rather than the Instance API.
Keep the existing configuration key and update its description wherever it
appears in the nscale provider documentation.
- Around line 186-190: Update the verification step in the nscale provider
documentation to compare Placement Server hostnames with Slurm’s node list,
using scontrol show nodes -o and failing when the names differ; alternatively,
revise the step’s wording to describe inspection only rather than verification.
Ensure the instructions accurately reflect the Instances2NodeMap name filtering
behavior.

In `@pkg/providers/nscale/provider_test.go`:
- Around line 194-223: Expand TestInstances2NodeMap and add focused
PlacementServers test cases covering servers missing metadata.id or
metadata.name, asserting they are excluded while valid servers remain mapped.
Add malformed JSON coverage that expects an error, and canceled-context coverage
that verifies the request returns promptly without retries, using the existing
test server/provider helpers.
🪄 Autofix

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: ASSERTIVE

Plan: Enterprise

Run ID: a61b42f5-6538-45c6-ad9e-86e046d88701

📥 Commits

Reviewing files that changed from the base of the PR and between 0b5bc25 and 6a98218.

📒 Files selected for processing (4)
  • docs/providers/nscale.md
  • pkg/providers/nscale/provider.go
  • pkg/providers/nscale/provider_sim.go
  • pkg/providers/nscale/provider_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (7)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Run go fmt ./...; Go formatting is authoritative and code should not be hand-formatted.
Every new Go file must include the NVIDIA copyright header followed by the matching Apache 2.0 boilerplate.

Files:

  • pkg/providers/nscale/provider_sim.go
  • pkg/providers/nscale/provider_test.go
  • pkg/providers/nscale/provider.go
pkg/providers/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

pkg/providers/**/*.go: Providers must return a *topology.Graph and *httperr.Error; plain error is not acceptable at the provider interface boundary.
Providers discover topology and return the canonical topology.Graph; they must not emit scheduler-specific output.
When using ClusterTopology, populate fabric tiers closest-first, preserve optional accelerator domain and sub-domain fields, and call ToGraph.

Files:

  • pkg/providers/nscale/provider_sim.go
  • pkg/providers/nscale/provider_test.go
  • pkg/providers/nscale/provider.go
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Do not publicly disclose suspected security vulnerabilities; report them privately through NVIDIA PSIRT using the channels documented in SECURITY.md.
Every commit must include a Signed-off-by: trailer for DCO compliance.
Use Conventional Commits with an allowed type such as feat, fix, docs, chore, refactor, test, build, or ci.
Before pushing, run make qualify; all CI checks, including Go build/test/lint, Codecov, and DCO, must be green before merge.
Changes to provider, engine, chart, API, configuration schema, labels, annotations, or user-facing behavior must include the corresponding documentation updates described in the documentation impact table.

Files:

  • pkg/providers/nscale/provider_sim.go
  • docs/providers/nscale.md
  • pkg/providers/nscale/provider_test.go
  • pkg/providers/nscale/provider.go
{cmd,pkg,internal}/**/*.go

⚙️ CodeRabbit configuration file

{cmd,pkg,internal}/**/*.go: Focus on correctness, robustness, and failure paths:

  • Check error handling and propagation, including whether callers
    receive enough context to diagnose failures.
  • Verify context propagation, cancellation, timeouts, resource cleanup,
    and goroutine lifecycle.
  • Look for races, deadlocks, unsafe shared state, leaks, and partial
    updates that can leave state inconsistent.
  • Check nil, empty, malformed, duplicate, boundary, and partial inputs.
  • Verify deterministic and idempotent behavior where operations may be
    retried or repeated.
  • Preserve public contracts and the architectural boundaries documented
    in AGENTS.md.
  • Flag behavior changes that lack meaningful regression coverage.

Files:

  • pkg/providers/nscale/provider_sim.go
  • pkg/providers/nscale/provider_test.go
  • pkg/providers/nscale/provider.go
docs/providers/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Provider additions or changes require the corresponding provider documentation, including prerequisites, credentials, parameters, operation, and verification.

Files:

  • docs/providers/nscale.md
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

New or changed public behavior and new code paths should be covered by tests.

Files:

  • pkg/providers/nscale/provider_test.go

⚙️ CodeRabbit configuration file

**/*_test.go: Flag missing negative, cancellation, concurrency, malformed-input,
boundary, and regression cases. Check that assertions would fail if
the behavior under test were broken.

Files:

  • pkg/providers/nscale/provider_test.go
pkg/providers/*/provider.go

📄 CodeRabbit inference engine (AGENTS.md)

A provider must expose func NamedLoader() (string, providers.Loader) and be registered in pkg/registry/registry.go.

Files:

  • pkg/providers/nscale/provider.go
🔇 Additional comments (4)
pkg/providers/nscale/provider.go (1)

25-26: LGTM!

Also applies to: 38-38, 50-50, 73-80, 107-132, 179-181, 212-218

pkg/providers/nscale/provider_sim.go (1)

70-76: LGTM!

pkg/providers/nscale/provider_test.go (1)

32-103: LGTM!

Also applies to: 130-192

docs/providers/nscale.md (1)

12-34: LGTM!

Also applies to: 58-58, 81-81, 101-102, 127-128, 167-185

Comment thread docs/providers/nscale.md
Comment on lines +8 to +10
- **Placement Servers API**: returns server metadata via `GET /api/v2/placements/{placementID}/servers`

The Radar response supplies the provider instance ID, switch path, and optional block ID. The Instance API response maps provider instance IDs to hostnames using `metadata.id` and `metadata.name`; this is used by the Slurm engine when Topograph discovers Slurm nodes automatically.
The Radar response supplies the provider instance ID, switch path, and optional block ID. The Placement Servers API response maps provider instance IDs to hostnames using `metadata.id` and `metadata.name`; this is used by the Slurm engine when Topograph discovers Slurm nodes automatically.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify the base URL for placement-server discovery.

This section now documents the Placement Servers API, but instanceApiUrl is still described as the base URL for the Instance API. Keep the configuration key required by pkg/providers/nscale/provider.go, but describe its value as the base URL for the Placement Servers API. This prevents operators from selecting the old endpoint for the new discovery request.

🤖 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 `@docs/providers/nscale.md` around lines 8 - 10, The documentation describing
instanceApiUrl should identify it as the base URL for the Placement Servers API
rather than the Instance API. Keep the existing configuration key and update its
description wherever it appears in the nscale provider documentation.

Comment thread docs/providers/nscale.md
Comment on lines +186 to +190
First verify that the Placement Servers API returns the hostnames Slurm knows:

```bash
curl -s -H "Authorization: Bearer $TOKEN" \
"$INSTANCE_API_URL/v2/instances?organizationID=$ORG&regionID=$REGION" \
"$INSTANCE_API_URL/api/v2/placements/$PLACEMENT_ID/servers" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the verification step compare with Slurm.

This command only prints metadata.id and metadata.name from the Placement Servers API. It does not read or compare the Slurm node list. Therefore, it cannot verify that the returned hostnames match Slurm nodes, although Instances2NodeMap filters mappings by those names. Either change the text to describe inspection only, or add a comparison with scontrol show nodes -o that fails on a mismatch.

🤖 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 `@docs/providers/nscale.md` around lines 186 - 190, Update the verification
step in the nscale provider documentation to compare Placement Server hostnames
with Slurm’s node list, using scontrol show nodes -o and failing when the names
differ; alternatively, revise the step’s wording to describe inspection only
rather than verification. Ensure the instructions accurately reflect the
Instances2NodeMap name filtering behavior.

Comment on lines +194 to +223
func TestInstances2NodeMap(t *testing.T) {
ctx := context.Background()

server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodGet, r.Method)
require.Equal(t, "/api/v2/placements/placement-1/servers", r.URL.Path)
require.Equal(t, "Bearer token", r.Header.Get("Authorization"))

i2n, err := provider.(*Provider).Instances2NodeMap(ctx, []string{"node-1", "node-2"})
w.Header().Set("Content-Type", "application/json")
_, err := w.Write([]byte(placementServersResponse))
require.NoError(t, err)
}))
defer server.Close()

p := newTestProvider(t, ctx, server.URL)

i2n, err := p.Instances2NodeMap(ctx, []string{"training-workers-0", "training-workers-1"})
require.NoError(t, err)
require.Equal(t, map[string]string{
"instance-1": "node-1",
"instance-2": "node-2",
"psrv-7f3d9d5d2a7c4e32": "training-workers-0",
"psrv-950ab3259a1443da": "training-workers-1",
}, i2n)

i2n, err = provider.(*Provider).Instances2NodeMap(ctx, nil)
i2n, err = p.Instances2NodeMap(ctx, nil)
require.NoError(t, err)
require.Equal(t, map[string]string{
"instance-1": "node-1",
"instance-2": "node-2",
"instance-3": "outside-node",
"psrv-7f3d9d5d2a7c4e32": "training-workers-0",
"psrv-950ab3259a1443da": "training-workers-1",
}, i2n)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover incomplete responses, malformed JSON, and cancellation.

Lines 126-128 in pkg/providers/nscale/provider.go skip servers without metadata.id or metadata.name, but no test executes those branches. The tests also do not cover invalid JSON or a canceled context for PlacementServers.

Add cases that assert incomplete servers are excluded, valid servers remain mapped, malformed JSON returns an error, and a canceled context returns without a retry loop.

As per coding guidelines, “New or changed public behavior and new code paths should be covered by tests.” As per path instructions, “Flag missing negative, cancellation, concurrency, malformed-input, boundary, and regression cases.”

Also applies to: 225-274

🤖 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 `@pkg/providers/nscale/provider_test.go` around lines 194 - 223, Expand
TestInstances2NodeMap and add focused PlacementServers test cases covering
servers missing metadata.id or metadata.name, asserting they are excluded while
valid servers remain mapped. Add malformed JSON coverage that expects an error,
and canceled-context coverage that verifies the request returns promptly without
retries, using the existing test server/provider helpers.

Sources: Coding guidelines, Path instructions

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