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
- Variables
- func DocTable() string
- func Handler(component, version string, src Source, now func() time.Time) http.Handler
- func Run(ctx context.Context, d Deps, cfg RunConfig, out io.Writer, term string, ...) int
- type CRD
- type Check
- type ClusterConfig
- type Component
- type ComponentRef
- type Deps
- type Duration
- type Outcome
- type Report
- type Result
- type RunConfig
- type Seam
- type SecretRef
- type Source
- type Versioner
- type Where
Constants ¶
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.
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 ¶
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_sandbox", "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"}, {ID: "routines-ui-write", Seams: []Seam{SeamCluster}, RunsIn: []Where{InFactory}, Fail: []string{"ui_write_check_failed"}, Warn: []string{"ui_write_gitops_managed"}, What: "routines.uiWrite off for GitOps repositories", From: "UP17"}, }
Catalog is IN2's table.
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.
var SeamOrder = []Seam{SeamCluster, SeamSandbox, SeamSecrets, SeamNetwork, SeamPostgres, SeamIdentity, SeamGitHub, SeamModels, SeamRunLore, SeamExposure, SeamObservability}
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
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.
Types ¶
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.
type ComponentRef ¶
ComponentRef is a component whose /preflight the runner collects: its name and its ops URL.
type Deps ¶
Deps are the runner's clients: the API server through client and its version endpoint, and HTTP to the components' ops ports.
type Duration ¶
Duration is a JSON duration string ("30s").
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON reads "30s".
type Report ¶
type Report struct {
// contains filtered or unexported fields
}
Report is a run's results.
func (*Report) Add ¶
Add stores r, held to the catalog. A message holding a credential is refused, and the refusal does not echo it.
func (*Report) Exit ¶
Exit is the runner's status: 1 on any fail, and with strict on any warn too; else 0.
func (*Report) Results ¶
Results are the stored results, sorted by seam (SeamOrder), then by check id, then by component.
func (*Report) Summary ¶
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 ¶
WriteJSONLines writes one JSON object per result, in order.
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 ¶
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 ¶
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
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.