setup

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package setup builds the cache and engine configuration the UI runs on, for callers that run the engine themselves, such as a one-shot CLI (D-053). pkg/app builds its own configuration here, so the two cannot drift.

Nothing here waits. The time-based checks (restart hold, grace periods, scope-verifier persistence) read as pending in a single pass. A fresh metrics result reads OK, and Next marks when it goes stale. Controller metrics reach the engine only through Config.Collected; the ctrlmetrics package documents the one-shot sequence (CollectOnce, then Publish). engine.Model.Next and each health.Report.Next say when computing again can change the result. Waiting, and for how long, is the caller's.

Before a single pass, wait with cache.Cache.Settled, not by receiving on Changes. Settled covers the required informers only. Then wait until each optional watch in Snapshot().Access (cache.ProxyPodsGVR, cache.CRDsGVR, cache.EventsGVR, cache.ServicesGVR, cache.EndpointSlicesGVR, when present) and each list-only served kind (kinds.Descriptor.ListOnly) is OK or has an Err. Otherwise a pass can read them as not yet read, and the output varies between runs.

To stop, cancel the context passed to cache.Cache.Start, then call cache.Cache.Wait, which returns once every goroutine Start launched has exited.

Controller logs and proxy stats come from long-running collectors that pkg/app runs and this package does not. A caller without them gets those inputs as not read, never as healthy (D-006): controllerLogs reads as not read, and the checks over proxy stats or controller metrics report them not collected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricsMaxAge

func MetricsMaxAge(interval time.Duration) time.Duration

MetricsMaxAge is the age beyond which a metrics result is stale: three collection intervals, so a stalled collector cannot keep an old result green.

Types

type Clients

type Clients struct {
	Dynamic   dynamic.Interface
	Kube      kubernetes.Interface
	Discovery kinds.DiscoveryClient
	// Metadata reads CRD metadata; nil means no CRD watch.
	Metadata metadata.Interface
}

Clients are the Kubernetes clients the cache and kind discovery read.

type Config

type Config struct {
	Cache  cache.Config
	Engine engine.Config
	// Collected is the store Engine.Collected reads. pkg/app's collectors
	// publish to it; a one-shot caller publishes controller metrics with ctrlmetrics.Publish.
	Collected *collect.Store
	// Kinds re-resolves the served kinds and the Catalog; Build has refreshed it
	// once. A long-running caller runs it; a one-shot caller can ignore it.
	Kinds *kinds.Monitor
	// Changes is the one coalescing recompute signal the cache, the kinds
	// monitor and the engine share (D-019). A one-shot caller waits with
	// Cache.Settled and the optional and list-only Access entries, not on Changes.
	Changes *trigger.Signal
}

Config is what Build returns. The caller creates the cache from Cache and sets Engine.Snapshots to it.

func Build

func Build(c Clients, o Options, reg *extension.Registry) (Config, error)

Build validates o and reg, resolves the served kinds and lists the Catalog once, and returns the cache and engine configuration pkg/app runs on. Engine.Snapshots is the caller's to set.

type Options

type Options struct {
	// Pinned restricts the model to one install: its ID, or namespace/name (D-016).
	Pinned string
	// MetricsInterval is the controller metrics collection interval; it must be
	// positive. Metrics staleness and scope-verifier persistence derive from it.
	MetricsInterval time.Duration
	// DelegationEdgeCap caps the selected delegation edges per install; zero
	// means computed.DefaultBounds.Edges. It must not be negative.
	DelegationEdgeCap int
	// NoEvents and NoCRDs turn off the Warning Event and CRD metadata watches.
	NoEvents, NoCRDs bool
	// NoEndpoints turns off the Service and EndpointSlice watches; the zero value keeps them on.
	NoEndpoints bool
	// ClassOnlyInstalls adds an install per GatewayClass controllerName no
	// detector claims (engine.Config.ClassOnly).
	ClassOnlyInstalls bool
	// Clock drives the engine and stamps snapshots; nil means the real clock.
	Clock clock.WithTicker
}

Options are the settings both configs derive from.

Jump to

Keyboard shortcuts

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