kata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package kata is the workspace driver for Linux: each workspace is a Kata microVM made and run by the root helper (design/workstreams/agent/LLD/workspace-kata.md#the-driver-internalagentworkspacekata), which this driver runs as sudo -n kata-helper <verb>. Commands in a workspace go through kata-helper exec, with vmexec's tar streams and pid-file cancel, as tart's go through tart exec.

Index

Constants

View Source
const (
	AgentDir  = "/var/lib/factory/bin"
	AgentLink = "/usr/local/bin/factory-agent"
)

The agent binary's place in a workspace: Start puts it in AgentDir and links AgentLink to it, where workspace.AgentCommand finds it on PATH.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Helper is the root helper: default katahelper.HelperPath, the path the sudoers rule names.
	Helper string
	// Sudo runs the helper as root without a prompt: default sudo -n.
	Sudo   []string
	Runner vmexec.Runner
	// Image is the workspace image, factory-agent-base:<version> (host init's katabase.json).
	Image string
	// DiskGiB is an empty workspace disk's size: the config's workspace.size.disk (20 to 500).
	DiskGiB int
	// Warm is whether host init's warm disk exists (katawarm.json): Create copies it, else it
	// makes an empty disk.
	Warm bool
	// AgentBinary is the factory-agent Start puts in each workspace: default this executable
	// (the host and the guest are both linux/amd64).
	AgentBinary string
	// Boot bounds Start's wait for systemd in the workspace (3 minutes), polled every Poll (1 s).
	Boot, Poll time.Duration
	// Grace is how long Exec waits after the remote SIGTERM before SIGKILL (45 s, as tart's).
	Grace time.Duration
	// MaxGet bounds Get's stream: default vmexec.MaxGet.
	MaxGet int64
}

Config is the driver's setup; every field but Image and DiskGiB has a default.

type Driver

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

Driver is the kata workspace driver. It keeps no state per workspace, so it's safe for concurrent use on different workspaces.

func New

func New(c Config) *Driver

New returns a driver.

func (*Driver) Create

func (d *Driver) Create(ctx context.Context, name string, spec workspace.Spec) error

Create implements workspace.Driver: kata-helper create <name> <cpu-1> <MiB> <diskGiB> warm|empty <image>. Kata adds a vCPU of its own to the container's (Q8 H06).

func (*Driver) Destroy

func (d *Driver) Destroy(ctx context.Context, name string) error

Destroy implements workspace.Driver: kata-helper rm, which stops and removes the workspace and frees its slot; a missing one is no error. It runs after ctx is done too, for up to rmBound.

func (*Driver) Exec

func (d *Driver) Exec(ctx context.Context, name string, argv []string, stdin io.Reader, stdout, stderr io.Writer) error

Exec implements workspace.Driver: vmexec's, through kata-helper exec [-i]. The helper exits with the remote command's status, or katahelper.ExecFailed with its own error as the last stderr line: only that pair is an exec failure, so a remote command's own 125 stays its status.

func (*Driver) Get

func (d *Driver) Get(ctx context.Context, name, srcDir, dstDir string, files ...string) error

Get implements workspace.Driver: vmexec's, at most MaxGet bytes.

func (*Driver) List

func (d *Driver) List(ctx context.Context) ([]string, error)

List implements workspace.Driver: kata-helper list, which names only workspaces.

func (*Driver) Put

func (d *Driver) Put(ctx context.Context, name, srcDir, dstDir string) error

Put implements workspace.Driver: vmexec's tar stream through kata-helper exec -i.

func (*Driver) Start

func (d *Driver) Start(ctx context.Context, name string) (workspace.Network, error)

Start implements workspace.Driver: kata-helper start, then it waits for systemd (which also proves exec works after its boot), reads the network and checks it against the slot's, and puts the agent binary in. A failure destroys nothing: the caller does.

func (*Driver) Stop

func (d *Driver) Stop(ctx context.Context, name string) error

Stop implements workspace.Driver: kata-helper stop (systemd's halt). It runs after ctx is done too, for up to stopBound.

Jump to

Keyboard shortcuts

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