model

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: 13 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 model is the vocabulary of the package lifecycle: the data that flows between Engine, the package Reconciler, Current and Global, and the Report. It holds types, not behaviour.

Dependency interfaces live with their consumers. The three interfaces here are carrier types: Package, the loaded package object, and Windows and Notifier, the update calendar and the update notification webhook inside Policy. A value handed from one component to the next needs one type both can name; each consumer still calls it through its own narrow interface.

Index

Constants

View Source
const (
	ReasonSettingsInvalid = "SettingsInvalid"
	// ReasonRequirementsNotMet: CheckConstraints, CheckDependents (an enabled dependent rejects the
	// version) or the activation's AddNode (a cycle found after the final gate) rejected the
	// revision.
	ReasonRequirementsNotMet = "RequirementsNotMet"
	ReasonWaitingWindow      = "WaitingWindow"
	// ReasonWaitingNotification: the update is not announced yet, or its notification's minimal
	// time has not passed.
	ReasonWaitingNotification = "WaitingNotification"
	// ReasonAttachFailed: the attach step failed (download, verification and mount are one call).
	ReasonAttachFailed             = "AttachFailed"
	ReasonLoadFromFilesystemFailed = "LoadFromFilesystemFailed"
	// ReasonHookInitializationFailed: enabling or synchronizing the hook bindings failed.
	ReasonHookInitializationFailed = "HookInitializationFailed"
	ReasonHookFailed               = "HookFailed"
	ReasonManifestsApplyFailed     = "ManifestsApplyFailed"
	// ReasonScalingForbidden: the chart forbids the replicas a package's resource requests ask
	// for; the release service reports it under the same string.
	ReasonScalingForbidden = "ScalingForbidden"
	// ReasonApplyingManifests: ManifestsApplied is false while nelm applies a changed release.
	ReasonApplyingManifests   = "ApplyingManifests"
	ReasonReleaseDeleteFailed = "ReleaseDeleteFailed"
	// ReasonOrphansPurgeFailed: deleting what a removed application left beside its release failed.
	ReasonOrphansPurgeFailed = "OrphansPurgeFailed"
	// ReasonDisabled: Installed is false because the package is disabled.
	ReasonDisabled = "Disabled"
	// ReasonCRDsApplyFailed and ReasonWebhooksApplyFailed: a Global ensure step failed for a
	// module.
	ReasonCRDsApplyFailed     = "CRDsApplyFailed"
	ReasonWebhooksApplyFailed = "ConversionWebhooksApplyFailed"
)

