vmdriver

package
v0.2.16 Latest Latest
Warning

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

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

Documentation

Overview

Package vmdriver provides a generic ephemeral-VM Driver shared by the macOS drivers (tart, lume). The provision/status/teardown flow and the SSH runner bootstrap are identical across them; only the VM CLI differs, so that part lives behind the Commands interface and everything else is shared here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, bin string, args ...string) ([]byte, error)

Run executes a VM CLI command and returns its stdout. Shared by the tart and lume bindings so their exec/stderr/error handling can't drift.

Types

type Commands

type Commands interface {
	// Clone makes a copy-on-write copy of base as name.
	Clone(ctx context.Context, base, name string) error
	// Start boots name headless, detached so it survives the parent process
	// (a controller restart can then reconcile live VMs via List). A non-empty
	// share is a host directory to expose read-only, at guestShare(share) in a
	// macOS guest.
	Start(name, share string) error
	Stop(ctx context.Context, name string) error
	Delete(ctx context.Context, name string) error
	// List returns our VMs — those whose name matches prefix.
	List(ctx context.Context, prefix string) ([]driver.SlotHandle, error)
	// State returns name's status and, when the CLI exposes it cheaply in the
	// same call (e.g. lume ls), its IP — empty otherwise, in which case the
	// generic layer falls back to IP().
	State(ctx context.Context, name string) (driver.Status, string, error)
	// IP returns name's current IP. Before a lease it returns "" or a non-nil
	// error; callers retry on both.
	IP(ctx context.Context, name string) (string, error)
	// StorePath is the directory the CLI keeps VM images and its download cache
	// in — the filesystem that fills up.
	StorePath() string
	// PruneCaches drops cached image downloads last used more than
	// olderThanDays ago; zero drops them all. It must never touch local VMs —
	// the base image the driver clones from is one of them.
	PruneCaches(ctx context.Context, olderThanDays int) error
}

Commands abstracts a VM CLI (tart, lume). All methods operate on VM names.

type Config

type Config struct {
	Base     string
	SSHUser  string
	Capacity int
	// ActionCache is the host's action archive cache directory, "" for none.
	ActionCache string
}

Config carries the runtime knobs shared by all VM drivers.

type Driver

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

Driver is the generic VM driver, parameterized by a Commands implementation.

func New

func New(cmd Commands, cfg Config) *Driver

New constructs a Driver from a CLI binding and config.

func (*Driver) Capacity

func (d *Driver) Capacity() int

func (*Driver) Destroy

func (d *Driver) Destroy(ctx context.Context, h driver.SlotHandle) error

func (*Driver) DiskPath

func (d *Driver) DiskPath(context.Context) string

func (*Driver) List

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

func (*Driver) Maintain

func (d *Driver) Maintain(ctx context.Context)

Maintain keeps the host's runner at GitHub's latest release until ctx is cancelled. Provision copies it into any clone whose baked runner differs, so a stale base image still runs jobs.

func (*Driver) Provision

func (d *Driver) Provision(ctx context.Context, req driver.ProvisionRequest) (driver.SlotHandle, error)

func (*Driver) ReclaimTiers

func (d *Driver) ReclaimTiers(ctx context.Context) []driver.Tier

ReclaimTiers frees the CLI's image download caches. Neither step needs a drain: the caches hold pulled images, not the local VMs, so a running clone is untouched — the worst outcome is a re-pull the next time the operator refreshes the base image.

func (*Driver) StartedJob

func (d *Driver) StartedJob(ctx context.Context, h driver.SlotHandle) (bool, error)

StartedJob reports whether the runner has begun a job (vs idling after a pre-pickup cancel), letting the agent reap a stranded slot.

func (*Driver) Status

func (d *Driver) Status(ctx context.Context, h driver.SlotHandle) (driver.Status, error)

Jump to

Keyboard shortcuts

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