Documentation
¶
Index ¶
- Constants
- type AnyOfGroup
- type Constraints
- type CycleError
- type Dependency
- type Event
- type EventKind
- type NoneOfGroup
- type Option
- type Order
- type Package
- type Scheduler
- func (s *Scheduler) AddNode(pkg Package) error
- func (s *Scheduler) Ch() <-chan Event
- func (s *Scheduler) CheckConstraints(name string, 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()
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 AnyOfGroup ¶ added in v1.76.1
type AnyOfGroup struct {
Name string `json:"name" yaml:"name"`
Members map[string]*semver.Constraints `json:"members" yaml:"members"`
}
AnyOfGroup is a group of alternative dependencies: at least one member must be installed and satisfy its constraint for the group to pass. A nil constraint on a member means "any installed version is acceptable". Name is the stable identifier used by the scheduler in failure diagnostics.
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. Source of topological ordering and checker inputs.
AnyOf []AnyOfGroup // Groups of alternative dependencies. Checker-only: never contributes edges to the topological graph, so fallback chains across packages do not produce cycles.
NoneOf []NoneOfGroup // Groups of forbidden dependencies. Checker-only: "must not be installed" is an admission predicate, not an ordering relation.
}
Constraints defines the scheduling requirements for a Package: ordering priority, version bounds, and inter-package dependencies.
type CycleError ¶ added in v1.76.1
type CycleError struct {
Members []string
}
CycleError reports a topological cycle in the dependency graph. Members are the participating node names, sorted alphabetically for deterministic output.
func (*CycleError) Error ¶ added in v1.76.1
func (e *CycleError) Error() string
Error renders the cycle members in a single line suitable for K8s admission rejections and operator-facing logs.
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 NoneOfGroup ¶ added in v1.76.1
type NoneOfGroup struct {
Name string `json:"name" yaml:"name"`
Members map[string]*semver.Constraints `json:"members" yaml:"members"`
}
NoneOfGroup is a group of forbidden dependencies: no member may be installed in a way that matches its constraint. A nil constraint on a member forbids the module at any installed version; a non-nil constraint narrows the forbidden range. Name is the stable identifier used by the scheduler in failure diagnostics.
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 it into the existing graph, and triggers a full scheduling pass. Newly-eligible dependents are advanced automatically.
Returns a *CycleError (without mutating any state) if adding the package would close a dependency cycle. Callers are expected to handle the error — typically by surfacing a status condition on the corresponding CR — and to retry once the manifest is fixed.
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(name string, constraints Constraints) error
CheckConstraints evaluates the given constraints against the current cluster state and the current dependency graph. Returns an error describing the first unsatisfied constraint (version, dependency) or a *CycleError if adding a node named `name` with these dependencies would create a topological cycle. Returns nil only when every check passes and the proposed addition would leave the dep graph acyclic.
`name` is the scheduler-side identifier of the package that would be added. It is used by the cycle-simulation step to identify the proposed graph vertex.
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 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.