scheduler

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MovementModeCordon    = "cordon"
	MovementModeDrain     = "drain"
	MovementModeRebalance = "rebalance"
)

Variables

This section is empty.

Functions

func ValidateAssignments

func ValidateAssignments(assignments []Assignment) error

ValidateAssignments checks persisted assignment structure before it is used or copied into a new desired revision.

func ValidateMovementPlan

func ValidateMovementPlan(plan MovementPlan) error

ValidateMovementPlan detects edits to a reviewed plan document.

Types

type Assignment

type Assignment struct {
	Slot   int    `json:"slot"`
	NodeID string `json:"nodeId"`
	Node   string `json:"node"`
}

Assignment binds one stable replica slot to an immutable platform node. Slots are one-based and are never renumbered during ordinary scale changes.

func PlanGlobal

func PlanGlobal(permitted, eligible []string, prior []Assignment) ([]Assignment, error)

PlanGlobal retains one assignment for every previously assigned permitted node and adds one for each newly eligible node. Node order never renumbers or moves existing slots; cordoned nodes remain represented until an explicit movement/removal operation is approved.

func PlanSticky

func PlanSticky(replicas int, permitted, eligible []string, prior []Assignment) ([]Assignment, error)

PlanSticky preserves every valid prior slot, removes only slots above the desired replica count, and assigns only new slots. It never silently moves a retained slot because membership order changed or a new node joined.

func Stable

func Stable(assignments []Assignment) []Assignment

Stable returns a slot-ordered copy suitable for state persistence.

type Movement

type Movement struct {
	Service                 string   `json:"service"`
	Slot                    int      `json:"slot"`
	FromNode                string   `json:"fromNode"`
	FromNodeID              string   `json:"fromNodeId,omitempty"`
	ToNode                  string   `json:"toNode,omitempty"`
	ToNodeID                string   `json:"toNodeId,omitempty"`
	Persistent              bool     `json:"persistent,omitempty"`
	Volumes                 []string `json:"volumes,omitempty"`
	RequiresVolumeMigration bool     `json:"requiresVolumeMigration,omitempty"`
}

type MovementBlocker

type MovementBlocker struct {
	Service string `json:"service"`
	Slot    int    `json:"slot"`
	Node    string `json:"node"`
	Reason  string `json:"reason"`
}

type MovementImpact

type MovementImpact struct {
	Service string `json:"service"`
	Slot    int    `json:"slot"`
	Node    string `json:"node"`
	NodeID  string `json:"nodeId,omitempty"`
}

MovementImpact identifies a replica that will remain in place when a node is cordoned and excluded from future assignments.

type MovementPlan

type MovementPlan struct {
	APIVersion      string                    `json:"apiVersion"`
	Kind            string                    `json:"kind"`
	PlanID          string                    `json:"planId"`
	Mode            string                    `json:"mode"`
	InputRevisionID string                    `json:"inputRevisionId"`
	TargetNode      string                    `json:"targetNode,omitempty"`
	TargetNodeID    string                    `json:"targetNodeId,omitempty"`
	Services        []MovementServiceProposal `json:"services"`
	Impacts         []MovementImpact          `json:"impacts,omitempty"`
	Moves           []Movement                `json:"moves,omitempty"`
	Blockers        []MovementBlocker         `json:"blockers,omitempty"`
	Executable      bool                      `json:"executable"`
	RequiresReview  bool                      `json:"requiresReview"`
	CreatedAt       time.Time                 `json:"createdAt"`
}

MovementPlan is an immutable, reviewable proposal. PlanID is a digest of the state revision and all proposed decisions; CreatedAt is informational and deliberately excluded from the digest.

func PlanMovement

func PlanMovement(mode, targetNode, inputRevisionID string, nodeIDs map[string]string, workloads []MovementWorkload) (MovementPlan, error)

PlanMovement proposes a drain or a conservative per-service rebalance. It never proposes moving a persistent service or a service with volume mounts.

type MovementServiceProposal

type MovementServiceProposal struct {
	Service  string       `json:"service"`
	Current  []Assignment `json:"current"`
	Proposed []Assignment `json:"proposed"`
}

type MovementWorkload

type MovementWorkload struct {
	Service    string
	Global     bool
	Persistent bool
	Volumes    []string
	Current    []Assignment
	Eligible   []string
}

MovementWorkload is the scheduler input for one service. Eligible contains only schedulable nodes allowed by that service's placement constraints.

Jump to

Keyboard shortcuts

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