scheduler

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 16 Imported by: 0

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 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")
View Source
var (
	ErrProfileRevisionMismatch = errors.New("SecondBox scheduler ProfileRevision mismatch")
)

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
	GuestProtocolGeneration  uint32
	PreferredArtifactDigests []string
	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
	ArtifactDigests         []string
	Materializations        []MaterializationSnapshot
	SupportedEgressContexts []string
	GuestProtocolMinimum    uint32
	GuestProtocolMaximum    uint32
}

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 locality 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
}

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