Reasons of the Current and Candidate sections. Invalid settings have one reason in both: the same check (the revision's ValidateSettings) produces it.

Variables

This section is empty.

Functions

func ReleaseNamespace

func ReleaseNamespace(kind Kind, name, modulesNamespace string) string

ReleaseNamespace is the namespace of a package's release: an application's is the part of its name before the first dot (apps.BuildName; a namespace has no dot), a module's is modulesNamespace. It needs only the name, so a remove without a loaded object finds the release too.

Types

type Announcement

type Announcement struct {
	Name    string // Name is the package name; namespace.name for an application.
	Kind    Kind
	From    string    // From is Current's version.
	Version string    // Version is the version the update activates.
	ApplyAt time.Time // ApplyAt is when the update is expected to activate.
}

Announcement is one update notification the package Reconciler asks the notifier to send.

type BootPackage

type BootPackage struct {
	Name string
	Kind Kind
	// Version is status.currentVersion, written at activation; empty restores nothing. For an
	// embedded package it is the version the image ships, the only one after a Deckhouse upgrade.
	Version string
	// Settings is the settings checkpoint, possibly of the previous version: the effective values
	// of status.lastAppliedConfiguration, whose SchemaVersion the core sets to the restored
	// object's latest at Boot. nil means absent
	// (resources installed before the field existed): Current waits for the first Apply rather
	// than run with schema defaults instead of the user's settings. Empty Values mean the package
	// ran without user settings.
	Settings *Settings
	// Maintenance and ResourceRequests come from spec: they are not validated against a schema, so
	// they cannot prevent a start, and the restored Current runs before the first Apply; without
	// them it would reconcile a release the user put into maintenance.
	Maintenance      nelm.MaintenanceState
	ResourceRequests []resourcesize.Request
	// Intent is the module's enable intent from Module.spec.enabled; nil means none. It must reach
	// the scheduler before Resume: an unknown intent falls to the module floor (Disable).
	Intent *bool
	// Source is the repository in spec, not necessarily the one the version came from (the
	// checkpoint does not record it). The repositories of one package are mirrors; if a new one
	// lacks currentVersion, the package cannot be restored and Deckhouse exits until it has it or
	// is set back. Accepted.
	Source   Source
	Embedded bool
	// Removing: the resource is being deleted. The package is restored only to be uninstalled as
	// at runtime (hooks, release, purge), since a restart interrupted its removal.
	Removing bool
	// Notified is the notification sent for the pending update, so a restart does not send it again
	// and still keeps its MinimalTime.
	Notified Notified
}

BootPackage is the checkpoint of one installed package. Spec settings are not used at boot, so invalid settings in spec cannot prevent the package from starting; they arrive through Apply and are reported as a configuration failure.

type CandidateReport

type CandidateReport struct {
	Version string `json:"version" yaml:"version"` // Version is the desired version being evaluated.
	// Blocked is the reason of the gate that blocks: ReasonSettingsInvalid,
	// ReasonRequirementsNotMet, ReasonWaitingNotification or ReasonWaitingWindow. Nothing is broken; the world must change.
	Blocked string `json:"blocked" yaml:"blocked"`
	// Step is the preparation step that failed (attach, load); the package Reconciler retries it.
	Step string `json:"step" yaml:"step"`
	// Reason is the failed step's own reason (AttachFailed, LoadFromFilesystemFailed); the
	// projection derives the external reason from Step. For Blocked=RequirementsNotMet it is the scheduler's reason
	// (ConstraintError.Reason, e.g. DependencyNotEnabled), which modules show as is.
	Reason  string `json:"reason" yaml:"reason"`
	Message string `json:"message" yaml:"message"`
}

CandidateReport is the Candidate section: the preparation of the candidate, its blockers and failures (the UpdateInstalled condition). Written only by the package Reconciler and cleared when no update is needed or at activation. At most one of Blocked and Step is set.

type Condition

type Condition struct {
	Status ConditionStatus `json:"status" yaml:"status"`
	// Reason is empty unless False. For a failed step it is the reason its error names, else the
	// step's own. Which condition is false is always the step's, so the projection derives the
	// external reason from the condition and reads this one as detail.
	Reason  string `json:"reason" yaml:"reason"`
	Message string `json:"message" yaml:"message"`
}

Condition is one internal condition of the Current section. The zero value is "not reported": the projection keeps the existing external condition. Why: a restart is a reconciliation, not an install; a restored Current reports a condition only once an operation decides it, so Installed (and every other condition) never reads False for a moment after a restart. Build values with TrueCondition and FalseCondition.

func FalseCondition

func FalseCondition(reason, message string) Condition

FalseCondition returns a False condition with its reason and message.

func TrueCondition

func TrueCondition() Condition

TrueCondition returns a True condition.

type ConditionStatus

type ConditionStatus string

ConditionStatus is the status of a Condition; its zero value is ConditionUnknown.

const (
	ConditionUnknown ConditionStatus = "" // ConditionUnknown: not reported since the start.
	ConditionTrue    ConditionStatus = "True"
	ConditionFalse   ConditionStatus = "False"
)

type Configuration

type Configuration struct {
	Settings    Settings              `json:"settings"`
	Maintenance nelm.MaintenanceState `json:"maintenance"` // Maintenance is spec.maintenance.
	// ResourceRequests are Application spec.resourceRequests; nil for modules.
	ResourceRequests []resourcesize.Request `json:"resourceRequests"`
}

Configuration is everything the package Reconciler pushes to Current. Current applies all of it to the object on accept, and every field is part of its inputs.

type CurrentReport

type CurrentReport struct {
	// Version is the revision (Image.Version) of the Current whose operation last wrote
	// HooksProcessed, ManifestsApplied and Installed; "" until one did. The section outlives a
	// Current, so after an activation these conditions are the previous revision's until Version
	// equals Report.CurrentVersion: the projection keeps the update phase until then. Accepts and
	// decisions do not move it, they say nothing about the new revision's operation.
	Version string `json:"version" yaml:"version"`

	Configured       Condition `json:"configured" yaml:"configured"`             // Configured: the latest pushed configuration was accepted.
	HooksProcessed   Condition `json:"hooksProcessed" yaml:"hooksProcessed"`     // HooksProcessed: the hooks of the last operation succeeded.
	ManifestsApplied Condition `json:"manifestsApplied" yaml:"manifestsApplied"` // ManifestsApplied: the release of the last operation was applied.
	Installed        Condition `json:"installed" yaml:"installed"`               // Installed: the release is installed; false only once disabled, never on a failure.

	// AcceptedValues are the effective settings in force, written on every successful accept,
	// before any run. Why beside the checkpoint: other components read the settings of deckhouse
	// and global as soon as they are in force, and a failing first run must not block them.
	AcceptedValues addonutils.Values `json:"acceptedValues" yaml:"acceptedValues"`
	// AcceptedChecksum is the effective values' checksum (with the maintenance mode and, for an
	// application, the resource requests); Global's covers the values alone.
	AcceptedChecksum string `json:"acceptedChecksum" yaml:"acceptedChecksum"`
	// Maintenance is the maintenance mode of the accepted configuration; the composition root
	// publishes the maintenance metric from it.
	Maintenance nelm.MaintenanceState `json:"maintenance" yaml:"maintenance"`

	// Decision is the scheduler's decision about Current's node; nil until one arrived. The
	// projection derives RequirementsMet and status.enabled from it.
	Decision *Decision `json:"decision" yaml:"decision"`

	// The settings checkpoint, written after a successful run, and after the disable and every
	// later accept while disabled. Boot restores AppliedValues at the restored object's latest settings version.
	//
	// AppliedValues are the effective settings of the checkpoint (status.lastAppliedConfiguration).
	AppliedValues addonutils.Values `json:"appliedValues" yaml:"appliedValues"`
	// AppliedChecksum is the checkpoint's effective values' checksum, as AcceptedChecksum.
	AppliedChecksum string `json:"appliedChecksum" yaml:"appliedChecksum"`
}

CurrentReport is the Current section. The projection maps it to the external conditions (ConfigurationApplied = Configured and HooksProcessed and ManifestsApplied). Current writes it only when it changes. A condition no operation has decided since the start is ConditionUnknown (see Condition).

type Decision

type Decision struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	Reason  string `json:"reason" yaml:"reason"` // Reason is empty when enabled.
	Message string `json:"message" yaml:"message"`
}

