clustercreate

package
v0.7.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderTarget = "X-Cluster-Create-Target"
	HeaderID     = "X-Cluster-Create-ID"

	ReservationTTL = 120 * time.Second
)
View Source
const (
	OverlapPhaseCreate  = "create"
	OverlapPhaseSeal    = "seal"
	OverlapPhasePromote = "promote"
)

OverlapPhase names which step failed on the overlapped reserved-path create. Handlers use errors.As(*OverlapFailure) to map to the right HTTP status.

Variables

This section is empty.

Functions

func CancelReservationBestEffort

func CancelReservationBestEffort(ctx context.Context, svc *service.Service, logger *slog.Logger, sandboxID string)

func CapacityRequestFromCreate

func CapacityRequestFromCreate(req models.CreateSandboxRequest) capacity.Request

func CreateOnSelectedNode

func CreateOnSelectedNode(ctx context.Context, svc *service.Service, logger *slog.Logger, req models.CreateSandboxRequest, reservationID string, opts CreateOptions) (*models.CreateSandboxResponse, error)

func DeletePlacementBestEffort

func DeletePlacementBestEffort(ctx context.Context, svc *service.Service, logger *slog.Logger, sandboxID string)

func FormatPromoteError

func FormatPromoteError(err error) string

FormatPromoteError matches the v1 handler's historical promote-fail message.

func FormatSealError

func FormatSealError(err error) string

FormatSealError matches the v1 handler's historical seal-fail message.

func OverlapCreateAndPromote

func OverlapCreateAndPromote(
	ctx context.Context,
	svc *service.Service,
	logger *slog.Logger,
	req models.CreateSandboxRequest,
	reservationID string,
	opts OverlapOptions,
) (*models.CreateSandboxResponse, error)

OverlapCreateAndPromote runs CreateSandboxWithID in parallel with PutClusterSecretsForRecipient (the seal), joins both, and only then promotes via RecordPlacement (plans/warm-create-latency-tier1.5-seal-promote-overlap.md).

Promote is deliberately NOT overlapped with the create. The FSM releases the pending-reservation accounting on opPlace, and that accounting is what ClusterCreateMaxPendingPerWorker backpressure and SelectPlacement's double-booking guard count — promoting early would uncharge an in-flight local create. It is also what keeps the placement invisible to the owner watcher, which would otherwise start a concurrent recreate of a failover-enabled sandbox whose local create outlives one 5s watcher tick. The row must stay Reserved until the local create has succeeded.

Reserved path only — reservationID must be non-empty. Self-wins / CreateSandbox (no ID) stays sequential at the call site.

Types

type CreateOptions

type CreateOptions struct {
	PromoteWithSpec bool
}

type Decision

type Decision struct {
	ReservationID string
}

type ErrorWriter

type ErrorWriter func(w http.ResponseWriter, status int, message string)

type OverlapFailure

type OverlapFailure struct {
	Phase string
	Err   error
}

OverlapFailure is returned when the create leg, seal leg, or the post-join promote fails. Retract has already been attempted; the handler should surface Err (not invent a new shape). Phase distinguishes create vs seal vs promote for status mapping.

func AsOverlapFailure

func AsOverlapFailure(err error) (*OverlapFailure, bool)

AsOverlapFailure extracts an OverlapFailure from err, if present.

func (*OverlapFailure) Error

func (f *OverlapFailure) Error() string

func (*OverlapFailure) Unwrap

func (f *OverlapFailure) Unwrap() error

type OverlapOptions

type OverlapOptions struct {
	// PromoteWithSpec includes the redacted create request in RecordPlacement.
	// v1 always wants true; Daytona/E2B facades pass true; helpers that rely
	// on the reservation-held spec pass false.
	PromoteWithSpec bool
	Timing          *createtiming.CreateTiming
}

OverlapOptions configures reserved-path create∥seal.

type PrepareOptions

type PrepareOptions struct {
	PreferredSandboxID string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL