app

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package app is the App kind's server side (ADR-0199, F113): the app-parts admission, which admits each declared part as a direct write of it would be admitted, and the App reconciler, which writes the parts, reports one status and prunes what a new spec drops. The reconciler also stamps an AppRevision per changed spec and records its rollout, its deadline and the history (ADR-0200, F114), records each write-back of a hand edit and writes nothing while spec.paused is set (ADR-0212, F115). It writes the ConfigMaps the App defines under their hashed names and writes no part while a declared Secret or key is missing; app-parts refuses a part that names an undeclared Secret (ADR-0213, F116). It calls the App's hook Functions before its parts change and after a new revision is current, records each call on the AppRevision and resumes a failed one on Retry (ADR-0214, F117). It holds a revision until every App it requires is Ready at a matching version, and app-requires refuses the upgrade, rollback, delete or cycle that would break a started dependent (ADR-0219, F122). The owner GC removes the tree on App delete (internal/gc).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdmission

NewAdmission returns app-parts. parts builds the admissions a direct write passes over the reader it is given; app-parts gives it the view holding the App's other parts. It implements admission.NamespaceReading, true when a part admission it runs is.

func NewRequiresAdmission added in v0.11.0

func NewRequiresAdmission(r admission.StoreReader) admission.Admission

NewRequiresAdmission returns app-requires, the Validating admission of App Create, Update and Delete that refuses an upgrade or a rollback out of a started dependent's range, the delete of a required App, and a requirement cycle, each refusal naming the dependents sorted by name. A missing required App is never refused: it waits.

Types

type Deps

type Deps struct {
	Store  store.Store
	Purger gc.BucketPurger
	Logger *slog.Logger
	// Clock reads every time of the rollout record (ADR-0200); nil ⇒ clock.System().
	Clock clock.Clock
	// UpgradeTimeout is app.upgradeTimeout, the time from a stamp to its switch; 0 ⇒ 5m.
	UpgradeTimeout time.Duration
	// RevisionHistory is app.revisionHistory, the AppRevisions kept besides the current one; 0 ⇒ 10.
	RevisionHistory int
	// SupervisionPeriod is runtime.supervisionPeriod, the retry of a stopped pass or a blocked prune (ADR-0199
	// Decision 6, as the Workflow materializer); 0 ⇒ controller.SupervisionPeriod.
	SupervisionPeriod time.Duration
	// Hold is the platform hold (ADR-0206 Decision 6); nil ⇒ never held. A held pass writes nothing and no hook call
	// starts or is recorded (ADR-0214 Decision 8); the deadline reads its ReleasedAt (ADR-0212 Decision 6).
	Hold hold
	// NamespaceHold is the per-namespace hold (ADR-0222 Decision 8): an App of a held namespace is held as on a held
	// platform, and the deadline reads ReleasedAtIn of its namespace for ReleasedAt; nil ⇒ none held.
	NamespaceHold namespaceHold
	// Invoker calls the hook Functions (ADR-0214 Decision 5); nil ⇒ every call fails Unavailable "no invoker".
	Invoker Invoker
	// InvokeTimeout is invoke.defaultTimeout, a hook call's deadline when its Function sets no spec.timeout; 0 ⇒
	// v1.DefaultInvokeTimeout.
	InvokeTimeout time.Duration
	// Enqueue requeues an App once its hook call ended (ADR-0214 Decision 6); nil ⇒ none.
	Enqueue func(controller.Request)
}

Deps are the reconciler's dependencies; Store and Purger are required.

type Invoker added in v0.11.0

type Invoker interface {
	Invoke(ctx context.Context, ns v1.NamespaceName, fn v1.ObjectName, ev eventing.CloudEvent) error
}

Invoker calls a Function with a CloudEvent, waking a cold one (ADR-0033); *sensor.HTTPInvoker satisfies it.

type Planner added in v0.11.0

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

Planner answers what a write of an App would make its rollout do (ADR-0220 Decision 5), by the reconciler's own rules through the helpers the pass calls. It only reads the store; the control plane calls it as its AppPlanner.

