provideradmission

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmissionResult

type AdmissionResult struct {
	Decision             admission.Decision `json:"decision"`
	PreemptedWarmWorkers []string           `json:"preempted_warm_workers,omitempty"`
}

type Allocation

type Allocation struct {
	InstanceName     string
	ControllerID     string
	PoolID           string
	PoolName         string
	VCPU             int
	MemoryMiB        int
	ImageFingerprint string
	// State is derived from immutable Incus lifecycle metadata. An empty value
	// is treated as StateCreated for compatibility with cold workers.
	State   providerjournal.LeaseState
	JobName string
}

type Controller

type Controller struct {
	Store        providerjournal.Store
	ControllerID string
	Policy       admission.ReservePolicy
	LeaseTTL     time.Duration
	Now          func() time.Time
}

func (Controller) Admit

func (c Controller) Admit(
	ctx context.Context,
	host admission.HostSnapshot,
	observed []Allocation,
	request Request,
) (admission.Decision, error)

func (Controller) AdmitPreemptible

func (c Controller) AdmitPreemptible(
	ctx context.Context,
	host admission.HostSnapshot,
	observed []Allocation,
	request Request,
) (AdmissionResult, error)

AdmitPreemptible atomically reserves a cold request and marks a deterministic capacity-satisfying set of unclaimed warm-ready leases as its victims. The caller must delete every returned VM before launching the reserved job worker, then call this method again with fresh host/inventory state to prove that the hand-off preserved all reserves.

func (Controller) AuthorizeWarmDrain

func (c Controller) AuthorizeWarmDrain(ctx context.Context, instanceName string) error

AuthorizeWarmDrain verifies under the journal lock that the exact instance is an unclaimed ready lease. The manager must remain stopped after this check so no new claim can be admitted before the provider teardown begins.

func (Controller) ClaimWarm

func (c Controller) ClaimWarm(
	ctx context.Context,
	observed []Allocation,
	request WarmClaimRequest,
) (WarmClaimResult, error)

ClaimWarm atomically binds one GARM job identity to one already observed, unregistered warm VM. It performs no Incus mutation and is safe to repeat after a provider crash: the same job always receives the same provider ID.

func (Controller) MarkCreated

func (c Controller) MarkCreated(ctx context.Context, instanceName string) error

MarkCreated records that Incus accepted the create transaction. It refuses to manufacture a lease because admission must precede every mutation.

func (Controller) MarkDeleting

func (c Controller) MarkDeleting(ctx context.Context, instanceName string) error

func (Controller) MarkWarmInjected

func (c Controller) MarkWarmInjected(ctx context.Context, jobName, instanceName string) error

func (Controller) Reconcile

func (c Controller) Reconcile(ctx context.Context, observed []Allocation) error

Reconcile records the exact observed Incus inventory without making a new capacity decision. It is used when a provider retry adopts a VM that already exists after a process or manager restart.

func (Controller) Release

func (c Controller) Release(ctx context.Context, instanceName string) error

func (Controller) Resolve

func (c Controller) Resolve(ctx context.Context, identifier string) (string, error)

type Request

type Request struct {
	Allocation
	QueueIntentAuthorized bool
}

type WarmClaimRequest

type WarmClaimRequest struct {
	JobName          string
	ControllerID     string
	PoolID           string
	PoolName         string
	ImageFingerprint string
}

type WarmClaimResult

type WarmClaimResult struct {
	InstanceName string
	State        providerjournal.ClaimState
	Found        bool
}

Jump to

Keyboard shortcuts

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