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 ¶
- Variables
- func CheckReserved(reserved Reserved) error
- func LoopbackOrigin(value string) bool
- type CheckpointNode
- type Declarations
- type Deployment
- type Node
- type Placement
- type Reserved
- type Rules
- func (r *Rules) CheckAdmission(d Deployment, installation string) error
- func (r *Rules) CheckPublicOrigin(provider string) error
- func (r *Rules) ChooseCheckpoint(nodes []CheckpointNode, source string, ...) (string, error)
- func (r *Rules) DecidePlacement(d Deployment, nodes []Node) (*Placement, error)
- func (r *Rules) PublicURL() string
Constants ¶
This section is empty.
Variables ¶
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 reachable HTTPS public URL before they 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") // 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 ¶
CheckReserved admits an allocation on the node placement its Session reserved: the placement must be unreleased and its node available.
func LoopbackOrigin ¶
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 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 ¶
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.