Documentation
¶
Overview ¶
Package lifecycle is the package Reconciler, one per package name: it decides which revision of the package runs and owns the two things that run it, Current (the running revision, lifecycle/current) and the Candidate (the preparation of the desired one). A new revision is downloaded, loaded and checked while Current keeps working; Current stops only after every check passed.
The loop wakes on an input from the core (Apply, Remove), a scheduler event, the end of a preparation attempt or its one timer; it pushes the latest configuration and event to Current, which interprets them itself, and decides with gate.Decide, a pure function over one snapshot:
UpToDate the desired version is Current's; a Candidate is dropped.
Prepare attach and load the desired revision; a failed attempt is retried with backoff.
Blocked a requirement, the settings, the update notification or the update window stop it.
The prepared Candidate is kept and the timer wakes the gate again (the window's
start, the notification's minimal time, a retry). The notification gate also asks
the package Reconciler to send the notification.
Activate every gate passed: the Candidate becomes Current.
A file is a lifecycle stage:
reconciler.go the type, its inputs and Start, which starts a restored package from its
checkpoint.
loop.go the loop and reconcile: one decision per wake, the one timer; the settings memo.
prepare.go the Candidate: attach, load, the retry backoff.
notify.go the update notification: the send, its retry, the sent notification, which
the activation or a cancelled update clears.
activate.go the switch: AddNode first, stop the old Current, start the new one, detach the
old image. The point of no return; there is no rollback. Restore, the same
preparation once at Boot.
remove.go removal: wait for an event of Current's revision, RemoveNode, uninstall,
detach, report Removed.
Invariants: at most one Current and one Candidate; the package has a scheduler node exactly while it has a Current; settings reach Current at once, also while a Candidate is blocked; instances are name@version, so a Candidate never touches Current's image, and a detach keeps the stored image; Shutdown stops everything and changes nothing, neither the cluster nor the Report.
Index ¶
- func Restore(ctx context.Context, deps Deps, pkg model.BootPackage) (*model.Revision, error)
- type Config
- type Deps
- type Disk
- type Disks
- type LoadFunc
- type Reconciler
- func (r *Reconciler) Activated() (model.Revision, bool)
- func (r *Reconciler) Apply(desired model.Desired)
- func (r *Reconciler) Done() <-chan struct{}
- func (r *Reconciler) HandleScheduleEvent(ev schedule.Event)
- func (r *Reconciler) Remove()
- func (r *Reconciler) Report() model.Report
- func (r *Reconciler) Shutdown()
- func (r *Reconciler) Start(parent context.Context)
- func (r *Reconciler) Wake()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Restore ¶
Restore brings back the Current revision of one package at boot: the preparation steps once, in place, then AddNode, while the scheduler is paused. Attach verifies against the registry, so a registry outage at restart makes the package unrestorable and Deckhouse exits until it is back (accepted). On error the caller must exit; the cleanup before the next boot removes what was attached.
Types ¶
type Config ¶
type Config struct {
Name string
// Kind selects the disk, Current's steps and the release namespace.
Kind model.Kind
// Restored is the checkpoint brought back at boot; nil when nothing is installed.
Restored *model.Restored
// Notify is called after the Report changed; it must not block.
Notify func()
}
Config configures one package Reconciler; the desired state arrives only through Apply.
type Deps ¶
type Deps struct {
Scheduler scheduler
Disks Disks
Load LoadFunc
Current current.Deps
Releases releaseDeleter // Releases deletes the release of a package without a Current.
Clock retry.Clock // Clock nil means the wall clock.
Logger *log.Logger // Logger nil means a no-op logger.
}
Deps are the effects of every package Reconciler; shared by all of them and safe for concurrent use.
type Disk ¶
type Disk struct {
Backend backend
Dir string
}
Disk is a backend with its working directory; an instance is mounted at disk.AttachPath(Dir, instance).
type Disks ¶
type Disks struct {
Apps Disk
Modules Disk
// EmbeddedDir is the deckhouse image directory: an embedded module's image is
// EmbeddedDir/<name> (the loader resolves the weight prefix). Nothing is attached there.
EmbeddedDir string
}
Disks are the disks of every kind, shared by every package Reconciler. Known limit, accepted: a backend holds its mutex during a download, so a detach can wait behind another package's download.
type LoadFunc ¶
LoadFunc loads a new package object of kind from an attached image; it reads only the image, never the cluster. The name is image.Name, never read from the path, which carries the version (name@version).
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler reconciles one package from its whole state on every wake; named so because "Package" also named the domain package and the loaded object. The exported methods are its inputs and never block on the loop's work, except Shutdown.
func NewReconciler ¶
func NewReconciler(cfg Config, deps Deps) *Reconciler
NewReconciler returns a package Reconciler that is not running yet. Called by Engine.
func (*Reconciler) Activated ¶
func (r *Reconciler) Activated() (model.Revision, bool)
Activated returns the revision Current runs; false without one. Safe from any goroutine; it does not wait for the loop.
func (*Reconciler) Apply ¶
func (r *Reconciler) Apply(desired model.Desired)
Apply records the latest desired state. Non-blocking.
func (*Reconciler) Done ¶
func (r *Reconciler) Done() <-chan struct{}
Done is closed when the loop has exited: after remove or shutdown.
func (*Reconciler) HandleScheduleEvent ¶
func (r *Reconciler) HandleScheduleEvent(ev schedule.Event)
HandleScheduleEvent records the latest scheduler event of this node. Non-blocking.
func (*Reconciler) Remove ¶
func (r *Reconciler) Remove()
Remove starts the removal; an Apply afterwards is ignored. Non-blocking; completion is visible as Report.Removed, after which the loop exits.
func (*Reconciler) Report ¶
func (r *Reconciler) Report() model.Report
Report returns a snapshot of the package's Report. Safe from any goroutine.
func (*Reconciler) Shutdown ¶
func (r *Reconciler) Shutdown()
Shutdown stops the preparation and Current and waits for the loop. It never uninstalls, never detaches Current's image (the next boot restores it) and reports nothing: a restart must not change statuses. Returns at once if Start never ran.
func (*Reconciler) Start ¶
func (r *Reconciler) Start(parent context.Context)
Start starts the loop; a restored package first starts Current from the checkpoint and pushes its configuration, when there is one, and a removing one starts removing. Called once by Engine: at the end of Boot for a restored package, else on the first Apply or Remove of the name.
func (*Reconciler) Wake ¶
func (r *Reconciler) Wake()
Wake wakes the loop without a new input: for a package Reconciler without a node, whose requirements gate still depends on the graph. Non-blocking.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package configstate holds the configuration state Current and Global share: what was pushed, what is in force, and the checksum every configuration is identified by.
|
Package configstate holds the configuration state Current and Global share: what was pushed, what is in force, and the checksum every configuration is identified by. |
|
Package current runs the working revision of one package: its configuration, hooks and release.
|
Package current runs the working revision of one package: its configuration, hooks and release. |
|
Package gate is the update decision of one package: Decide answers whether the desired revision is Current, must be prepared, is blocked, or may be activated.
|
Package gate is the update decision of one package: Decide answers whether the desired revision is Current, must be prepared, is blocked, or may be activated. |
|
Package global runs Global: the global hooks, the global settings and the global run, which ensures the CRDs and conversion webhooks of the enabled modules and publishes the enabled set into the global values.
|
Package global runs Global: the global hooks, the global settings and the global run, which ensures the CRDs and conversion webhooks of the enabled modules and publishes the enabled set into the global values. |
|
Package hooklane runs a package's runtime and synchronization hooks in lanes: one lane per hook queue of the package, a FIFO with one goroutine, so the hooks of one queue run one at a time in event order and the queues run in parallel, beside the package's operations.
|
Package hooklane runs a package's runtime and synchronization hooks in lanes: one lane per hook queue of the package, a FIFO with one goroutine, so the hooks of one queue run one at a time in event order and the queues run in parallel, beside the package's operations. |
|
Package inbox holds the latest value of every input of a loop plus a wake signal: inputs are states passed whole, so a loop that wakes late loses nothing by reading only the last one.
|
Package inbox holds the latest value of every input of a loop plus a wake signal: inputs are states passed whole, so a loop that wakes late loses nothing by reading only the last one. |
|
Package model is the vocabulary of the package lifecycle: the data that flows between Engine, the package Reconciler, Current and Global, and the Report.
|
Package model is the vocabulary of the package lifecycle: the data that flows between Engine, the package Reconciler, Current and Global, and the Report. |
|
Package operation runs one operation of Current, Global or the package Reconciler (the preparation of a candidate): its steps, in order, in a worker goroutine that the owner's loop starts and cancels.
|
Package operation runs one operation of Current, Global or the package Reconciler (the preparation of a candidate): its steps, in order, in a worker goroutine that the owner's loop starts and cancels. |
|
Package report stores the Report of one package or of Global.
|
Package report stores the Report of one package or of Global. |
|
Package retry is the backoff of every execution failure in the lifecycle and the Clock its deadlines are read with.
|
Package retry is the backoff of every execution failure in the lifecycle and the Clock its deadlines are read with. |