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 ¶
- func Run(ctx context.Context, bin string, args ...string) ([]byte, error)
- type Commands
- type Config
- type Driver
- func (d *Driver) Capacity() int
- func (d *Driver) Destroy(ctx context.Context, h driver.SlotHandle) error
- func (d *Driver) DiskPath(context.Context) string
- func (d *Driver) List(ctx context.Context) ([]driver.SlotHandle, error)
- func (d *Driver) Maintain(ctx context.Context)
- func (d *Driver) Provision(ctx context.Context, req driver.ProvisionRequest) (driver.SlotHandle, error)
- func (d *Driver) ReclaimTiers(ctx context.Context) []driver.Tier
- func (d *Driver) StartedJob(ctx context.Context, h driver.SlotHandle) (bool, error)
- func (d *Driver) Status(ctx context.Context, h driver.SlotHandle) (driver.Status, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Driver) Maintain ¶
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 ¶
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 ¶
StartedJob reports whether the runner has begun a job (vs idling after a pre-pickup cancel), letting the agent reap a stranded slot.