preflight

package
v0.53.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 24 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 preflight answers, seam by seam, whether an install can work (v4 D24). It holds the check catalog (IN2), the report (IN5) and the /preflight shape each component serves. Each check runs where its traffic runs: the cluster checks in the preflight pod, the component checks inside the component that makes the call, the outside checks in the CLI.

A check that cannot decide fails with the code undecided, never passes. No result names a value: a message names a Secret and key, a host, an HTTP status or a SQLSTATE.

Index

Constants

View Source
const (
	// Undecided: the check could not decide (a timeout, a 5xx, an RBAC denial on its own read).
	Undecided = "undecided"
	// ComponentTooOld: the component serves no /preflight; its image predates it.
	ComponentTooOld = "component_too_old"
)

The two codes every check may fail with.

View Source
const (
	CheckTimeout = 10 * time.Second
	AllTimeout   = 30 * time.Second
	CacheFor     = 30 * time.Second
)

The component side's bounds (IN3): one check runs at most CheckTimeout, all of them at most AllTimeout, and an answer is served from cache for CacheFor.

Variables

View Source
var Catalog = []Check{
	{ID: "kubernetes", Seams: []Seam{SeamCluster}, RunsIn: []Where{InPod}, Fail: []string{"kubernetes_too_old"},
		What: "the server version is 1.30 or later", From: "D26"},
	{ID: "crds", Seams: []Seam{SeamCluster}, RunsIn: []Where{InPod}, Fail: []string{"crd_missing", "crd_version"},
		What: "the six maku CRDs at the chart's served versions, and each CRD the values need (agentgateway's, Gateway API's, prometheus-operator's, ESO's)",
		From: "D13, A11"},
	{ID: "runtimeclass", Seams: []Seam{SeamSandbox}, RunsIn: []Where{InPod}, Fail: []string{"runtimeclass_missing"},
		Warn: []string{"unsafe_allow_runc"}, What: "the RuntimeClass sandbox.runtimeClassName names exists", From: "D18"},
	{ID: "secrets", Seams: []Seam{SeamSecrets}, RunsIn: []Where{InPod}, Fail: []string{"secret_missing", "secret_key_missing"},
		What: "each Secret of the registry the values enable exists, with its documented keys", From: "D14"},
	{ID: "run-path", Seams: []Seam{SeamNetwork, SeamSandbox}, RunsIn: []Where{InRunController},
		Fail: []string{"run_path_runtimeclass", "run_path_git_secrets", "run_path_network", "run_path_gateway"},
		Warn: []string{"network_policy_none"}, What: "the run-controller's preflight: RuntimeClass, git Secrets, the CNI probe, the gateway",
		From: "D6, D18"},
	{ID: "database", Seams: []Seam{SeamPostgres}, RunsIn: []Where{InBroker},
		Fail: []string{"db_unreachable", "db_too_old", "db_role_bypasses_rls", "db_wrong_role", "db_schema_behind", "db_schema_ahead",
			"db_ledger_unreadable"},
		What: "the three DSNs: reachable, Postgres 16 or later, roles without BYPASSRLS, the schema current",
		From: "D9"},
	{ID: "oidc", Seams: []Seam{SeamIdentity}, RunsIn: []Where{InBroker, InFactory},
		Fail: []string{"oidc_discovery", "oidc_issuer_mismatch", "oidc_jwks"},
		What: "discovery answers, its issuer matches, the JWKS fetches", From: "D8"},
	{ID: "github-link", Seams: []Seam{SeamIdentity}, RunsIn: []Where{InBroker}, Fail: []string{"link_client", "link_callback_mismatch"},
		What: "the GitHub link's OAuth client authorizes, and its callback is the web host's", From: "D8"},
	{ID: "apps", Seams: []Seam{SeamGitHub}, RunsIn: []Where{InFactory}, Fail: []string{"app_not_installed", "app_permission_missing"},
		What: "each served repository has both App installations, with their grants", From: "D10, D12"},
	{ID: "merge-gate", Seams: []Seam{SeamGitHub}, RunsIn: []Where{InFactory}, Fail: []string{"merge_gate_not_required"},
		Warn: []string{"merge_gate_rules_unread"}, What: "the default branch's ruleset requires maku/merge-gate from the posting App", From: "D11"},
	{ID: "private-code", Seams: []Seam{SeamGitHub}, RunsIn: []Where{InFactory}, Fail: []string{"private_code_unacknowledged"},
		What: "each private repository has privateCode.acknowledged: without it, it is refused new tasks", From: "D3"},
	{ID: "models", Seams: []Seam{SeamModels}, RunsIn: []Where{InBroker, InRunController}, Fail: []string{"model_unreachable", "model_refused"},
		What: "the planner, the classifier and one run alias per listener answer a one-token completion", From: "D7"},
	{ID: "knowledge", Seams: []Seam{SeamRunLore}, RunsIn: []Where{InBroker}, Fail: []string{"knowledge_unreachable", "knowledge_tools_missing"},
		What: "tools/list lists kb_search and kb_get within the timeout", From: "D20"},
	{ID: "exposure", Seams: []Seam{SeamExposure}, RunsIn: []Where{InFactory, InCLI},
		Fail: []string{"broker_exposed_around_proxy", "host_unresolved", "route_unanswered", "slack_route_too_wide"},
		What: "no route reaches the broker around the proxy; each host resolves and answers", From: "D19"},
	{ID: "tracing", Seams: []Seam{SeamObservability}, RunsIn: []Where{InRunController}, Fail: []string{"collector_unreachable"},
		What: "the collector's OTLP port accepts a run's connection", From: "D21"},
}

