schedule

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FunctionalOrder is the Order value assigned to functional (non-critical) packages.
	// It is higher than any critical package order, ensuring functional packages are
	// scheduled only after all critical packages have been processed.
	FunctionalOrder = 999
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraints added in v1.76.0

type Constraints struct {
	Order        Order                 // Scheduling priority; lower values run first.
	Kubernetes   *semver.Constraints   // Kubernetes version constraint (e.g., ">=1.21")
	Deckhouse    *semver.Constraints   // Deckhouse version constraint (e.g., ">=1.60")
	Dependencies map[string]Dependency // Inter-package dependencies; keyed by package name.
}

Constraints defines the scheduling requirements for a Package: ordering priority, version bounds, and inter-package dependencies.

type Dependency added in v1.76.0

type Dependency struct {
	Constraint *semver.Constraints `json:"constraint" yaml:"constraint"` // Semver constraint the dependency must satisfy
	Optional   bool                `json:"optional" yaml:"optional"`     // If true, the check is skipped when the dependency is absent
}

Dependency describes a requirement on another package, with an optional semver constraint and a flag to skip the check when the target is absent.

type Event added in v1.76.0

type Event struct {
	Kind    EventKind
	Name    string
	Reason  string
	Message string
	Enabled []string
}

Event represents a single lifecycle transition in the scheduling graph. Name identifies the affected node; Enabled is populated only for EventGlobalDone.

type EventKind added in v1.76.0

type EventKind int

EventKind identifies the type of lifecycle event emitted by the Scheduler.

const (
	// EventSchedule is emitted when a node transitions from idle to scheduled.
	EventSchedule EventKind = iota
	// EventDisable is emitted when a node loses eligibility during a scheduling pass.
	EventDisable
	// EventGlobalDone is emitted when the global sentinel node completes,
	// carrying the list of currently enabled package names.
	EventGlobalDone
)

type Option

type Option func(*Scheduler)

Option configures a Scheduler during construction.

func WithBootstrapCondition

func WithBootstrapCondition(cond condition.Condition) Option

WithBootstrapCondition sets the predicate that gates scheduling until bootstrap is ready.

func WithDeckhouseVersionGetter

func WithDeckhouseVersionGetter(deckhouseVersionGetter version.Getter) Option

WithDeckhouseVersionGetter sets the provider for the current Deckhouse version.

func WithDependencyGetter

func WithDependencyGetter(getter dependency.Getter) Option

WithDependencyGetter sets the provider for the current dependency version.

func WithKubeVersionGetter

func WithKubeVersionGetter(kubeVersionGetter version.Getter) Option

WithKubeVersionGetter sets the provider for the current Kubernetes version.

type Order added in v1.76.0

type Order uint

Order is a numeric priority for scheduling: lower values are processed first.

type Package

type Package interface {
	GetName() string
	GetVersion() *semver.Version
	GetConstraints() Constraints
}

Package is the interface that graph participants must implement to be managed by the Scheduler.

type Scheduler

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

Scheduler manages a dependency graph of packages and their lifecycle. Each scheduling pass recomputes eligibility, cascade-disables nodes that lost it, and advances newly-eligible nodes — all in topological order. All exported methods are safe for concurrent use.

func NewScheduler

func NewScheduler(opts ...Option) *Scheduler

NewScheduler creates a Scheduler with an empty dependency graph and a buffered event channel. Use functional options to configure version providers and conditions. Call Scheduler.Ch to consume lifecycle events.

func (*Scheduler) AddNode added in v1.76.0

func (s *Scheduler) AddNode(pkg Package)

AddNode registers a single package, wires its dependency edges into the existing graph, and triggers a full scheduling pass. Newly-eligible dependents are advanced automatically.

func (*Scheduler) Ch added in v1.76.0

func (s *Scheduler) Ch() <-chan Event

Ch returns a read-only channel that emits Event values as the graph evolves. The caller must drain this channel to avoid blocking the scheduler.

func (*Scheduler) CheckConstraints added in v1.76.0

func (s *Scheduler) CheckConstraints(constraints Constraints) error

CheckConstraints evaluates the given constraints against the current cluster state and returns an error describing the first unsatisfied constraint, or nil if all are met.

func (*Scheduler) Complete added in v1.76.0

func (s *Scheduler) Complete(completed string)

Complete marks the named package as active (processing finished) and runs a scheduling pass to advance any newly-eligible dependents.

func (*Scheduler) Dump added in v1.76.0

func (s *Scheduler) Dump() []byte

Dump returns a YAML snapshot of all nodes and their current state.

func (*Scheduler) DumpByName added in v1.76.0

func (s *Scheduler) DumpByName(name string) []byte

DumpByName returns a YAML snapshot of a single scheduler node by name. Returns empty bytes if the node is not found. It is used by the debug endpoint to inspect the scheduling state of an individual package without dumping the entire graph.

func (*Scheduler) Pause

func (s *Scheduler) Pause()

Pause prevents any state changes from being processed.

func (*Scheduler) RemoveNode added in v1.76.0

func (s *Scheduler) RemoveNode(name string)

RemoveNode removes a package from the graph, cleans up all dependency edges that reference it, and triggers a full reschedule.

func (*Scheduler) Reschedule added in v1.76.0

func (s *Scheduler) Reschedule(name string)

Reschedule reverts the named package to idle and runs a full scheduling pass, causing it (and potentially its dependents) to be rescheduled. It is a no-op if the package does not exist.

func (*Scheduler) Resume

func (s *Scheduler) Resume()

Resume enables state change processing and re-evaluates all packages. For each package whose state changed, the appropriate callback is invoked.

func (*Scheduler) Schedule added in v1.76.0

func (s *Scheduler) Schedule()

Schedule forces a full scheduling pass without changing any node state. Use when external conditions (e.g. Kubernetes version) have changed and the graph needs re-evaluation.

func (*Scheduler) Stop added in v1.76.0

func (s *Scheduler) Stop()

Stop closes the event channel, preventing further events from being sent. It is safe to call Stop concurrently and multiple times.

func (*Scheduler) Trigger added in v1.76.0

func (s *Scheduler) Trigger(name string)

Trigger resets a node's direct followers to idle, then runs a full scheduling pass so they are re-evaluated and potentially rescheduled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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