orchestrator

package
v0.0.0-...-bb730e8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeStartInFlight             = "sandbox_start_in_flight"
	ErrCodeFilesystemBootUnconfirmed = "sandbox_filesystem_boot_unconfirmed"
)

Semantic error codes for the explicit filesystem-boot (memory:false) path, emitted in APIError.ErrorCode so callers and metrics can distinguish these from ambient 4xx/5xx on the same routes.

View Source
const MaxAutoResumeTransitionRetries = 3

Variables

View Source
var (
	ErrSandboxNotFound        = errors.New("sandbox not found")
	ErrAccessForbidden        = errors.New("access forbidden")
	ErrSandboxOperationFailed = errors.New("sandbox operation failed")
	// ErrRefusedRouteLost: the node refused the pause retryably but the edge
	// could not put the sandbox's route back, so the sandbox cannot be kept.
	ErrRefusedRouteLost = errors.New("pause refused by the node and the edge could not restore its route")
)
View Source
var ErrNodeNotFound = errors.New("node not found")
View Source
var PlacementErrorCodes = []string{
	errCodePlacementTimeout,
	errCodeCapacityUnavailable,
	errCodeNoCompatibleNode,
	errCodeFeatureUnsupported,
	errCodeSandboxCreateFailed,
	errCodeInternalServer,
}

PlacementErrorCodes is every semantic error code placementAPIError can return.

Functions

This section is empty.

Types

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	config cfg.Config,
	tel *telemetry.Client,
	nodeDiscovery servicediscovery.Discoverer,
	localRegistryOwnsOrchestrators bool,
	posthogClient *analyticscollector.PosthogClient,
	redisClient redis.UniversalClient,
	sqlcDB *sqlcdb.Client,
	clusters *clusters.Pool,
	featureFlags *featureflags.Client,
	accessTokenGenerator *sandbox.AccessTokenGenerator,
	snapshotCache SnapshotCacheInvalidator,
	snapshotUpsertSem *utils.AdjustableSemaphore,
) (*Orchestrator, error)

func (*Orchestrator) AdminNodeDetail

func (o *Orchestrator) AdminNodeDetail(clusterID uuid.UUID, nodeID string) (*api.NodeDetail, error)

func (*Orchestrator) AdminNodes

func (o *Orchestrator) AdminNodes(clusterID uuid.UUID) ([]*api.Node, error)

func (*Orchestrator) CheckpointSandbox

func (o *Orchestrator) CheckpointSandbox(ctx context.Context, teamID uuid.UUID, sandboxID string) error

CheckpointSandbox snapshots a running sandbox in place: the sandbox is briefly paused on its node, snapshotted, and resumed under the same execution ID, so it keeps running with its ID, expiration, and reservation untouched. The snapshot is written to the sandbox's own snapshots row, so it can immediately be resumed or forked from.

func (*Orchestrator) Close

func (o *Orchestrator) Close(ctx context.Context) error

func (*Orchestrator) CreateSandbox

func (o *Orchestrator) CreateSandbox(
	ctx context.Context,
	sandboxID,
	executionID string,
	team *teamtypes.Team,
	getSandboxData SandboxDataFetcher,
	startTime time.Time,
	endTime time.Time,
	timeout time.Duration,
	isResume bool,
	demandFilesystemBoot bool,
	creationMeta sandbox.CreationMetadata,
) (sbx sandbox.Sandbox, apiErr *api.APIError)

func (*Orchestrator) CreateSnapshotTemplate

func (o *Orchestrator) CreateSnapshotTemplate(ctx context.Context, teamID uuid.UUID, sandboxID string, opts SnapshotTemplateOpts) (result SnapshotTemplateResult, e error)

CreateSnapshotTemplate creates a persistent snapshot template from a running sandbox and immediately resumes it. The handler is responsible for parsing the name, resolving aliases via the cache, and populating opts.

func (*Orchestrator) GetClusterNodes

func (o *Orchestrator) GetClusterNodes(clusterID uuid.UUID) []*nodemanager.Node

func (*Orchestrator) GetNode

func (o *Orchestrator) GetNode(clusterID uuid.UUID, nodeID string) *nodemanager.Node

func (*Orchestrator) GetNodeByWorkloadID deprecated

func (o *Orchestrator) GetNodeByWorkloadID(id string) *nodemanager.Node

Deprecated: use GetNode instead

func (*Orchestrator) GetNodeRouteIPAddress

func (o *Orchestrator) GetNodeRouteIPAddress(clusterID uuid.UUID, nodeID string) string

func (*Orchestrator) GetSandbox

func (o *Orchestrator) GetSandbox(ctx context.Context, teamID uuid.UUID, sandboxID string) (sandbox.Sandbox, error)

func (*Orchestrator) GetSandboxes

