Documentation
¶
Overview ¶
Package scheduling decides which worker should host an actor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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
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 ¶
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 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 ¶
WorkerSource provides the whole fleet of workers.