Catalog is IN2's table.

View Source
var ErrCredential = errors.New("preflight: the message carries a credential")

ErrCredential is a result whose message carries what looks like a credential: it is never stored.

SeamOrder is the summary's order.

Functions

func DocTable added in v0.48.0

func DocTable() string

DocTable is the catalog as docs/install.md's check table: one row per check, in the catalog's order, with the seam, where it runs, what it checks, and the codes it fails or warns with.

func Handler added in v0.48.0

func Handler(component, version string, src Source, now func() time.Time) http.Handler

Handler serves GET /preflight on a component's ops port: its checks, run on demand under AllTimeout and cached CacheFor, so a scrape storm costs nothing. It is unauthenticated, like /metrics on the same port, so it carries nothing a metric would not: a result whose message holds a credential is replaced by a fail undecided naming the check alone.

func Run

func Run(ctx context.Context, d Deps, cfg RunConfig, out io.Writer, term string, strict bool) int

Run runs the cluster checks, collects every component's /preflight, writes the JSON lines to out and the summary to term (the pod's termination message), and returns the exit status.

Types

type CRD

type CRD struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

CRD is one CRD the install needs, at a version it must serve.

type Check

type Check struct {
	ID     string
	Seams  []Seam
	RunsIn []Where
	Fail   []string
	Warn   []string
	What   string // what it checks, for docs/install.md
	From   string // the spec decisions it proves
}

Check is one row of the catalog: its id, its seams (the first orders it), where it runs, and the closed set of codes a failure or a warning may carry.

type ClusterConfig

type ClusterConfig struct {
	MinKubernetes   string      `json:"minKubernetes"`
	CRDs            []CRD       `json:"crds"`
	RuntimeClass    string      `json:"runtimeClass"`
	UnsafeAllowRunc bool        `json:"unsafeAllowRunc"`
	Secrets         []SecretRef `json:"secrets"`
}

ClusterConfig is what the preflight pod checks against the API server: the chart renders it.

type Component

type Component struct {
	Component string   `json:"component"`
	Version   string   `json:"version"`
	Checks    []Result `json:"checks"`
}

Component is what a component serves at GET /preflight on its ops port: its name, its version and its checks' results, computed on demand.

func DecodeComponent

func DecodeComponent(r io.Reader) (Component, error)

DecodeComponent reads a /preflight answer strictly, bounded, and stamps each result with the component that served it.

type ComponentRef

type ComponentRef struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

ComponentRef is a component whose /preflight the runner collects: its name and its ops URL.

type Deps

type Deps struct {
	Client  client.Reader
	Version Versioner
	HTTP    *http.Client
}

Deps are the runner's clients: the API server through client and its version endpoint, and HTTP to the components' ops ports.

type Duration

type Duration struct{ time.Duration }

