core

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 20 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 core is the engine core: the registry of package Reconcilers, Global, the boot, the dispatcher of scheduler events and readiness. It makes no lifecycle decisions and never reads Kubernetes: it passes every input whole to the package Reconciler that owns the name, to Global or to the scheduler.

Index

Constants

This section is empty.

Variables

View Source
var ErrGlobalNotSynced = errors.New("global hooks not synchronized")

ErrGlobalNotSynced is Boot's error when Global's hooks did not synchronize within globalSyncTimeout.

Functions

This section is empty.

Types

type BootGlobal

type BootGlobal struct {
	Module global.Module
	// Settings is Global's settings checkpoint; nil makes Global wait for the first Apply.
	Settings *model.Settings
}

BootGlobal is Global's boot input, a type of its own so there is no room for a missing, duplicated or attached Global.

type Config

type Config struct {
	// Notify is called with a package name after its Report changed, from the package Reconciler,
	// Current and Global goroutines; it must not block. Nil disables it.
	Notify func(name string)
}

Config configures an Engine.

type Deps

type Deps struct {
	Reconciler lifecycle.Deps
	Global     global.Deps
}

Deps are the effects of every package Reconciler and of Global; New sets their scheduler fields.

type Engine

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

Engine is the package registry; every method is safe for concurrent use.

Invariant: Boot runs exactly once, before any controller starts; controllers call Apply and Remove only after Boot has returned; Shutdown runs exactly once, and Apply and Remove are ignored from its start (controllers may still reconcile while it runs).

func New

func New(cfg Config, sched scheduler, deps Deps) *Engine

New returns an Engine and starts its dispatcher. The scheduler must be paused.

func (*Engine) Activated

func (e *Engine) Activated(name string) (model.Revision, bool)

Activated returns the revision name's Current runs, for the admission webhooks and the debug server; false without one, also once removed. Never blocks on the package Reconciler's work.

func (*Engine) Apply

func (e *Engine) Apply(desired model.Desired)

Apply passes desired to the package Reconciler of its name, creating it for an unknown name or one that has finished (see finished); the package Reconciler ignores it while it removes (see entry). KindGlobal and the reserved name global go to Global (dropped without one), so no package Reconciler can take Global's node. A module's Intent reaches the scheduler first, also while the package Reconciler removes. Non-blocking.

func (*Engine) Boot

func (e *Engine) Boot(ctx context.Context, bootGlobal *BootGlobal, packages []model.BootPackage) error

Boot restores the checkpoints persisted before a restart and starts them, before any controller starts. Blocking; called once, with the scheduler paused. bootGlobal nil boots no Global (no global node, no barrier): the engine without EnableModuleV2, which runs applications only.

  1. Refuse a package named global or a name passed twice: AddNode replaces by name, so either would take another's node, and the registry would lose a package Reconciler Shutdown must stop.
  2. Add the global node and start Global, so its sync (the hooks) runs while packages restore.
  3. Restore every package with a Version (lifecycle.Restore), in parallel; the first error is returned and deckhouse must exit. A package being deleted is restored too, to be uninstalled.
  4. Start a package Reconciler for every restored package; its Current's facts accumulate while paused. A removing one starts removing; readiness does not wait for it.
  5. Set the modules' intents.
  6. The boot gate: with a Global, wait until its hooks are synchronized, bounded by ctx and by globalSyncTimeout; without one, return with the scheduler paused until Engine.Resume.
  7. With a Global, Resume.

Why 4 and 5 come before Resume: an unknown intent falls to the module floor (Disable), and an unknown gate input (the Kubernetes version global discovery fills) reads as Forbid; the first computation would disable modules and delete their releases on every restart.

Restored Currents run once after boot with their checkpoint, without waiting for Apply (applied is not persisted); an unchanged release makes that run cheap.

func (*Engine) Converged

func (e *Engine) Converged() bool

Converged reports the live convergence: Global synchronized, when there is one, and the scheduler's global and module nodes converged (applications never hold it).

func (*Engine) GlobalSynced

func (e *Engine) GlobalSynced() bool

GlobalSynced reports whether Global's hooks are synchronized; true without Global.

func (*Engine) Names

func (e *Engine) Names(kind model.Kind) []string

Names returns the names of the package Reconcilers of kind, removed ones included, sorted. Never blocks on the package Reconciler work.

func (*Engine) Ready

func (e *Engine) Ready() bool

Ready reports whether the startup converge has finished: every module Boot restored was applied or removed, and Converged was true, at least once. It latches, because it backs the readiness probe: every settings change or update makes some node unconverged for a while, and a live answer would take deckhouse's own webhooks off their Service endpoints each time. A restored module that keeps failing keeps it false, as it held addon-operator's first converge (decided).

func (*Engine) Recheck

func (e *Engine) Recheck()

Recheck makes the scheduler compute once more, so the rules re-read inputs that are not facts of any node: without a Global, addon-operator's state (the wiring must call it at the end of every addon-operator converge); with one, a global hook's enable signal, which changes no values checksum (Build wires it). A no-op before the boot gate ended and after Shutdown.

func (*Engine) Remove

func (e *Engine) Remove(name string, kind model.Kind)

Remove asks the package Reconciler of name to uninstall; completion is visible as Report.Removed. For an unknown name it creates a package Reconciler that deletes the release by name (kind selects its namespace): this is how a remove interrupted by a restart finishes. A repeated Remove keeps reporting Removed. global is never removed. Non-blocking.

func (*Engine) Report

func (e *Engine) Report(name string) (model.Report, bool)

Report returns the lifecycle half of the named package's status and whether the package is known; global is Global's. Never blocks on the package Reconciler or Global work.

func (*Engine) Resume

func (e *Engine) Resume()

Resume ends the boot gate of an Engine without a Global; the wiring calls it when addon-operator has converged. Why wait: the gate inputs then come from addon-operator's global values, known only after its first converge, and an unknown input reads as Forbid, so an earlier computation would disable every restored application and delete its release. A call during Boot is deferred to its end, so the first computation sees every restored node. Later converges do not pause the engine (the inputs stay known); Recheck follows them. Idempotent; a no-op with a Global.

func (*Engine) Shutdown

func (e *Engine) Shutdown()

Shutdown stops everything without uninstalling or detaching anything, and blocks until every goroutine has exited; also after a failed Boot. Apply and Remove are ignored from its start. Package Reconcilers stop concurrently, then Global, because packages run against what Global provides; then the scheduler, whose Stop ends the dispatcher.

Jump to

Keyboard shortcuts

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