gate

package
v1.78.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 6 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 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. It reads one Input and calls only read-only checks, so it has no effects; the package Reconciler acts on the Decision.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstraintMessage

func ConstraintMessage(err error) string

ConstraintMessage returns the message of a CheckConstraints or AddNode error without the reason prefix ConstraintError.Error() adds: the decision carries its own reason.

func ConstraintReason

func ConstraintReason(err error) string

ConstraintReason returns the reason of a CheckConstraints or AddNode error; empty when err is no *schedule.ConstraintError.

Types

type Decision

type Decision struct {
	Kind   Kind
	Reason string
	// Cause is the scheduler's own reason of a requirements blocker (ConstraintError.Reason, e.g.
	// DependencyNotEnabled); empty for every other decision.
	Cause   string
	Message string
	Step    string    // Step is the failed preparation step (Prepare).
	WakeAt  time.Time // WakeAt is when the notification or window gate wants to decide again (Blocked).
	// Notify: the update must be announced before it goes on; ApplyAt is when it is expected to
	// activate, for the announcement (Blocked, ReasonWaitingNotification).
	Notify  bool
	ApplyAt time.Time
}

Decision is Decide's answer.

func Decide

func Decide(ctx context.Context, in Input, deps Deps) Decision

Decide runs the gates in their contract order, current → requirements → prepared → final (settings of an update, constraints, dependents) → notification → window, and returns the first that stops; Activate when none does. Every wake decides from the start. The gates before prepared check requirements only, before anything is downloaded: settings can be checked only once the revision is loaded. The notification and the window come last, so only an update ready to activate is announced, and the revision is downloaded, loaded and checked ahead and the activation happens at the window start; meanwhile the package Reconciler keeps the prepared candidate, and every wake (a settings change among them) runs the final gate again.

type Deps

type Deps struct {
	Scheduler scheduler
	Settings  settings
}

Deps are the read-only checks Decide calls.

type Input

type Input struct {
	Name    string
	Desired model.Desired
	// Settings are those the package Reconciler pushes to Current: the final gate checks exactly
	// what the activation pushes.
	Settings model.Settings
	// Current is Current's image; nil for a first install.
	Current *model.Image
	// Prepared is the latest result of the preparation of the desired revision; nil when there is
	// none.
	Prepared *Prepared
	// Notified is the notification sent for the pending update; zero when none was.
	Notified model.Notified
	Now      time.Time
}

Input is everything the decision reads, taken once per wake.

type Kind

type Kind int

Kind says who must act on a decision.

const (
	UpToDate Kind = iota // UpToDate: the desired revision is Current; no Candidate is needed.
	// Prepare: the revision is not prepared yet; the package Reconciler retries a failed
	// preparation.
	Prepare
	// Blocked: nothing is broken and the world must change (settings, requirements, the clock).
	// Re-evaluated on every wake, never retried with backoff: retrying cannot change the answer.
	Blocked
	Activate // Activate: every gate passed; the prepared revision may become Current.
)

type Prepared

type Prepared struct {
	// Ready: the revision is attached and loaded; Object is the loaded object, idle until the
	// activation, so the final gate's read-only checks may use it.
	Ready  bool
	Object model.Package
	// Step is the preparation step that failed last (the package Reconciler retries it); empty when
	// none did. Reason is the step's own; Message says why.
	Step    string
	Reason  string
	Message string
}

Prepared is the preparation of the desired revision as the decision reads it.

Jump to

Keyboard shortcuts

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