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 ¶
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: paused for maintenance, 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, or no node at all. ErrNodeUnavailable = errors.New("sandbox node unavailable") )
Functions ¶
func CheckReserved ¶
CheckReserved admits an allocation on the node placement its Session reserved: the placement must be unreleased and its node available.
func CheckRestore ¶
CheckRestore admits restoring suspended compute on its original node: the node must be online, ready for the allocation's generation and below its active capacity. Restore never selects another node.
func LoopbackOrigin ¶
LoopbackOrigin reports whether a validated origin names a loopback host, which nothing outside the Core host can reach.
Types ¶
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 an installation is claimed or configured.
InstallationID string
Provider, Mode string
Generation uint64
WebManaged bool
AdmissionPaused bool
// 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 Restore ¶
type Restore struct {
Node *Node
// Generation is zero when the allocation has none.
Generation uint64
GenerationReady bool
}
Restore is what restoring suspended compute on its node reads: the node, nil when the installation no longer has it, and whether the node is ready for the allocation's generation.
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, which is empty when the installation has none.
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. An unclaimed deployment admits everything.
func (*Rules) CheckPublicOrigin ¶
CheckPublicOrigin rejects a provider that requires a reachable public origin while the installation public URL is loopback.
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 when the deployment places no node: in direct mode and without a provider. It prefers the highest ready generation, then the fewest active sandboxes. A Web-managed installation places only on nodes enrolled with its public URL; restores still reach the others.