placement

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 5 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 placement is the multi-node scheduler: node label selectors plus a simple spread over eligible nodes. No bin-packing, by design.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEligibleNode = errors.New("placement: no eligible node")

ErrNoEligibleNode is returned when no candidate passes every filter.

Functions

func Check

func Check(c Candidate, req Request) error

Check validates an explicit target against req, the manual-assignment path.

func Filter

func Filter(c Candidate, req Request) string

Filter returns why c may not take req, or "" when it may.

func ParseLabels

func ParseLabels(pairs []string) (map[string]string, error)

ParseLabels turns ["k=v", ...] into a validated map.

func ValidateLabels

func ValidateLabels(labels map[string]string) error

ValidateLabels checks keys and values are short, plain identifiers.

Types

type Candidate

type Candidate struct {
	ID          string
	Name        string
	Labels      map[string]string
	Schedulable bool
	Online      bool
	// Load is how many apps and databases already run there.
	Load int
}

Candidate is one node as the scheduler sees it.

type Decision

type Decision struct {
	NodeID   string
	Rejected []Rejection
}

Decision is the chosen node, plus every rejected candidate's reason.

func Spread

func Spread(cands []Candidate, req Request) (Decision, error)

Spread picks the least loaded eligible candidate, ties broken by ID so the choice is deterministic.

type Rejection

type Rejection struct {
	NodeID string `json:"node_id"`
	Reason string `json:"reason"`
}

Rejection says why one candidate was filtered out.

type Request

type Request struct {
	Selector Selector
	// Exclude is skipped outright, typically the node being drained.
	Exclude string
}

Request is what one placement decision needs.

type Selector

type Selector map[string]string

Selector is a set of key=value pairs a node's labels must all carry.

func (Selector) Matches

func (sel Selector) Matches(labels map[string]string) bool

Matches reports whether labels satisfy every pair in sel.

func (Selector) String

func (sel Selector) String() string

String renders sel as sorted "k=v,k=v".

Jump to

Keyboard shortcuts

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