placement

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 6 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 placement decides whether the sandbox deployment admits new hosted work and which node receives it. Its rules are pure: they read the deployment and node facts the caller loads under the deployment lock, the provider declarations and the installation public URL, and do no I/O. The caller applies what they decide in the same transaction.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResetAdmission rejects new hosted work while a sandbox reset pauses
	// admission.
	ErrResetAdmission = errors.New("hosted admission is paused for a sandbox reset")
	// ErrAdmissionClosed rejects new hosted work that the deployment cannot
	// admit: without a valid specification, or for another installation.
	ErrAdmissionClosed = errors.New("environment is no longer available")
	// ErrPublicURLUnreachable rejects selection and admission when the provider
	// requires a reachable public origin and the installation is loopback.
	ErrPublicURLUnreachable = errors.New("This sandbox provider needs a public URL that is not loopback before its sandboxes can connect to Core.")
	// ErrNodesPreparing rejects placement while no node serves the target
	// generation and at least one is preparing it.
	ErrNodesPreparing = errors.New("sandbox nodes are preparing the target generation")
	// ErrNodeUnavailable reports a sandbox node that is offline, unready or
	// full, no node at all, or a deployment without a provider.
	ErrNodeUnavailable = errors.New("sandbox node unavailable")
	// ErrPublicURLRequired rejects rules without the installation public URL.
	ErrPublicURLRequired = errors.New("placement rules require the installation public URL")
)

Functions

func CheckReserved

func CheckReserved(reserved Reserved) error

CheckReserved admits an allocation on the node placement its Session reserved: the placement must be unreleased and its node available.

func LoopbackOrigin

func LoopbackOrigin(value string) bool

LoopbackOrigin reports whether a validated origin names a loopback host, which nothing outside the Core host can reach.

Types

type CheckpointNode added in v0.0.10

type CheckpointNode struct {
	Node       Node
	Checkpoint *sandbox.CheckpointCompatibility
}

CheckpointNode is a fresh readiness declaration for one immutable generation. Capacity is read under the same deployment lock as the allocation transfer.

type Declarations

type Declarations interface {
	// RequiresPublicOrigin reports whether the provider's guests must reach
	// Core at a public origin.
	RequiresPublicOrigin(provider string) (bool, error)
	// ValidateSpecification rejects a specification the provider cannot run.
	ValidateSpecification(provider string, spec sandbox.DeploymentSpec) error
}

Declarations are the provider declarations placement reads. *providers.Registry satisfies it.

type Deployment

type Deployment struct {
	// InstallationID is empty until the execution owner claims the
	// installation at startup.
	InstallationID string
	Provider, Mode string
	Generation     uint64
	// Resetting reports a sandbox reset in progress.
	Resetting     bool
	Specification json.RawMessage
}

Deployment is the deployment as placement reads it, loaded under the deployment lock.

type Node

type Node struct {
	ID                   string
	Online, ServingReady bool
	// ReadyGeneration is nil until the node serves a generation.
	ReadyGeneration        *uint64
	TargetState            string
	Active, Retained       int64
	MaxActive, MaxRetained int
	CoreURL                string
}

Node is one node of the installation with its presence and usage.

type Placement

type Placement struct {
	NodeID     string
	Generation uint64
}

Placement is the node and generation a new Session's Environment reserves.

type Reserved

type Reserved struct {
	NodeID     string
	Generation uint64
	Released   bool
	// Available reports that the node is connected, fresh and ready for the
	// reserved generation.
	Available bool
}

Reserved is the node placement a Session reserved for its Environment.

type Rules

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

Rules decides admission and placement for one installation. Its declarations and public URL never change after NewRules.

func NewRules

func NewRules(declarations Declarations, publicURL string) (*Rules, error)

NewRules returns the rules for the provider declarations and the installation public URL.

func (*Rules) CheckAdmission

func (r *Rules) CheckAdmission(d Deployment, installation string) error

CheckAdmission admits new hosted work on the deployment. installation is the canonical installation the work was provisioned for, or empty for a new Session. Only a claimed deployment with a provider admits hosted work.

func (*Rules) CheckPublicOrigin

func (r *Rules) CheckPublicOrigin(provider string) error

CheckPublicOrigin rejects a provider that requires a reachable public origin while the installation public URL is loopback.

func (*Rules) ChooseCheckpoint added in v0.0.10

func (r *Rules) ChooseCheckpoint(nodes []CheckpointNode, source string, compatibility sandbox.CheckpointCompatibility, cleanup bool) (string, error)

ChooseCheckpoint selects a compatible node without interpreting adapter tokens. A retained allocation already owns its source slot. Cleanup needs no active slot and compares only the artifact domain, but still reserves a retained slot.

func (*Rules) DecidePlacement

func (r *Rules) DecidePlacement(d Deployment, nodes []Node) (*Placement, error)

DecidePlacement chooses the node a new Session's hosted Environment reserves, or nil in direct mode, which places no node. It prefers the highest ready generation, then the fewest active sandboxes. It places only on nodes enrolled with the public URL; restores still reach the others.

func (*Rules) PublicURL

func (r *Rules) PublicURL() string

PublicURL returns the installation public URL, OAC_PUBLIC_URL. Core derives every address it gives nodes, sandboxes and administrators from it.

Jump to

Keyboard shortcuts

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