Duration is a JSON duration string ("30s").

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON reads "30s".

type Outcome

type Outcome string

Outcome is a check's verdict.

const (
	Pass Outcome = "pass"
	Warn Outcome = "warn"
	Fail Outcome = "fail"
	Skip Outcome = "skip"
)

The outcomes.

type Report

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

Report is a run's results.

func (*Report) Add

func (r *Report) Add(res Result) error

Add stores r, held to the catalog. A message holding a credential is refused, and the refusal does not echo it.

func (*Report) Exit

func (r *Report) Exit(strict bool) int

Exit is the runner's status: 1 on any fail, and with strict on any warn too; else 0.

func (*Report) Results

func (r *Report) Results() []Result

Results are the stored results, sorted by seam (SeamOrder), then by check id, then by component.

func (*Report) Summary

func (r *Report) Summary() string

Summary is the one line the pod writes to its termination message: the counts, then each failing or warning check with its code, cut to fit 4096 bytes.

func (*Report) WriteJSONLines

func (r *Report) WriteJSONLines(w io.Writer) error

WriteJSONLines writes one JSON object per result, in order.

func (*Report) WriteText

func (r *Report) WriteText(w io.Writer) error

WriteText writes the human table, grouped by seam.

type Result

type Result struct {
	Check     string  `json:"check"`
	Component string  `json:"component"`
	Outcome   Outcome `json:"outcome"`
	Code      string  `json:"code"`
	Message   string  `json:"message"`
	Seconds   float64 `json:"seconds"`
}

Result is one check's verdict in one place: IN5's JSON line.

func Bounded added in v0.48.0

func Bounded(ctx context.Context, timeout time.Duration, check string, run func(ctx context.Context) Result) Result

Bounded runs one check within timeout: a check that does not return in time is a fail undecided (it keeps running in the background until its own context ends). The result's Check is check's, and Seconds its duration.

func ClusterChecks

func ClusterChecks(ctx context.Context, c client.Reader, v Versioner, cfg ClusterConfig) []Result

ClusterChecks runs IN2's four cluster checks (kubernetes, crds, runtimeclass, secrets) through the preflight pod's own API access. A read it cannot make, an RBAC denial included, is undecided.

type RunConfig

type RunConfig struct {
	Cluster    ClusterConfig  `json:"cluster"`
	Components []ComponentRef `json:"components"`
	Timeout    Duration       `json:"timeout"`
}

RunConfig is the preflight pod's config, rendered by the chart (preflight-config.yaml).

func LoadRunConfig

func LoadRunConfig(path string) (RunConfig, error)

LoadRunConfig reads the config strictly: a key the binary does not know fails the run.

type Seam

type Seam string

Seam is a row of the spec's seam table: the summary groups checks in this order.

const (
	SeamCluster       Seam = "cluster"
	SeamSandbox       Seam = "sandbox"
	SeamSecrets       Seam = "secrets"
	SeamNetwork       Seam = "network"
	SeamPostgres      Seam = "postgres"
	SeamIdentity      Seam = "identity"
	SeamGitHub        Seam = "github"
	SeamModels        Seam = "models"
	SeamRunLore       Seam = "runlore"
	SeamExposure      Seam = "exposure"
	SeamObservability Seam = "observability"
)

The seams, in docs/install.md's order.

type SecretRef

type SecretRef struct {
	Seam      string   `json:"seam"`
	Namespace string   `json:"namespace"`
	Name      string   `json:"name"`
	Keys      []string `json:"keys"`
}

SecretRef is one Secret of step 5's registry the values enable, with the keys it must hold.

type Source added in v0.48.0

type Source func(ctx context.Context) []Result

Source runs a component's checks once. Each result names a catalog check; the handler holds them to the catalog and refuses a message that carries a credential.

type Versioner

type Versioner interface {
	ServerVersion() (*version.Info, error)
}

Versioner is the API server's version endpoint (discovery).

type Where

type Where string

Where is where a check runs: the preflight pod, a component, or the CLI.

const (
	InPod           Where = "pod"
	InRunController Where = "run-controller"
	InBroker        Where = "broker"
	InFactory       Where = "factory"
	InCLI           Where = "cli"
)

The places.

Jump to

Keyboard shortcuts

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