Decision is the scheduler's decision about one node (Event.Enabled, Reason, Message).

type Desired

type Desired struct {
	Name string // Name is the package name: the node name and the release name.
	// Kind is fixed for the life of a package Reconciler. For KindGlobal Engine routes it to
	// Global, which reads only Configuration.Settings.
	Kind Kind
	// Version is the revision that should become Current: the update decision compares it, and it
	// names the stored image, the node's revision and status.currentVersion.
	Version       string
	Configuration Configuration
	Policy        Policy
	// Requirements are the constraints declared on the package version resource, checked before
	// anything is downloaded.
	Requirements schedule.Constraints
	Source       Source // Source is unused for an embedded package.
	// Embedded takes the image from the deckhouse image directory. It does not switch the update
	// off: a first install of an embedded module passes the ordinary gates.
	Embedded bool
	// Intent is the module's enable intent from Module.spec.enabled; nil means none. Read only for
	// KindModule; it reaches the scheduler before the Desired, so the first node never runs against it.
	Intent *bool
}

Desired is the full desired state of one package, always passed whole, so the latest one is all the package Reconciler needs. The caller must not mutate its maps and slices afterwards: the package Reconciler keeps the value.

type Image

type Image struct {
	Kind Kind   // Kind selects the disk.
	Name string // Name is the package name: the node name and the release name.
	// Version is the revision's identity: what the update decision compares, the node's revision
	// in the scheduler protocol (Node.Revision, Facts.Version, Event.Version; facts of another
	// revision are dropped) and the stored image.
	Version  string
	Source   Source // Source is empty for an embedded image.
	Embedded bool   // Embedded: the deckhouse image directory; nothing is attached or detached.
	// Instance is the attach instance (name@version) that keys the mount and its detach; empty for
	// an embedded image.
	Instance string
	Path     string // Path is the image root; valid until it is detached.
}

