scheduler

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 18 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 scheduler selects compatible runners and persists fenced assignment authority.

Index

Constants

View Source
const (
	DrainPhaseActive   = "active"
	DrainPhaseDraining = "draining"
)

Variables

View Source
var (
	ErrProfileRevisionMismatch = errors.New("SecondBox scheduler ProfileRevision mismatch")
	// ErrCapacityWaitExpired refuses placement once the originating start's
	// capacity wait has ended.
	ErrCapacityWaitExpired = errors.New("SecondBox scheduler start capacity wait expired")
)
View Source
var ErrEgressContextUnavailable = ports.ErrEgressContextUnavailable
View Source
var ErrHomeRunnerUnavailable = errors.New("SecondBox Sandbox home runner is unavailable")
View Source
var ErrNoCompatibleRunner = errors.New("SecondBox scheduler found no compatible runner")

Functions

This section is empty.

Types

type Capacity

type Capacity struct {
	VCPUCount   int64
	MemoryBytes int64
	DiskBytes   int64
	Instances   int64
	Operations  int64
}

Capacity is runner compute that may be reserved by assignments.

type DurableAssignment

type DurableAssignment struct {
	ID                      string
	SandboxID               string
	InstanceID              string
	RunnerID                string
	ProfileRevisionID       string
	BackendKind             string
	BackendReference        string
	Generation              int64
	FencingToken            []byte
	State                   string
	CapabilitySnapshot      map[string]string
	ResolvedArtifacts       map[string]string
	ReleaseProof            map[string]string
	FailureClass            string
	RetryCount              int64
	RetryLimit              int64
	OperationDeadline       time.Time
	ClaimExpiresAt          time.Time
	ReconcileOwner          string
	ReconcileClaimExpiresAt time.Time
	NextReconcileAt         time.Time
	Revision                int64
	CreatedAt               time.Time
	UpdatedAt               time.Time
	EgressContext           *string
}

DurableAssignment contains every private runner and backend authority field.

type MaterializationSnapshot added in v0.7.0

type MaterializationSnapshot struct {
	BackendKind     string `json:"backendKind"`
	Architecture    string `json:"architecture"`
	RuntimeDigest   string `json:"runtimeDigest"`
	ToolchainDigest string `json:"toolchainDigest"`
	Digest          string `json:"digest"`
}

MaterializationSnapshot is one revalidated local backend composition.

type PostgresStore

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

PostgresStore coordinates scheduler replicas through durable transactions.

func NewPostgresStore

func NewPostgresStore(
	ctx context.Context,
	config PostgresStoreConfig,
) (*PostgresStore, error)

NewPostgresStore connects the scheduler to PostgreSQL authority.

func (*PostgresStore) Close

func (store *PostgresStore) Close()

func (*PostgresStore) Schedule

func (store *PostgresStore) Schedule(
	ctx context.Context,
	request ScheduleRequest,
) (DurableAssignment, bool, error)

Schedule serializes one Sandbox generation and reserves capacity on one compatible Runner.

type PostgresStoreConfig

type PostgresStoreConfig struct {
	DatabaseURL string
	Now         func() time.Time
}

PostgresStoreConfig contains the scheduler's explicit durable dependencies.

type Requirements

type Requirements struct {
	PoolName             string
	Architecture         string
	RequiredCapabilities []string
	Capacity             Capacity
	EgressContext        *string
}

Requirements are immutable ProfileRevision placement constraints.

type RunnerSnapshot

type RunnerSnapshot struct {
	ID                      string
	PoolName                string
	BackendKind             string
	Architecture            string
	Capabilities            map[string]bool
	Allocatable             Capacity
	Reserved                Capacity
	DrainPhase              string
	LastHeartbeatAt         time.Time
	Materializations        []MaterializationSnapshot
	SupportedEgressContexts []string
	GuestProtocolMinimum    uint32
	GuestProtocolMaximum    uint32
	StoragePressureStatus   string
}

RunnerSnapshot is one durable registration and latest heartbeat view.

func SelectHomeRunner

func SelectHomeRunner(
	homeRunnerID string,
	requirements Requirements,
	runners []RunnerSnapshot,
	now time.Time,
	heartbeatTimeout time.Duration,
) (RunnerSnapshot, error)

SelectHomeRunner admits only the current authoritative home Runner. Compatible non-home Runners are deliberately invisible to ordinary lifecycle placement.

func SelectRunner

func SelectRunner(
	requirements Requirements,
	runners []RunnerSnapshot,
	now time.Time,
	heartbeatTimeout time.Duration,
) (RunnerSnapshot, error)

SelectRunner applies hard compatibility before free capacity and stable identity ordering.

type ScheduleRequest

type ScheduleRequest struct {
	AssignmentID            string
	AssignmentCommandID     string
	InstanceID              string
	SandboxID               string
	WorkspaceID             string
	StartMutationID         string
	ProfileRevisionID       string
	Requirements            Requirements
	AssignmentCommand       *runnerv1.AssignmentCommand
	FencingToken            []byte
	ResolvedArtifacts       map[string]string
	ClaimExpiresAt          time.Time
	OperationDeadline       time.Time
	RetryLimit              int64
	SerializationRetryLimit int
	HeartbeatTimeout        time.Duration
	Now                     time.Time
	EffectStartedAt         time.Time
	PlanReadyAt             time.Time
	// CapacityWaitDeadline, when set, is the instant after which the
	// originating start may no longer be placed. It is checked under the
	// Sandbox lock, so a plan loaded before the deadline cannot place after it.
	CapacityWaitDeadline *time.Time
	// LifecycleClaimOwner is the lifecycle worker whose claim on the Sandbox
	// this placement completes. While that worker still owns the claim, a new
	// Assignment releases it and schedules the starting Sandbox at its
	// operation deadline in the same transaction.
	LifecycleClaimOwner string
}

ScheduleRequest contains explicit immutable assignment authority and retry bounds.

Jump to

Keyboard shortcuts

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