orchestrator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package orchestrator owns the VM lifecycle: it resolves the per-call dependencies (store, SSH key, image, backend), creates the backend network, and boots, waits for, and tears down VMs. It is the only place the internal/backend implementations are wired in, so it is the one package whose import graph carries a hypervisor (vz on darwin, cloud-hypervisor on linux).

On linux the root fleetbox package imports the orchestrator and runs it in-process. On darwin the root package does NOT import it — the orchestrator lives only inside the downloaded, signed fleetbox-helper, and the root package is a thin pure-Go client that drives the helper over a socket (ADR-0017). The clustering-capability gate and the public ErrClustersUnsupported sentinel live in the root package, not here: a caller is expected to have checked SupportsClustering before adding a second member, so Cluster.Add boots unconditionally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NestedVirtSupported

func NestedVirtSupported() bool

NestedVirtSupported reports whether nested virtualization is available on this host, asking the backend directly. On darwin it is the authoritative VZ check (the root client uses a pure-Go heuristic to avoid downloading the helper just to skip a test); on linux it probes /dev/kvm and the KVM nested parameter.

func Prune

func Prune() error

Prune reclaims the inert host resources a fleetbox holder leaves behind if it dies without running its teardown — on Linux, orphaned bridges, taps, and firewall rules. On macOS it is a no-op (vmnet owns its state).

Types

type Cluster

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

Cluster is a set of VMs sharing one network, so every member reaches the others by IP — a vmnet SharedMode network on macOS, a Linux bridge on Linux (ADR-0008, ADR-0011). The shared network is a runtime object tied to the Cluster's lifetime — never persisted, so a Cluster is a runtime handle, not on-disk state. Members can be added after creation, which is what lets a CLI holder process grow a live cluster without recreating its network.

func NewCluster

func NewCluster(optFns ...opts.Option) (*Cluster, error)

NewCluster creates a cluster's shared network but boots no VMs. Use Add to bring members up on it. Shared setup (store, SSH key, image, backend) runs once here and is reused for every Add.

func (*Cluster) Add

func (c *Cluster) Add(ctx context.Context, name string) (*VM, error)

Add boots an additional VM on the cluster's shared network and registers it as a member. The new VM reaches every existing member by IP. The clustering-capability gate lives in the root package's Cluster.Add, which is expected to have rejected a second member on a non-clustering backend before reaching here, so Add boots unconditionally.

func (*Cluster) Close

func (c *Cluster) Close() error

Close releases the cluster's shared network. Call it once every member has been stopped or destroyed — on Linux it tears down the bridge and egress rules; on macOS it is a no-op (the vmnet network is released by GC). It is idempotent.

func (*Cluster) SupportsClustering

func (c *Cluster) SupportsClustering() bool

SupportsClustering reports whether this cluster's backend can interconnect VMs on its shared network. It is false only on macOS older than 26, where VZ NAT isolates VMs from one another (ADR-0008, ADR-0012); the root package's gate consults it before booting a second member.

func (*Cluster) VMs

func (c *Cluster) VMs() []*VM

VMs returns a snapshot of the cluster's current members in the order they were added.

type VM

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

VM represents a running virtual machine owned by the orchestrator.

func Start

func Start(ctx context.Context, name string, optFns ...opts.Option) (*VM, error)

Start creates and boots a new VM with the given name on its own one-member network. If the VM already exists, it boots the existing VM.

func (*VM) Destroy

func (v *VM) Destroy(ctx context.Context) error

Destroy stops the VM and removes all its files.

func (*VM) IP

func (v *VM) IP() net.IP

IP returns the VM's IP address.

func (*VM) Name

func (v *VM) Name() string

Name returns the VM name.

func (*VM) SSH

func (v *VM) SSH(_ context.Context, cmd string) (string, error)

SSH executes a command on the VM via SSH and returns the output.

func (*VM) State

func (v *VM) State() string

State returns the current VM state.

func (*VM) Stop

func (v *VM) Stop(ctx context.Context) error

Stop gracefully shuts down the VM. The disk is preserved.

Jump to

Keyboard shortcuts

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