func (o *Orchestrator) GetSandboxes(ctx context.Context, teamID uuid.UUID, states []sandbox.State) ([]sandbox.Sandbox, error)

GetSandboxes returns instances for a given team.

func (*Orchestrator) HandleExistingSandboxAutoResume

func (o *Orchestrator) HandleExistingSandboxAutoResume(
	ctx context.Context,
	teamID uuid.UUID,
	sandboxID string,
	sbx apisandbox.Sandbox,
	transitionWaitBudget time.Duration,
) (string, bool, error)

func (*Orchestrator) KeepAliveFor

func (o *Orchestrator) KeepAliveFor(ctx context.Context, teamID uuid.UUID, sandboxID string, duration time.Duration, allowShorter bool) (*sandbox.Sandbox, *api.APIError)

func (*Orchestrator) NodeCount

func (o *Orchestrator) NodeCount() int

func (*Orchestrator) RemoveSandbox

func (o *Orchestrator) RemoveSandbox(ctx context.Context, teamID uuid.UUID, sandboxID string, opts sandbox.RemoveOpts) error

func (*Orchestrator) TeamRunningSandboxCounts

func (o *Orchestrator) TeamRunningSandboxCounts(ctx context.Context) (map[uuid.UUID]int64, error)

func (*Orchestrator) UpdateSandbox

func (o *Orchestrator) UpdateSandbox(
	ctx context.Context,
	sandboxID string,
	endTime time.Time,
	clusterID uuid.UUID,
	nodeID string,
) error

func (*Orchestrator) UpdateSandboxNetworkConfig

func (o *Orchestrator) UpdateSandboxNetworkConfig(
	ctx context.Context,
	teamID uuid.UUID,
	sandboxID string,
	allowedEntries []string,
	deniedEntries []string,
	rules map[string][]types.SandboxNetworkRule,
	allowInternetAccess *bool,
	egressProxy *sandbox_network.EgressProxyConfig,
) *api.APIError

func (*Orchestrator) WaitForStateChange

func (o *Orchestrator) WaitForStateChange(ctx context.Context, teamID uuid.UUID, sandboxID string) error

type PauseQueueExhaustedError

type PauseQueueExhaustedError = sandbox.PauseQueueExhaustedError

Defined in the sandbox package so the evictor can classify it without an import cycle.

type SandboxDataFetcher

type SandboxDataFetcher func(ctx context.Context) (SandboxMetadata, *api.APIError)

SandboxDataFetcher is a callback that fetches sandbox metadata. It is called after the concurrency lock is acquired to ensure fresh data.

type SandboxMetadata

type SandboxMetadata struct {
	Metadata            map[string]string
	EnvVars             map[string]string
	Build               queries.EnvBuild
	AllowInternetAccess *bool
	Network             *types.SandboxNetworkConfig
	Alias               string
	TemplateID          string
	BaseTemplateID      string
	AutoPause           bool
	// AutoPauseFilesystemOnly makes a timeout auto-pause take a filesystem-only
	// snapshot instead of a full memory one. Only meaningful when AutoPause.
	AutoPauseFilesystemOnly bool
	AutoResume              *types.SandboxAutoResumeConfig
	VolumeMounts            []*orchestrator.SandboxVolumeMount
	EnvdAccessToken         *string
	// Iam records the sandbox workload identity configuration requested at create
	// time. Nil means workload identity is disabled.
	Iam    *types.SandboxIam
	NodeID *string
	// SnapshotSandboxID is the sandbox ID the resume snapshot is stored under.
	// It differs from the ID of the sandbox being started when forking.
	SnapshotSandboxID string
	// FilesystemBoot demands a cold boot of a memory-inclusive snapshot
	// (explicit memory:false resume). Set only by the resume data fetchers;
	// template creates and auto-resume never set it.
	FilesystemBoot bool
	// FilesystemOnlySnapshot marks a resume whose snapshot persists only the
	// rootfs. Unlike FilesystemBoot it describes the stored artifact rather than
	// the request, so every path that resumes such a snapshot sets it.
	FilesystemOnlySnapshot bool
}

type SnapshotCacheInvalidator

type SnapshotCacheInvalidator interface {
	Invalidate(ctx context.Context, sandboxID string)
}

SnapshotCacheInvalidator invalidates cached snapshot entries.

type SnapshotTemplateOpts

type SnapshotTemplateOpts struct {
	// ExistingTemplateID is set when the alias resolved to an existing template owned by the team.
	ExistingTemplateID *string
	// Alias is the parsed alias name (without namespace). Set when a name was provided.
	Alias *string
	// Namespace is the team slug used for alias scoping. Set when a name was provided.
	Namespace *string
	// Tag is the build tag parsed from the name, defaults to "default".
	Tag string
}

type SnapshotTemplateResult

type SnapshotTemplateResult struct {
	TemplateID string
	BuildID    uuid.UUID
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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