8000 🧠 Name a cause or the facts for every failure by abahmed · Pull Request #531 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 87 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ enforces, are in `docs/contributor-architecture.md`.
| `internal/rootcause` | Shared root-cause types: the `Cause` record, confidence levels, graph and scheduler-message helpers |
| `internal/rootcause/explain` | The root-cause engine: propagation table (data), candidate walk, scorers and weights, set-cover solver, incremental cache; a pure function of an inventory snapshot |
| `internal/incident` | Incident manager: root resolution, settling, material-change digest, resolve hold, flapping, recurrence, routine, tiers, severity overrides, restore |
| `internal/notification/compose` | Writes an incident decision as a `notification.Message`: one narrative note built from per-fact sentence writers, steps, runbooks, startup summary |
| `internal/notification/compose` | Writes an incident decision as a `notification.Message`: one narrative note built from per-fact sentence writers, steps, runbooks, startup summary, roll-up and digest |
| `internal/notification` | Provider-neutral message type, severity levels, and rendering helpers such as chunking and mention neutralizing (leaf) |
| `internal/scope` | Delivery scope over findings: namespaces, reasons, silences, and maintenance holds |
| `internal/pipeline` | Engine loop: observation queue, model update, detectors, incident manager, scope, investigation, downtime reconciliation, audit entries; the only producer of incident decisions |
Expand Down Expand Up @@ -483,12 +483,96 @@ Some quirks are load-bearing. Preserve them unless a change explicitly says othe
- Decisions for out-of-scope incidents are dropped before delivery, but the
incident is still tracked so reasoning keeps its evidence.
- The audit log records every in-scope decision when it is made. A decision
the digest or the startup summary carries reaches the sink with
the digest, a roll-up or the startup summary carries reaches the sink with
`Message.Carrier` set; delivery drops it, the replay keeps it apart from
delivered messages, and the audit entry says `delivery: digest`.
- Two or more announcements in one tick go as one roll-up
(`internal/pipeline/rollup.go`). A roll-up is a `Listing` like the startup
summary: the first own message of a listed incident is written as an
announcement, and the roll-up resolves once every listed incident has.
Open roll-ups are persisted in the startup marker.
- An announced incident that loses every member is rerooted (same ID, "cause
revised") only when all members that left since its last decision went to
one root (`Incident.movedTo`); members that dispersed leave it empty, and it
recovers and resolves like any incident whose failures cleared.
- `explain` reports when each cause began (`Cause.Began`, from
`view.startOf`; a zone or pool starts with its first broken node). The
incident layer refuses a cause that began more than
`explain.TemporalExclusion` (10m) after an announced incident was opened
(`Manager.beganTooLate`): the finding stays in its incident.
- `explain` records, per failure, the upstream entities that were reached
and showed nothing wrong (`Trace.Checked`); the incident keeps their kinds
(`Incident.Checked`) and `compose.checkedSentences` says what was found
healthy when no cause is found. The phrase "couldn't find an outside
cause" must not come back.
- A healthy, unchanged node, image, ConfigMap, Secret or ServiceAccount
reached from a failure gets the pseudo mode `ModeSharedFactor`
(`shared_factor.go`). The `shared-node` row needs `SharedFactorMinWorkloads`
workloads whose failures began within `SharedFactorWindow`, and a
shared-factor-only candidate is capped at `SharedFactorMaxConfidence`
and viable only when at least `SharedFactorMinShare` of its dependents
fail. Only a node is suspected (an unchanged shared image, config, secret
or account is weak evidence), and `setCover` never lets a shared factor
claim a failure a candidate with its own evidence explains.
- `detection.Finding.Advisory` marks a configuration risk (`Risk.*` reasons,
`detectors.Risk`). Advisory findings are not failures to explain nor
causes (`explain.unhealthy`), never open an incident (`Manager.attach`),
join the incident of a real failure of the same root
(`adoptAdvisories`) and leave with it (`dropAdvisories`), never lead a
message (`compose.rootFinding`) and add a consequence only through
`compose.riskSentences`.
- Pods relate to the external endpoints their environment names
(`kube.podDependencies`, relation `Calls`, kind
`kube.KindExternalEndpoint`). Host and port only: credentials never
leave the value. The active prober dials them when
`autoDependencies` is on, and the `external-endpoint-unreachable` row
blames a probed-down endpoint for its callers.
- A failing pod reaches the failing kube-system DaemonSet pods on its node
(`agentHops`, `LinkNodeAgent`); the `node-agent-failing` row needs two
workloads. `detectors.ImageDrift` reads `AttrImageID`; the `image-drift`
row is an Inside row. `daemonSetGaps` adds evidence to a DaemonSet's
availability finding. The prober lists Leases every `leaseScanEvery`
rounds into `kube.KindLease` entities and `detectors.Lease` flags a stale
one only while its holder pod runs. `announcer.deliver` holds a
`ReasonMaterialChange` update for a fresh investigation when the last one
is older than `reinvestigateAfter`. HTTPS probes record `AttrCertExpiry`
on their endpoint, which `detectors.Certificate` reads.
`incident.TriggerOf` classifies a cause for `Occurrence.Trigger`, which
`compose.recurrenceSentences` summarises.
- A scheduler verdict naming a volume node affinity conflict gives the
pod's claim the pseudo mode `ModeVolumePinned` (`view.pinnedClaim`) and
the `claim-pins-pod` row blames it; `schedulingHops` then adds no
scheduling candidate. `detectors.removalTaint` turns scale-down and
out-of-service taints into `NodeDraining`. `Incident.Considered` keeps the
area's alternatives for the audit entry's `considered`. The prober reads
`/metrics` of the API server and of the cluster DNS pods
(`probe_metrics.go`, `AttrPodIP`) into rate attributes that
`detectors.errorRates` turns into `APIServerErrors` and
`CoreDNSServfail`.
- The announcer reads the engine's active advisory findings
(`Engine.activeAdvisories`) and names each once in a digest that goes
out anyway (`pendingRisks`, `mentionRisks`); risks never open a window.
`StatsPoller.kubeletHealth` adds `AttrPLEGRelistMS` and
`AttrEvictionRate` for `detectors.kubeletFindings`. `unusedService` and
`unusedClaim` are digest-tier hygiene after `DefaultUnusedAfter`.
`applyBudget` ranks kinds in `Model.NotedKinds` (recent Warning events)
before silent ones (`DynamicConfig.Noted`).
- Known problems and rhythms: `incident.Known` (two heard occurrences, the
first a day old) and `incident.Rhythm` (three occurrences in a day at even
gaps) send non-page incidents to the digest in `tier`. An announced open
incident is reminded every `RemindEvery` (`Incident.Reminded`,
`ReasonReminder`). Resolve messages name the cause (`resolvedCause`).
`replacementGraceFor` adds five minutes for young pods on fresh nodes
(`kube.AttrCreated`) to `notReady` and workload availability.
- Repeated unknown Warning events become `UnusualEvent.<Reason>` findings
(`detectors.unusualEvents`, digest tier); `shownByState` lists the
event reasons object state already covers.
- A zone or node pool is `MembersFailing` only when two or more of its nodes
have a finding with `Health == Failing`; degraded nodes (CPU stall, high
usage) do not count, so a strained pool never absorbs workload incidents.
- The audit decision reason strings (`settled`, `material change`,
`flapping`, `healthy for ...`, `stable for ...`, `startup summary`,
`digest`) are stable strings people grep for.
`roll-up`, `digest`) are stable strings people grep for.

