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
- type Config
- type Driver
- func (d *Driver) Create(ctx context.Context, name string, spec workspace.Spec) error
- func (d *Driver) Destroy(ctx context.Context, name string) error
- func (d *Driver) Exec(ctx context.Context, name string, argv []string, stdin io.Reader, ...) error
- func (d *Driver) Get(ctx context.Context, name, srcDir, dstDir string, files ...string) error
- func (d *Driver) List(ctx context.Context) ([]string, error)
- func (d *Driver) Put(ctx context.Context, name, srcDir, dstDir string) error
- func (d *Driver) Start(ctx context.Context, name string) (workspace.Network, error)
- func (d *Driver) Stop(ctx context.Context, name string) error
Constants ¶
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 (*Driver) Create ¶
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 ¶
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) List ¶
List implements workspace.Driver: kata-helper list, which names only workspaces.
func (*Driver) Put ¶
Put implements workspace.Driver: vmexec's tar stream through kata-helper exec -i.