Documentation
¶
Index ¶
- Constants
- type Constraints
- type Dependency
- type Event
- type EventKind
- type Option
- type Order
- type Package
- type Scheduler
- func (s *Scheduler) AddNode(pkg Package)
- func (s *Scheduler) Ch() <-chan Event
- func (s *Scheduler) CheckConstraints(constraints Constraints) error
- func (s *Scheduler) Complete(completed string)
- func (s *Scheduler) Dump() []byte
- func (s *Scheduler) DumpByName(name string) []byte
- func (s *Scheduler) Pause()
- func (s *Scheduler) RemoveNode(name string)
- func (s *Scheduler) Reschedule(name string)
- func (s *Scheduler) Resume()
- func (s *Scheduler) Schedule()
- func (s *Scheduler) Stop()
- func (s *Scheduler) Trigger(name string)
Constants ¶
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
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 ¶
WithBootstrapCondition sets the predicate that gates scheduling until bootstrap is ready.
func WithDeckhouseVersionGetter ¶
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 ¶
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 ¶
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
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
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
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
Dump returns a YAML snapshot of all nodes and their current state.
func (*Scheduler) DumpByName ¶ added in v1.76.0
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
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
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.