buildrunners

package
v1.5.16 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 4 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 buildrunners decides when elastic build runners should be created or destroyed. It is pure: callers gather the facts and act on the plan.

Index

Constants

View Source
const (
	KindPlatform = "platform"
	KindCapacity = "capacity"
)

Demand kinds.

View Source
const (
	CodeNoAccount      = "no_account"
	CodeNoRegion       = "no_region_allowed"
	CodeNoSize         = "no_size_for_arch"
	CodeBudgetZero     = "budget_zero"
	CodeMaxRunners     = "max_runners"
	CodePriceUnknown   = "price_unknown"
	CodeBudgetExceeded = "budget_exceeded"
	CodeUnknownArch    = "unknown_arch"
)

Stable refusal codes, safe to match on in the API, audit rows and the dashboard.

Variables

This section is empty.

Functions

func ParseSizeMap

func ParseSizeMap(items []string) (map[string]string, error)

ParseSizeMap reads "os/arch=size" entries into a map; a bad entry is an error.

Types

type Caps

type Caps struct {
	AccountID      string
	MaxRunners     int
	MaxMonthlyUSD  float64
	IdleTTL        time.Duration
	AllowedRegions []string
	// SizeByArch maps an arch such as linux/arm64 to the one size used for it.
	SizeByArch map[string]string
	// PriceBySize is the listed monthly price per size; a missing size is refused.
	PriceBySize map[string]float64
	// SpentMonthUSD is what live and past elastic runners already cost this month.
	SpentMonthUSD float64
}

Caps are every limit the planner obeys. Zero values refuse, so a caller that forgets a field creates nothing.

type Demand

type Demand struct {
	App  string `json:"app"`
	Arch string `json:"arch"`
	Kind string `json:"kind"`
}

Demand is one build that could not be placed well on the runners that exist.

type Destroy

type Destroy struct {
	RunnerID    string `json:"runner_id"`
	Arch        string `json:"arch"`
	IdleSeconds int64  `json:"idle_seconds"`
	Reason      string `json:"reason"`
}

Destroy asks for one idle elastic runner to be removed.

type Plan

type Plan struct {
	Provisions []Provision `json:"provisions"`
	Destroys   []Destroy   `json:"destroys"`
	Refusals   []Refusal   `json:"refusals"`
}

Plan is the full outcome of one Decide call.

func Decide

func Decide(demands []Demand, runners []Runner, caps Caps, now time.Time) Plan

Decide plans creates and destroys from the facts given. It reads no clock and does no I/O.

type Provision

type Provision struct {
	Arch       string   `json:"arch"`
	Size       string   `json:"size"`
	Region     string   `json:"region"`
	AccountID  string   `json:"account_id"`
	Kind       string   `json:"kind"`
	Apps       []string `json:"apps"`
	MonthlyUSD float64  `json:"monthly_usd"`
}

Provision asks for one new runner.

type Refusal

type Refusal struct {
	Arch   string `json:"arch"`
	Code   string `json:"code"`
	Reason string `json:"reason"`
}

Refusal says why a demand got no runner.

type Runner

type Runner struct {
	ID           string `json:"id"`
	Arch         string `json:"arch"`
	Elastic      bool   `json:"elastic"`
	Cordoned     bool   `json:"cordoned"`
	ActiveBuilds int    `json:"active_builds"`
	// IdleSince is the last build end, or the enroll time when it never built.
	IdleSince  time.Time `json:"idle_since"`
	MonthlyUSD float64   `json:"monthly_usd"`
}

Runner is one build runner as the planner sees it.

Jump to

Keyboard shortcuts

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