func NewPlanner added in v0.11.0

func NewPlanner(st store.Store) *Planner

NewPlanner builds the Planner over st.

func (*Planner) PlanApp added in v0.11.0

func (p *Planner) PlanApp(ctx context.Context, a *v1.App) (v1.AppPlan, error)

PlanApp plans a, the admitted object of a dry-run write, whose UID is the stored App's or empty for a create. The revision is the one the stamp would name. A namesake held by another owner stops it: the plan lists only that AppRevision. Otherwise the parts are the first stop of the pass alone, ChildNotOwned then a declared Secret missing or lacking a key, or else every part a write would create or update, in section order, then every object the App controls that no entry names, as prune. The hooks are listed when a revision is named. A hold, a pause and an unmet requirement delay the rollout and are not shown (ADR-0220 open question 1).

type Reconciler

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

Reconciler drives an App to its declared parts (controller.Reconciler). It keeps no state between passes: the rollout deadline is read from the AppRevision's status.startedAt.

func NewReconciler

func NewReconciler(d Deps) (*Reconciler, error)

NewReconciler builds the App reconciler.

func (*Reconciler) MapPart

func (r *Reconciler) MapPart(ctx context.Context, obj v1.Object) []controller.Request

MapPart is the controller.MapFunc of every section kind: it requeues each App whose controller reference or marker obj carries, and each App of obj's namespace with a ref entry naming obj (Decision 4).

func (*Reconciler) MapRequires added in v0.11.0

func (r *Reconciler) MapRequires(ctx context.Context, obj v1.Object) []controller.Request

MapRequires is the controller.MapFunc of App (ADR-0219 Decision 6): for a changed or deleted App it requeues each App of its namespace whose spec.requires names it, each App its own spec.requires names, and each App whose status.requiredBy names it, so a removed or renamed requirement reaches the formerly required App.

func (*Reconciler) MapSecret added in v0.11.0

func (r *Reconciler) MapSecret(ctx context.Context, obj v1.Object) []controller.Request

MapSecret is the controller.MapFunc of Secret (ADR-0213 Decision 8): it requeues each App of the Secret's namespace that declares its name, so a Secret created, changed or deleted is checked at once. It reads the Secret's metadata only.

func (*Reconciler) MapStepFunction added in v0.11.0

func (r *Reconciler) MapStepFunction(ctx context.Context, obj v1.Object) []controller.Request

MapStepFunction is the controller.MapFunc of Functions for Workflow health (ADR-0215 Decision 8): it requeues each App of fn's namespace with a Workflow part one of whose steps dispatches to fn.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req controller.Request) (controller.Result, error)

Reconcile stamps an AppRevision when the spec changed, checks that the App owns every part that exists, writes the parts that are absent or differ, recording each self-heal, reads each part's readiness, calls the latest revision's due hook, derives the rollout record, prunes the dropped objects it controls once the latest revision is current and its post-hooks are done, writes the App's status, then each changed AppRevision status, and trims the history. While the latest revision's pre-hooks are not done, it writes only what they need (ADR-0214 Decision 4). A revision waits, writing no part, until every App it requires is met (ADR-0219). A held pass writes nothing (ADR-0206 Decision 6); a paused App gets only its Paused condition (ADR-0212).

func (*Reconciler) Retry added in v0.11.0

func (r *Reconciler) Retry(ctx context.Context, ns v1.NamespaceName, name v1.ObjectName) error

Retry starts again, without waiting, the first pre-hook not done of the App's latest revision when it is Failed with HookFailed, or the first failed post-hook of its current revision when that is the latest (Decision 7). It reserves the App before it reads the revisions, as a pass notes busy. Conflict when no such hook exists, a call of the App runs or the App is paused; Unavailable while funcd is held; NotFound without the App.

Directories

Path Synopsis
Package template renders an App template on the client (ADR-0217): a directory of App spec fragments plus a values schema becomes one typed, checked App.
Package template renders an App template on the client (ADR-0217): a directory of App spec fragments plus a values schema becomes one typed, checked App.

Jump to

Keyboard shortcuts

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