Skip to content

deploy: add --provision_only to provision resources without rolling out servers#1847

Draft
ns-kosti wants to merge 5 commits into
mainfrom
deploy/provision-only
Draft

deploy: add --provision_only to provision resources without rolling out servers#1847
ns-kosti wants to merge 5 commits into
mainfrom
deploy/provision-only

Conversation

@ns-kosti

Copy link
Copy Markdown
Contributor

What

Adds ns deploy --provision_only, which provisions a stack's resources (e.g.
applies Postgres schema) without rolling out the requested servers. This lets
resource provisioning run as its own step — for example, applying database
schema as a gated CI step that can fail before any application rollout.

ns deploy --provision_only ./app   # ensure DB + apply schema, no app rollout
ns deploy ./app                    # roll out the app

Why

The resource provider that applies database schema runs as part of every
deploy and emits the connection instance the servers consume. Today there is
no way to run that provisioning on its own. Splitting it out enables:

  • running migrations as a separate, reviewable pipeline step;
  • failing early, before rolling out servers;
  • running provisioning with narrower credentials than a full deploy.

Note: a subsequent ns deploy still re-runs the provider, because resource
instances are produced per-deploy and consumed to build each server's runtime
config — they are not persisted between deploys. This change re-orders
provisioning into its own step; it does not remove it from the rollout deploy.

How

provision-only is a deploy planning mode (PrepareDeployMode), not a filter
over the assembled plan:

  • Server deployables are filtered out of the typed DeploymentSpec before
    deployment planning, so the requested servers and their runtime-config ops
    are never emitted.
  • Servers that resources require (e.g. a colocated database) are kept, derived
    from the server-resources discovered while planning resources.
  • A no-op OpConsumeResourceOutputs invocation consumes the resource instance
    outputs that the dropped servers would have consumed, so the plan's output
    accounting stays balanced.
  • Runtime ingress is skipped, so no routes are created for servers that are not
    rolled out. Ingress-as-resource fragments deploy through the same path and
    are likewise not applied.

Testing

  • go test ./internal/planning/deploy/...
  • Unit tests cover the two correctness-critical helpers: keeping only
    resource-required servers, and building an output sink that consumes every
    produced resource instance.

Notes

  • Independent of any other in-flight change.
  • Commits are organized to be reviewed one at a time.

ns-kosti and others added 5 commits June 24, 2026 17:47
Add a PrepareDeployMode (full deploy vs provision-only) threaded through
the deploy planner. No behaviour change yet; the mode is consumed in
later commits.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef9f5-4ba4-711c-b45c-370fd77b0c55
Co-authored-by: Amp <amp@ampcode.com>
A no-op invocation that consumes resource instance outputs via
RequiredOutput. Used by provision-only deployments to balance output
accounting when the requested servers (the usual consumers) are not
rolled out. Not wired up yet.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef9f5-4ba4-711c-b45c-370fd77b0c55
Co-authored-by: Amp <amp@ampcode.com>
In provision-only mode, keep resource provisioning (including servers
that resources require, e.g. a colocated database) but do not roll out
the requested servers or runtime ingress. A no-op sink consumes resource
outputs that the dropped servers would have consumed, keeping the plan's
output accounting balanced.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef9f5-4ba4-711c-b45c-370fd77b0c55
Co-authored-by: Amp <amp@ampcode.com>
Provisions resources without rolling out the requested servers. Adjusts
the completion output to point at "ns deploy" for the rollout.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef9f5-4ba4-711c-b45c-370fd77b0c55
Co-authored-by: Amp <amp@ampcode.com>
Cover the two correctness-critical helpers: keeping only resource-required
servers, and building an output sink that consumes every produced resource
instance.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef9f5-4ba4-711c-b45c-370fd77b0c55
Co-authored-by: Amp <amp@ampcode.com>
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