cli/cluster: add --use_public_api to nsc create#1869
Draft
annervisser wants to merge 1 commit into
Draft
Conversation
Add a hidden --use_public_api flag (default false) to `nsc create`, with a --no_use_public_api counterpart, so the default can later be flipped in one line. When enabled, the instance is created through the public compute ReservationService.ReserveInstance API instead of the legacy private InstanceService (api.CreateAndWaitCluster). The public path is kept self-contained in create_publicapi.go so removing the legacy path later is trivial: - createInstanceViaPublicAPI reserves an instance, waits for the reservation to be fulfilled and the instance to become ready, and returns the same result as the legacy path. - the reservation deadline never outlives the client wait, and a reservation we stop waiting for is cancelled best-effort, so we never leave an untracked instance. - explicitly-set create flags the public path does not map yet are rejected rather than silently dropped. - machine_type accepts the full [os/arch:]<cpu>x<mem> form, with the legacy mac/silicon alias for macos/arm64. Output and side-effect files are shared between both paths via the extracted writeInstanceOutputFiles and printInstanceCreated helpers. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019f1880-ac56-7349-b5df-36566f7fc069
annervisser
marked this pull request as draft
July 12, 2026 13:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Start moving
nsc createonto the public compute API.Adds a hidden
--use_public_apiflag (default false) with a--no_use_public_apicounterpart, so the default can be flipped in a single line later. When enabled,nsc createcreates the instance through the public computeReservationService.ReserveInstanceAPI (waiting for the reservation to be fulfilled and the instance to become ready) instead of the legacy privateInstanceService(api.CreateAndWaitCluster).This reuses the logic that was implemented for the (now-dropped)
nsc reservation createcommand — see #1868.Clean split for trivial legacy removal
The public path is fully self-contained in
create_publicapi.go. Removing the legacy path later means deleting theelse/fall-through inNewCreateCmdand promoting the public branch; the shared output helpers stay.Correctness safeguards
--use_public_apirequires a positive--wait_timeout(the reservation flow is async and must wait for an instance).nsc createflags the public path does not map yet (--unique_tag,--available_secrets,--internal_extra,--experimental*) are rejected rather than silently dropped. Remove entries frompublicAPIUnsupportedFlagsas mappings are added.Shared behavior
Output and side-effect files are shared between both paths via the extracted
writeInstanceOutputFilesandprintInstanceCreatedhelpers; the JSON/plain output is byte-for-byte identical to legacynsc create.Verification
go vetclean; hidden flags absent from--help; mutual-exclusivity, unsupported-flag, andwait_timeout=0guards all error correctly.nsc create --use_public_api(plain and-o json) created ready instances with output identical to legacynsc create; both destroyed.Amp-Thread-ID: https://ampcode.com/threads/T-019f1880-ac56-7349-b5df-36566f7fc069