lifecycle

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreateRecordDir = errors.New("create lifecycle record directory")
	ErrReadRecord      = errors.New("read lifecycle record")
	ErrDecodeRecord    = errors.New("decode lifecycle record")
	ErrEncodeRecord    = errors.New("encode lifecycle record")
	ErrWriteRecord     = errors.New("write lifecycle record")
	ErrRenameRecord    = errors.New("rename lifecycle record")
	ErrVMRunning       = errors.New("VM is running")
	ErrInvalidPhase    = errors.New("invalid lifecycle phase transition")
	ErrReconcileTable  = errors.New("reconcile nftables table")
	ErrReconcileTap    = errors.New("reconcile TAP interface")
)

Functions

This section is empty.

Types

type CleanupResult

type CleanupResult struct {
	Status    string    `json:"status"`
	Error     string    `json:"error,omitempty"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Phase

type Phase string
const (
	PhaseCreating      Phase = "creating"
	PhaseCreated       Phase = "created"
	PhaseStarting      Phase = "starting"
	PhaseRunning       Phase = "running"
	PhaseStopping      Phase = "stopping"
	PhaseStopped       Phase = "stopped"
	PhaseCleaning      Phase = "cleaning"
	PhaseCleaned       Phase = "cleaned"
	PhaseCreateFailed  Phase = "create_failed"
	PhaseStartFailed   Phase = "start_failed"
	PhaseStopFailed    Phase = "stop_failed"
	PhaseCleanupFailed Phase = "cleanup_failed"
)

type ReconcileReport

type ReconcileReport struct {
	VMID    string
	Cleaned []string
	Failed  map[string]string
	Skipped string
}

type Reconciler

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

func NewReconciler

func NewReconciler() *Reconciler

func NewReconcilerWithManagers

func NewReconcilerWithManagers(stateMgr *state.Manager, subnetAlloc *state.SubnetAllocator) *Reconciler

func (*Reconciler) ReconcileAll

func (r *Reconciler) ReconcileAll(forceRunning bool) ([]ReconcileReport, error)

func (*Reconciler) ReconcileVM

func (r *Reconciler) ReconcileVM(vmID string, forceRunning bool) (ReconcileReport, error)

type Record

type Record struct {
	Version   int                      `json:"version"`
	VMID      string                   `json:"vm_id"`
	Backend   string                   `json:"backend,omitempty"`
	Phase     Phase                    `json:"phase"`
	UpdatedAt time.Time                `json:"updated_at"`
	LastError string                   `json:"last_error,omitempty"`
	Resources Resources                `json:"resources,omitempty"`
	Cleanup   map[string]CleanupResult `json:"cleanup,omitempty"`
}

type Resources

type Resources struct {
	StateDir      string `json:"state_dir,omitempty"`
	Workspace     string `json:"workspace,omitempty"`
	KernelRef     string `json:"kernel_ref,omitempty"`
	KernelPath    string `json:"kernel_path,omitempty"`
	RootfsPath    string `json:"rootfs_path,omitempty"`
	SubnetFile    string `json:"subnet_file,omitempty"`
	GatewayIP     string `json:"gateway_ip,omitempty"`
	GuestIP       string `json:"guest_ip,omitempty"`
	SubnetCIDR    string `json:"subnet_cidr,omitempty"`
	VsockPath     string `json:"vsock_path,omitempty"`
	TAPName       string `json:"tap_name,omitempty"`
	FirewallTable string `json:"firewall_table,omitempty"`
	NATTable      string `json:"nat_table,omitempty"`
}

type Store

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

func NewStore

func NewStore(vmDir string) *Store

func (*Store) Exists

func (s *Store) Exists() bool

func (*Store) History

func (s *Store) History() ([]Record, error)

func (*Store) Init

func (s *Store) Init(vmID, backend, stateDir string) error

func (*Store) Load

func (s *Store) Load() (*Record, error)

func (*Store) MarkCleanup

func (s *Store) MarkCleanup(name string, opErr error) error

func (*Store) Path

func (s *Store) Path() string

func (*Store) SetLastError

func (s *Store) SetLastError(err error) error

func (*Store) SetPhase

func (s *Store) SetPhase(phase Phase) error

func (*Store) SetResource

func (s *Store) SetResource(updateFn func(*Resources)) error

func (*Store) Update

func (s *Store) Update(updateFn func(*Record) error) error

type VMManager

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

VMManager wraps state lifecycle operations and ensures host resources are reconciled before metadata removal.

func NewVMManager

func NewVMManager() *VMManager

func NewVMManagerWithDeps

func NewVMManagerWithDeps(stateMgr *state.Manager, subnetAlloc *state.SubnetAllocator) *VMManager

func (*VMManager) Kill

func (m *VMManager) Kill(id string) error

func (*VMManager) List

func (m *VMManager) List() ([]state.VMState, error)

func (*VMManager) Prune

func (m *VMManager) Prune() ([]string, error)

func (*VMManager) Remove

func (m *VMManager) Remove(id string) error

Jump to

Keyboard shortcuts

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