## Extension contract

Expand Down
131 changes: 127 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,133 @@
reported for about two minutes") instead of whichever pod was worst.
- **Skipped resource types are named.** The startup log line about kinds
left out by the watch budget now lists them.
- **Audit log records every decision.** Decisions the digest or the startup
summary carry are written to the audit log when they are made, with
`delivery: digest` or `delivery: startup summary`; announcements that go
only to paging tools carry `delivery: paging`.
- **Problems found together are one message.** Two or more announcements
made in the same pass go as one roll-up that names them, like the startup
summary; each problem gets its own message when it changes or resolves,
page-tier ones still reach the paging tools on their own, and the roll-up
closes once all it listed have resolved.
- **A strained node pool is not a failing one.** A zone or node pool fails as
a whole only when two or more of its nodes have a failing finding (not
ready, under pressure, network unavailable). Nodes with a CPU stall or high
usage no longer make the pool take over the workload incidents on them and
hand them back minutes later.
- **A late cause does not take over an announced incident.** A cause that
began more than ten minutes after an incident was opened did not cause
what people were already told about: the incident keeps its root and the
new cause explains only the new failures. A zone or pool counts as having
begun when its first node broke. A node pool that fails this morning no
longer takes over a deployment that has been unavailable for a week.
- **Every crash loop gets a reason or the facts.** "I couldn't find an
outside cause" is gone. The engine records which objects upstream of a
failure it checked and found healthy and unchanged, and the message says
so: "Its node, image and configuration are healthy and unchanged, so
nothing outside it explains this." The quoted crash output follows.
- **A node that failing workloads share is suspected.** When three or more
workloads on one node start failing within ten minutes, most pods on that
node fail, and nothing upstream shows a fault, the node is named as a
possible cause, never above "possibly", and any cause with evidence of its
own outranks it. An unchanged shared image, ConfigMap, Secret or
ServiceAccount is no longer suspected: that is weak evidence, and bad
builds are covered by rollout, image digest drift and the shared failure
signature.
- **Dependencies outside the cluster are modelled and probed.** Environment
values that name a URL or a `host:port` (only host and port are kept; user
names, passwords and paths never leave the value) become
`external-endpoint` entities the pods call. With
`activeProbeMonitor.autoDependencies: true` kwatch dials them from its own
Pod, and a dependency that refuses connections is named as the cause of
the pods that call it, even for a single workload.
- **Configuration risks, in the digest and as the cost of a failure.** A new
detector reports a workload with no readiness probe, no memory limit, an
image tag that can change (`latest` or none), a single replica, every
replica on one node, or a privileged container. These are advisory: they
never open an incident on their own, they wait for the digest, and when a
failure of that workload shows what the risk cost, the message says so
("It runs a single replica, so this is downtime, not degradation.").
- **An overcommitted node explains kills on it.** A node whose pods' memory
limits add up to more than 150% of its memory is reported (digest tier)
and becomes a cause for OOM kills and evictions of pods that stayed within
their own limit.
- **Unknown Warning events are not silent.** A Warning event kwatch has no
detector for, repeated three times in a quarter hour on one object, becomes
an informational finding that quotes the event text, so a new failure
type is seen before a detector exists for it.
- **Changes say why they were made.** The `kubernetes.io/change-cause`
annotation of a blamed change is quoted: `recorded as "bump payments to
2.3 for the refund fix"`.
- **A failing node agent explains the pods beside it.** A kube-system
DaemonSet pod (the CNI, kube-proxy, a CSI node plugin) that fails on a
node is named as the cause when two or more workloads on that node lose
their readiness or network at the same time.
- **The same tag, different builds.** A workload whose running pods report
different image IDs for the same image reference is reported
(`ImageDigestDrift`), and the drift explains why some replicas fail and
others do not.
- **DaemonSet gaps name their nodes.** A DaemonSet below its desired count
lists the nodes whose pod is not ready and the taints on them.
- **Controllers that run but do not work.** kwatch reads every leader Lease
outside node heartbeats every two minutes; a Lease its running holder has
not renewed for three durations is reported (`LeaseStale`). A Lease whose
holder is gone is left alone, since an uninstalled controller leaves one.
- **Updates carry current evidence.** A material change whose evidence is
older than two minutes is investigated again before the update is sent,
so the quoted output is what the application says now.
- **HTTPS probes watch the certificate.** A probed HTTPS target records the
expiry of the certificate it served, and the certificate check covers it.
- **Recurrences name their shape.** When every time people heard about
followed the same kind of cause, the message says so: "This is the third
time this week, each time after a rollout."
- **A claim can pin a pod.** When the scheduler rejects a pod for a volume
node affinity conflict, the claim bound to a volume in a zone with no
node for the pod is the cause (`claim-pins-pod`), not the scheduler.
- **Removal taints are drains.** A node tainted for scale-down or marked
out of service is treated like a cordoned node: its disruption is the
maintenance itself, and only what fails because of it is reported.
- **The audit log says what was ruled out.** Each entry carries
`considered`: the other causes the solver weighed, best first, as
`root (row, confidence)`.
- **API server and cluster DNS metrics.** The prober reads the API server's
own `/metrics` and the cluster DNS pods' metrics port, both part of
Kubernetes itself, and reports an API server answering 5% or more of
requests with server errors (`APIServerErrors`) or a cluster DNS failing
10% or more of lookups with SERVFAIL (`CoreDNSServfail`). A cluster
without those endpoints loses only these findings.
- **Configuration risks reach the digest.** A risk the detector finds is
named once in the next low-priority digest ("Risk: orders runs a single
replica"); it never costs a message of its own.
- **Kubelet evidence.** The kubelet's pod lifecycle relist time and its
evictions are read from its own metrics: a kubelet that takes over a
second to list its pods is reported (`NodePLEGSlow`), and evictions in
progress go to the digest (`NodeEvicting`).
- **Idle objects in the digest.** A Service that has selected no pod for a
day (`ServiceUnused`) and a bound claim no pod has mounted for a day
(`ClaimUnused`) wait for the digest.
- **The watch budget favours noisy kinds.** Over the resource-type budget,
kinds whose objects had Warning events in the last hour are watched
before kinds nothing has complained about, instead of alphabetical order.
- **Known problems go to the digest after a day.** A problem people have
heard about twice, the first time a day ago or more, no longer interrupts
on its next recurrence; the digest keeps counting it. A page stays a page.
- **Regular rhythms are recognised and stated.** An incident that recurs at
even intervals within a day is treated as known, and says so: "It fails
every 40 minutes or so; this is the third time in a day."
- **A weekly "still open" reminder.** An announced incident that stays open
gets one update a week: "payments in shop is still down, for two weeks now."
- **The resolve message names the cause.** "... it was failing for 42 minutes
because node n3 was low on memory." A workload blamed on itself names none.
- **Replacement grace for pods on fresh nodes.** A pod younger than ten
minutes on a node younger than ten minutes gets five extra minutes before
`ContainersNotReady` or workload unavailability is reported, so a scale-up
or consolidation is not announced as an outage.
- **A dissolved group ends instead of changing subject.** When the members of
an announced incident disperse to several roots, the incident recovers and
resolves on its own and the workloads are announced anew (as one roll-up).
Its conversation no longer continues under whichever member left last.
Members that all leave for one root still move the conversation there.
- **Audit log records every decision.** Decisions the digest, a roll-up or
the startup summary carry are written to the audit log when they are made,
with `delivery: digest`, `roll-up` or `startup summary`; announcements that
go only to paging tools carry `delivery: paging`.
- **Low-priority digest.** Digest-tier incidents (an autoscaler at its
maximum, a budget that selects nothing, a throttled container, learned
routines) are no longer announced one by one. One 🟡 digest every 30
Expand Down
4 changes: 2 additions & 2 deletions deploy/chart/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rules:
- apiGroups: [""]
resources: ["nodes/stats", "nodes/metrics", "pods/log"]
verbs: ["get"]
- nonResourceURLs: ["/readyz"]
- nonResourceURLs: ["/readyz", "/metrics"]
verbs: ["get"]
- apiGroups: ["authorization.k8s.io"]
resources: ["selfsubjectaccessreviews"]
Expand Down Expand Up @@ -57,7 +57,7 @@ rules:
- apiGroups: [""]
resources: ["nodes/stats", "nodes/metrics", "pods/log"]
verbs: ["get"]
- nonResourceURLs: ["/readyz"]
- nonResourceURLs: ["/readyz", "/metrics"]
verbs: ["get"]
- apiGroups: ["apps"]
resources: ["deployments", "replicasets", "statefulsets", "daemonsets", "controllerrevisions"]
Expand Down
1 change: 1 addition & 0 deletions deploy/config-catalog.meta.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ activeProbeMonitor.timeoutSeconds|Monitors|Timeout for each active probe.|active
activeProbeMonitor.failureThreshold|Monitors|Consecutive probe failures before alerting.|active|
activeProbeMonitor.autoServices|Monitors|Probe discoverable Service ports automatically; opt in to avoid unexpected traffic.|active|
activeProbeMonitor.excludeNamespaces|Monitors|Namespaces automatic Service probing skips, for default-deny ingress that does not admit kwatch.|active|
activeProbeMonitor.autoDependencies|Monitors|Probe the endpoints outside the cluster that pod environments name, over TCP; a refused dependency explains its callers.|active|
activeProbeMonitor.http|Monitors|JSON array of HTTP probe targets with optional paths, headers, and latency limits.|active|
activeProbeMonitor.tcp|Monitors|JSON array of TCP probe targets.|active|
activeProbeMonitor.dns|Monitors|JSON array of DNS probe targets.|active|
Expand Down
1 change: 1 addition & 0 deletions deploy/config-catalog.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ ignoreNodeMessages|list|legacy|Compatibility|Legacy node-message suppression fie
heartbeatMonitor.url|string|empty|Security|External dead-man heartbeat URL; stored only through a mounted Secret.|secret|
kubelet.insecureSkipVerify|boolean|false|Security|Skip kubelet serving certificate verification for direct node stats reads; only for self-signed kubelet certificates.|active|
watch.secrets|boolean|true|Scope|Watch Secrets (values hashed, never stored); false removes Secret RBAC and Secret-based checks report that they cannot verify.|active|
activeProbeMonitor.autoDependencies|boolean|false|Monitors|Probe the endpoints outside the cluster that pod environments name, over TCP; a refused dependency explains its callers.|active|
2 changes: 1 addition & 1 deletion deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rules:
- apiGroups: [""]
resources: ["nodes/stats", "nodes/metrics", "pods/log"]
verbs: ["get"]
- nonResourceURLs: ["/readyz"]
- nonResourceURLs: ["/readyz", "/metrics"]
verbs: ["get"]
- apiGroups: ["authorization.k8s.io"]
resources: ["selfsubjectaccessreviews"]
Expand Down
Loading
Loading
0