project

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package project reduces raw Kubernetes objects to the allowlisted fields argus emits.

Raw objects are grotesque: a single Pod carries managedFields, a full duplicate of its own spec under last-applied-configuration, resourceVersion, uid, and generated token mounts. Emitting them fills the model's context with noise, and a model reasoning from noise guesses.

Every projection here is an explicit allowlist. Never a blocklist — a blocklist silently regresses the moment Kubernetes adds a field.

Index

Constants

View Source
const DefaultLogTokens = 1800

DefaultLogTokens is the ceiling on emitted log content.

Budgeting by tokens rather than lines is the point: "last 100 lines" is meaningless when one line is a 4KB JSON blob and the next is "ok". A model's context is spent in tokens, so that is the unit the limit has to be expressed in.

Variables

This section is empty.

Functions

func ContainerSpec

func ContainerSpec(c *corev1.Container) model.ContainerSpecView

ContainerSpec projects the desired shape of a container. Shared by Pod and by ReplicaSet template projection, which is what makes the rollout diff an apples-to-apples comparison.

func Events

func Events(evs []corev1.Event, now time.Time) []model.EventGroup

Events deduplicates raw events into groups keyed by (type, reason, normalized message, kind).

The object name is deliberately NOT part of the key. Forty pods of one Deployment reporting the same BackOff is one fact about the Deployment, not forty facts — keying on the object would produce forty near-identical groups and defeat the entire purpose. Each group instead reports how many distinct objects it covers, plus one of them as an example to drill into.

Counts respect the event's own series/count field rather than being recomputed: the apiserver already aggregates repeats server-side, so counting occurrences here would undercount by orders of magnitude on exactly the events that matter most.

func Logs added in v0.1.2

func Logs(raw string, now time.Time, tokenBudget int) ([]model.LogGroup, int)

Logs turns raw container output into redacted, grouped, budgeted lines.

Order of operations matters and is deliberate:

  1. redact first, so a credential can never survive into a group key or a count;
  2. group second, so repetition collapses before the budget is spent on it;
  3. budget last, keeping the NEWEST groups — a crash is at the end of the log, never the start.

func Node

func Node(n *corev1.Node, now time.Time) model.NodeView

Node projects the conditions that explain workload failures the workload did not cause.

func Normalize

func Normalize(msg string) string

Normalize strips the varying parts of an event message so equivalent events group together.

func PDB

PDB projects a PodDisruptionBudget, which explains rollouts that are stuck rather than broken.

func Pod

func Pod(p *corev1.Pod, usage map[string]corev1.ResourceList, now time.Time) model.PodView

Pod projects a pod and folds in its metrics, so a detector sees spec, status and usage together. usage is keyed by container name and may be nil when the metrics API is unavailable.

func RedactLine added in v0.1.2

func RedactLine(s string) string

RedactLine removes credential-shaped substrings from one line of log output.

func ReplicaSet

func ReplicaSet(rs *appsv1.ReplicaSet, currentHash string, now time.Time) model.ReplicaSetView

ReplicaSet projects an RS plus its template, which is the input to the rollout diff.

func Service

func Service(s *corev1.Service, ready, notReady, matched int) model.ServiceView

Service projects a Service together with the readiness of what it selects.

ready/notReady come from EndpointSlices; matched is how many pods the selector hits at all. Keeping both is what lets the endpoint detector distinguish a label mismatch (matched == 0) from a readiness failure (matched > 0, ready == 0) — two very different incidents that look identical in `kubectl get svc`.

func SortPods

func SortPods(pods []model.PodView)

SortPods orders pods worst-first so that a truncated list still shows what matters.

func Workload

func Workload(d *appsv1.Deployment, now time.Time) *model.WorkloadView

Workload projects a Deployment. StatefulSets and DaemonSets go through their own shims because their status fields have different names for the same concepts.

Types

This section is empty.

Jump to

Keyboard shortcuts

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