providerjournal

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ClaimsSchemaVersion = 2
View Source
const LegacySchemaVersion = 1
View Source
const PreemptionSchemaVersion = 3
View Source
const SchemaVersion = 4

Variables

This section is empty.

Functions

func IsImageMaintenanceInstance

func IsImageMaintenanceInstance(name string) bool

Types

type Claim

type Claim struct {
	JobName          string     `json:"job_name"`
	InstanceName     string     `json:"instance_name"`
	ControllerID     string     `json:"controller_id"`
	PoolID           string     `json:"pool_id"`
	PoolName         string     `json:"pool_name"`
	ImageFingerprint string     `json:"image_fingerprint"`
	State            ClaimState `json:"state"`
	ReservedAt       time.Time  `json:"reserved_at"`
	UpdatedAt        time.Time  `json:"updated_at"`
	ExpiresAt        time.Time  `json:"expires_at"`
}

Claim binds one GARM runner identity to one pre-booted, unregistered VM. The binding is persisted before any job credential crosses the Incus API. InstanceName is the provider ID returned to GARM; JobName is GARM's stable retry identity and therefore the map key.

type ClaimState

type ClaimState string
const (
	ClaimReserved ClaimState = "reserved"
	ClaimInjected ClaimState = "injected"
)

type Journal

type Journal struct {
	SchemaVersion        int              `json:"schema_version"`
	Generation           uint64           `json:"generation"`
	UpdatedAt            time.Time        `json:"updated_at"`
	WarmPreemptionsTotal uint64           `json:"warm_preemptions_total"`
	Leases               map[string]Lease `json:"leases"`
	Claims               map[string]Claim `json:"claims"`
}

func (Journal) Validate

func (j Journal) Validate() error

type Lease

type Lease struct {
	InstanceName     string     `json:"instance_name"`
	ControllerID     string     `json:"controller_id"`
	PoolID           string     `json:"pool_id"`
	PoolName         string     `json:"pool_name"`
	VCPU             int        `json:"vcpu"`
	MemoryMiB        int        `json:"memory_mib"`
	ImageFingerprint string     `json:"image_fingerprint"`
	State            LeaseState `json:"state"`
	// PreemptedBy durably binds speculative warm capacity to the admitted cold
	// request that is replacing it. It is set before VM teardown, so a warm
	// claim or replenishment process cannot race into the capacity hand-off.
	// State remains the observed lifecycle state until teardown actually starts;
	// MarkDeleting then moves it to StateDeleting.
	PreemptedBy string    `json:"preempted_by,omitempty"`
	AdmittedAt  time.Time `json:"admitted_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	ExpiresAt   time.Time `json:"expires_at"`
}

type LeaseState

type LeaseState string
const (
	StateAdmitted    LeaseState = "admitted"
	StateCreated     LeaseState = "created"
	StateDeleting    LeaseState = "deleting"
	StateWarmReady   LeaseState = "warm-ready"
	StateWarmClaimed LeaseState = "warm-claimed"
)

type MaintenanceReconcileResult

type MaintenanceReconcileResult struct {
	Applied    bool      `json:"applied"`
	ObservedAt time.Time `json:"observed_at"`
	Candidates []string  `json:"candidates"`
	Removed    []string  `json:"removed"`
	Retained   []string  `json:"retained"`
}

func ReconcileExpiredMaintenance

func ReconcileExpiredMaintenance(
	ctx context.Context,
	store Store,
	visible map[string]struct{},
	now time.Time,
	apply bool,
) (MaintenanceReconcileResult, error)

type Store

type Store struct {
	Path     string
	LockPath string
	Now      func() time.Time
}

func (Store) Read

func (s Store) Read(ctx context.Context) (Journal, error)

func (Store) ReadOnly

func (s Store) ReadOnly(ctx context.Context) (Journal, error)

ReadOnly observes one atomically published journal generation without opening or creating the lock file. Store updates are fsync+rename based, so a reader sees either the complete previous generation or the complete next generation. This path is for sandboxed telemetry processes that have no write access to the journal directory; lifecycle mutations must use Update.

func (Store) Update

func (s Store) Update(ctx context.Context, mutate func(*Journal) error) (Journal, error)

Jump to

Keyboard shortcuts

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