Image is an attached package image, immutable. The package Reconciler owns every image of its package and is the only one that detaches it: what a preparation attached is the package Reconciler's once its Done delivered, Restore hands its image over in the checkpoint.

type Kind

type Kind string

Kind is the package kind; it selects the disk, the loader and Current's step lists.

const (
	KindApplication Kind = "Application" // KindApplication is an apps.Application.
	KindModule      Kind = "Module"      // KindModule is a modules.Module.
	// KindGlobal addresses Global (the global module the deckhouse image ships). It has no
	// package Reconciler: Engine routes an Apply of this kind to Global.
	KindGlobal Kind = "Global"
)

type ModuleView

type ModuleView struct {
	Name    string // Name is the package name.
	Version string // Version is the revision's version, for messages.
	// Path is the root the object was loaded from: the attached image, or the weight-prefixed
	// directory of an embedded module.
	Path string
	// Package is the node's object; Global only renders the conversion webhooks from it and never
	// changes it.
	Package Package
}

ModuleView is what Global reads about one module for its run: the CRDs under Path and the conversion webhooks rendered from the package object. The package Reconciler attaches it to the module's scheduler node (schedule.Node.Attachment) and the scheduler hands it to Global with the enabled set (schedule.EnabledModule), computed together: Global always reads the revision its event names, and keeps no copy of any package's state.

type Notification

type Notification struct {
	// MinimalTime is the least time between the notification and the activation.
	MinimalTime time.Duration
	// Patches announces patch updates too (releaseType All); otherwise only minor and major ones.
	Patches bool
	// Notifier sends the announcement; nil announces nothing.
	Notifier Notifier
}

Notification is the update notification policy (applications.update.notification).

type Notified

type Notified struct {
	Version string    `json:"version" yaml:"version"` // Version is the announced version.
	At      time.Time `json:"at" yaml:"at"`           // At is when the notification was sent.
}

Notified is a sent update notification; the zero value means none.

func (Notified) IsZero

func (n Notified) IsZero() bool

IsZero reports whether no notification is recorded.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, a Announcement) error
}

Notifier sends update announcements to one webhook (engine/notify.Notifier satisfies it), carried to the package Reconciler, which declares its own interface over it.

type Package

type Package interface {
	nelm.Package // GetName, GetPath, GetRuntimeValues, GetValues, GetMaintenance

	// GetVersion is the parsed version dependents' rules compare; the revision's identity is
	// Image.Version.
	GetVersion() *semver.Version
	GetConstraints() schedule.Constraints

	// ValidateSettings converts settings from settingsVersion to the revision's schema and
	// validates them, without changing the object. A verdict is a function of the settings alone
	// (conversion, schema, the settings check hook's answer): Result{Valid: false} with its
	// Message; the final gate memoizes it. Anything that depends on cluster state (an unavailable
	// grant) or reached no verdict (a hook that could not run, ctx ended) is an error, which
	// callers retry with backoff. It may read the cluster and run the settings check hook, so it
	// blocks.
	ValidateSettings(ctx context.Context, settingsVersion int, settings addonutils.Values) (settingscheck.Result, error)
	// ApplySettings converts and stores settings in the object's values.
	ApplySettings(settingsVersion int, settings addonutils.Values) error
	// GetSettings returns the effective settings: stored settings merged with the schema defaults.
	GetSettings() addonutils.Values
	SetMaintenance(state nelm.MaintenanceState)
	// GetValuesChecksum is the checksum of the values hooks and templates see.
	GetValuesChecksum() string

	// The hooks: bindings are started in the hook lanes (lifecycle/hooklane); the core runs only
	// the bindings of its own operations.
	InitializeHooks()
	DisableHooks()
	GetHooksQueues() []string
	GetHooksByBinding(binding shtypes.BindingType) []hooks.ControllableHook
	UnlockKubernetesMonitors(hook string, monitors ...string)
	RunHooksByBinding(ctx context.Context, binding shtypes.BindingType) error
	RunHookByName(ctx context.Context, hook string, bctx []bctx.BindingContext) error
}

