scheduling

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scheduling decides which worker should host an actor.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCapacity = errors.New("no worker that meets the constraints has room")

ErrNoCapacity is returned by Schedule when no worker that meets the constraints has room. The cause can be full workers, or no worker that meets the constraints at all.

Functions

func Booking added in v1.0.0

func Booking(worker *ateapi.Worker, constraints Constraints) (*ateapi.Resources, bool)

Booking is what an actor takes from the worker's capacity: its limits plus the overhead of the worker runtime it would run under there. It reports false when that doesn't fit in an int64, and the actor doesn't fit on the worker.

func Registered

func Registered(worker *ateapi.Worker) bool

Registered reports whether worker's current worker process has registered and reported its sandbox class and runtimes. The assignment records the runtime and atelet requires it on Run/Restore, so a worker without one cannot host anything yet.

Types

type Constraints

type Constraints struct {
	// SandboxClass, when set, is the sandbox class of the snapshot the actor
	// restores from, and the worker's must equal it. A snapshot's files, its
	// durable volumes included, are written by one class's worker and read
	// back by the same, so unlike RequiredRuntime this holds for every
	// fidelity and is never relaxed. Empty for an actor with no snapshot,
	// which boots on whichever class its selectors pick.
	SandboxClass string

	// RequiredRuntime, when it names a runtime, restricts placement to
	// workers whose DefaultRuntime or RestorableRuntimes can restore a
	// snapshot stamped with it. Prepared once per Schedule, since Applies
	// asks it of every candidate.
	RequiredRuntime hardware.Requirement

	// SnapshotRuntime is the runtime of the snapshot the actor restores from,
	// or the zero Requirement when it starts on a worker's default runtime.
	// Unlike RequiredRuntime it is never relaxed: it picks the worker runtime
	// the actor runs under, and so the overhead it is booked with.
	SnapshotRuntime hardware.Requirement

	// TemplateSelector and ActorSelector must both match the worker's labels.
	TemplateSelector labels.Selector
	ActorSelector    labels.Selector

	// RequiredNodes, when non-empty, restricts placement to workers running
	// on one of these nodes. Used when the actor's latest snapshot is local
	// to specific node VMs.
	RequiredNodes []string

	// Limits are the actor's declared resource limits, in the units a Worker
	// reports its capacity in, so the two subtract.
	Limits *ateapi.Resources
}

Constraints describes what a worker must satisfy to host an actor.

type Option

type Option func(*scheduler)

Option configures the Scheduler returned by New.

func WithIntn

func WithIntn(intn func(n int) int) Option

WithIntn overrides the random source used to sample candidate pairs: when n >= 2 candidates exist, Schedule calls intn(n) and then intn(n-1).

type Scheduler

type Scheduler interface {
	// Schedule returns a worker that meets constraints and has room.
	// Returns ErrNoCapacity when no worker that meets constraints has room.
	Schedule(ctx context.Context, constraints Constraints) (*ateapi.Worker, error)

	// Applies reports whether worker satisfies non-capacity constraints. Capacity
	// is excluded so an existing assignment does not make its Worker ineligible.
	Applies(worker *ateapi.Worker, constraints Constraints) bool

	// HasRoom reports whether worker's remaining capacity admits one more actor
	// of this size, in every dimension. Independent of Applies.
	HasRoom(worker *ateapi.Worker, constraints Constraints) bool
}

Scheduler answers placement questions against the current worker fleet.

func New

func New(source WorkerSource, opts ...Option) Scheduler

New returns a Scheduler placing onto workers reported by source.

type WorkerSource

type WorkerSource interface {
	Workers() ([]*ateapi.Worker, error)
}

WorkerSource provides the whole fleet of workers.

Jump to

Keyboard shortcuts

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