Skip to content

Make stop_timeout configurable at create and stop time#294

Draft
Sayan- wants to merge 3 commits into
mainfrom
hypeship/configurable-stop-timeout
Draft

Make stop_timeout configurable at create and stop time#294
Sayan- wants to merge 3 commits into
mainfrom
hypeship/configurable-stop-timeout

Conversation

@Sayan-

@Sayan- Sayan- commented Jun 24, 2026

Copy link
Copy Markdown

Summary

The graceful-shutdown grace period for stopInstance (and the graceful teardown in deleteInstance) was effectively hardcoded to the 5s default. StoredMetadata.StopTimeout existed and was read by resolveStopTimeout, but nothing ever set it — it was always 0, so every stop fell back to DefaultStopTimeout.

This wires it up on two surfaces:

  • Create time — optional stop_timeout (integer seconds, minimum: 1) on CreateInstanceRequest. Persisted on the instance; also applies to delete's pre-teardown graceful shutdown since deleteInstance reads the same stored value.
  • Stop time — optional stop_timeout in the (new, optional) POST /instances/{id}/stop request body, overriding the configured value for that one call.

Precedence: stop-call override > instance-configured value > 5s default (implemented in resolveStopTimeout).

Changes

  • openapi.yaml: add stop_timeout to CreateInstanceRequest; add an optional request body with stop_timeout and a 400 response to stopInstance. Regenerated lib/oapi/oapi.go.
  • resolveStopTimeout(stored, override *int) applies the precedence rule.
  • Manager.StopInstance / stopInstance take a stopTimeout *int; internal callers (restart policy, fork, delete) pass nil.
  • API handlers validate stop_timeout >= 1 (the schema minimum isn't enforced at runtime by the strict server) and map it through.

Test plan

  • go build ./... (with local embed-binary stubs for the assets not present in a fresh clone)
  • New unit test TestResolveStopTimeout covers the precedence/default/override cases
  • go test ./lib/instances/ -run TestResolveStopTimeout and ./lib/builds/ pass
  • Integration tests in cmd/api/api require mkfs.erofs, network-bridge caps, and real image pulls/VMs — not runnable in this environment, so the handler paths weren't exercised end-to-end here

Notes

The lib/oapi/oapi.go diff is large but entirely generated — only StopInstance/CreateInstance identifiers change (adding a request body + 400 response fans out across client/server/strict wrappers). No other endpoints touched. The downstream SDKs (hypeman-go, hypeman-ts) and the hypeman CLI are separate repos and would need their own regen/flag to surface this; out of scope here.

The graceful stop grace period was hardcoded to a 5s default: the
StopTimeout field existed on instance metadata but nothing ever set it,
so it was always 0 and fell back to the default.

Expose it as an optional stop_timeout on the create-instance request
(persisted on the instance and also used by delete's graceful
teardown) and as an optional per-call override in the stop request
body. Precedence: stop-call override > instance-configured value >
default.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

✱ Stainless preview builds for hypeman

This PR will update the hypeman SDKs with the following commit message.

feat: Make stop_timeout configurable at create and stop time

Edit this comment to update it. It will appear in the SDK's changelogs.

hypeman-typescript studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅lint ❗test ✅

npm install https://pkg.stainless.com/s/hypeman-typescript/72196927223043e177488be1dd3470f16099391e/dist.tar.gz
hypeman-openapi studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅

⚠️ hypeman-go studio · code · diff

Your SDK build had a failure in the build CI job, which is a regression from the base state.
generate ✅build ❗ (prev: build ✅) → lint ✅test ✅

go get github.com/stainless-sdks/hypeman-go@151bfb89944f0d45fee051c0c607fc1e429c316b

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-06-24 20:02:43 UTC

Sayan- and others added 2 commits June 24, 2026 19:31
Dedupe the stop_timeout range check and error message that were
copy-pasted across the create and stop handlers into a single
validateStopTimeout helper, matching the existing toDomain* helper
convention. Stop passes the validated pointer straight through; create
maps it to the domain int via lo.FromPtr.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
stop_timeout was settable at create but not returned on the Instance
object, so clients couldn't read back what they configured. Add it to
the Instance schema and map it in instanceToOAPI, emitting the
configured value when set and omitting it when unset (server default
applies) — symmetric with the request-side semantics.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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