Package is the loaded package object, the revision itself (apps.Application, modules.Module); the loader returns it as this type, so the compiler checks both. Each load creates a new object, so a Candidate and Current never share one. The object keeps its own values and hook controllers, and may read the cluster internally (grants); the core never does.

It is the carrier type the object travels in (loader → preparation → package Reconciler → Current, and to Global in ModuleView), so its method set is the union of what consumers call; each consumer calls it through its own narrow interface. Remove a method here once no consumer calls it.

type Policy

type Policy struct {
	Mode    UpdateMode
	Windows Windows // Windows nil means any time.
	Force   bool    // Force skips the notification and the window checks.
	// Notification announces an update in the Auto mode before it activates; nil announces nothing.
	Notification *Notification
}

Policy controls when an update may be activated.

type Report

type Report struct {
	// CurrentVersion is the activated version (status.currentVersion), written at activation, the
	// point of no return, and once when a restored package Reconciler starts. A value lagging
	// behind activation would make a restart restore the old version over a partly applied new one.
	CurrentVersion string          `json:"currentVersion" yaml:"currentVersion"`
	Current        CurrentReport   `json:"current" yaml:"current"`     // Current is written only by the Current goroutine.
	Candidate      CandidateReport `json:"candidate" yaml:"candidate"` // Candidate is written only by the package Reconciler.
	Removed        bool            `json:"removed" yaml:"removed"`     // Removed: the package Reconciler's remove has finished.
	// RemoveError is the last failure of the by-name release delete of a remove without a Current;
	// cleared when the delete succeeds. While it is set, Removed stays false.
	RemoveError string `json:"removeError" yaml:"removeError"`
	// Notified is the notification sent for the pending update, written only by the package
	// Reconciler and cleared at activation or when the update is cancelled
	// (status.update.notified).
	Notified Notified `json:"notified" yaml:"notified"`
}

Report is the lifecycle half of a package's status (Engine.Report); the observed half is internal/packages/observed (Engine.Observed), and the projection builds the status from both. Each section has exactly one writer, and the blocking Stop keeps a stopped writer from writing again.

type Restored

type Restored struct {
	// Revision is attached, loaded and its node added; the package Reconciler owns its image.
	Revision Revision
	// Configuration is nil when the settings checkpoint is absent: Current then waits for Apply.
	Configuration *Configuration
	// Removing starts the package Reconciler removing, before any run (BootPackage.Removing).
	Removing bool
	Notified Notified // Notified is BootPackage.Notified.
}

Restored is a restored package as the package Reconciler starts it.

type Revision

type Revision struct {
	Image   Image
	Package Package
}

Revision is an attached image with the object loaded from it. A Candidate is a Revision the package Reconciler prepared; Current runs one. Its owner owns the image; ownership is never shared.

type Settings

type Settings struct {
	Values addonutils.Values `json:"values"`
	// SchemaVersion is the settings-schema version Values are validated and applied at; the object
	// converts them from it to its own schema. Desired settings carry spec.version; a restored
	// checkpoint, already effective values, carries the restored object's latest version, so it is
	// never converted a second time (set by the core at Boot).
	SchemaVersion int `json:"schemaVersion"`
}

Settings are a package's settings as the user wrote them. They carry no generation: Current detects a change by the checksum of the effective settings the object reports after applying them.

type Source

type Source struct {
	Repository registry.Remote
	Package    string // Package is the package name in the repository.
}

Source is where a package image comes from in the registry.

type UpdateMode

type UpdateMode string

UpdateMode selects whether an update waits for an update window.

const (
	UpdateModeAuto   UpdateMode = "Auto"   // UpdateModeAuto updates within the windows.
	UpdateModeManual UpdateMode = "Manual" // UpdateModeManual updates as soon as the version is desired.
)

type Windows

type Windows interface {
	IsAllowed(t time.Time) bool
	NextAllowedTime(t time.Time) time.Time
}

Windows is the update calendar (go_lib/hooks/update.Windows satisfies it), carried to the window gate, which declares its own interface over it.

Jump to

Keyboard shortcuts

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