sandboxexec

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package sandboxexec runs tasks in cloud sandboxes for podium-node. For each task it makes one sandbox through a sandbox.Provider, starts podium-sandbox-agent in it, and relays the agent's events and transfers. It never knows which provider it is driving.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor implements podium-node's executor on a sandbox provider.

func New

func New(o Options) (*Executor, error)

New returns an executor.

func (*Executor) AccountLimit

func (e *Executor) AccountLimit() int32

AccountLimit is the most sandboxes the provider account allows at once, 0 when unknown. It answers from the last read and reads again in the background at most once a minute, so a heartbeat never waits on the provider.

func (*Executor) Adopt

func (e *Executor) Adopt(ctx context.Context, req docker.AdoptRequest, events chan<- docker.Event) (docker.Result, error)

Adopt reattaches to a run whose sandbox outlived the previous daemon.

func (*Executor) Cancel

func (e *Executor) Cancel(taskID string)

Cancel implements the node's executor.

func (*Executor) Close

func (e *Executor) Close() error

Close implements the node's executor. A pool's waiting sandboxes are deleted: nothing would take them before the node is back, and they cost what any sandbox costs.

func (*Executor) EndWait added in v0.8.0

func (e *Executor) EndWait(taskID string) error

EndWait implements the node's executor.

func (*Executor) GatewayPorts

func (e *Executor) GatewayPorts(context.Context, string) (map[int]int, error)

GatewayPorts has nothing to say: a sandbox preview's URLs come from the provider.

func (*Executor) HeldExit

func (e *Executor) HeldExit(taskID string) (int, bool)

HeldExit implements the node's executor.

func (*Executor) Holds

func (e *Executor) Holds(_ context.Context, taskID string) bool

Holds implements the node's executor.

func (*Executor) Inject

func (e *Executor) Inject(taskID, text string) error

Inject implements the node's executor.

func (*Executor) KeepsWorkspaceImages added in v0.9.0

func (e *Executor) KeepsWorkspaceImages() (string, bool)

KeepsWorkspaceImages reports whether this executor keeps a session's workspace as an image of its provider's own, and which provider that is.

func (*Executor) ListOwned

func (e *Executor) ListOwned(context.Context) ([]docker.OwnedContainer, error)

ListOwned is every task this node recorded a sandbox for.

func (*Executor) ListPreviews

func (e *Executor) ListPreviews(ctx context.Context) ([]docker.HeldPreview, error)

ListPreviews is every recorded task that publishes ports. Their URLs are the provider's, so there is no address or slot to give back.

func (*Executor) OnDeleted

func (e *Executor) OnDeleted(fn func(id string))

OnDeleted is called with every sandbox Teardown deletes.

func (*Executor) PoolReady added in v0.8.0

func (e *Executor) PoolReady() int

PoolReady is how many pooled sandboxes are ready right now, in every pool.

func (*Executor) PruneImages

PruneImages implements the node's executor.

func (*Executor) Reap

func (e *Executor) Reap(ctx context.Context, id string) error

Reap deletes a sandbox this node does not hold, for a task the control plane gave up on. One that is already gone is not an error.

func (*Executor) Run

func (e *Executor) Run(ctx context.Context, req docker.Request, events chan<- docker.Event) (docker.Result, error)

Run makes the task's sandbox, starts the agent in it and relays the run.

func (*Executor) ServerVersion

func (e *Executor) ServerVersion() string

ServerVersion implements the node's executor.

func (*Executor) SetTemplate

func (e *Executor) SetTemplate(t string)

SetTemplate changes the snapshot image tasks start from, for every task planned after it.

func (*Executor) TaskDir

func (e *Executor) TaskDir(taskID string) string

TaskDir implements the node's executor.

func (*Executor) Teardown

func (e *Executor) Teardown(ctx context.Context, taskID string, _ bool) error

Teardown deletes the task's sandbox and forgets it. keepWorkspace has nothing to keep: the workspace lives and dies with the sandbox.

type Options

type Options struct {
	Provider sandbox.Provider
	DataDir  string
	// Template is the provider snapshot a task that names none starts from.
	Template string
	// Agent returns podium-sandbox-agent for linux/amd64.
	Agent  func() ([]byte, error)
	Logger *slog.Logger
	// Pool keeps sandboxes of one shape ready before any task asks. See pool.go.
	Pool PoolOptions
}

Options configures New.

type PoolOptions added in v0.8.0

type PoolOptions struct {
	// Size is how many ready sandboxes to keep. Zero is no pool.
	Size int
	// Image is the image the pooled sandboxes boot, on a provider that boots images. Empty
	// with a provider that cannot is the node's template.
	Image string
	// Images keeps a pool of Size for each image instead, in this order. A conversation's
	// playbooks run on a handful of images, and each that is pooled starts at once.
	Images []string
	// TTL is how long an unclaimed sandbox lives before the provider stops it; a taken one
	// gets its task's own. Zero is poolTTL.
	TTL time.Duration
}

PoolOptions configures a pool.

Directories

Path Synopsis
Package agentbin carries podium-sandbox-agent inside podium-node, the way the docker executor carries podium-runner.
Package agentbin carries podium-sandbox-agent inside podium-node, the way the docker executor carries podium-runner.

Jump to

Keyboard shortcuts

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