8000 🧠 Group symptoms under their shared cause and quiet the channel by abahmed · Pull Request #529 · 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
11 changes: 7 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,22 @@ Some quirks are load-bearing. Preserve them unless a change explicitly says othe
no members before the restore grace ends is not recovered, so a restart
never resolves incidents whose detectors have not re-run.
- An update is announced only when the digest changes (tier, root, cause, the
root's own reasons, bucketed impact size, state). Counters and timestamps
must never enter the digest.
root's own reasons seen so far, bucketed impact size, state). A root reason
that clears while the incident stays open is not news, so the set only
grows. Counters and timestamps must never enter the digest.
- Pods and containers are excluded from the impact size that drives the digest:
replicas failing one by one are not news.
- An announced incident's tier only rises (`ratchetTier`); de-escalation is
told by the recovery. While settling, the tier follows the members.
- The first list of every source only observes; changes made while kwatch was
down are reconstructed from saved fingerprints after every source has
synced and are dated at the last snapshot, so they precede the failures
they may have caused.
- Decisions for out-of-scope incidents are dropped before delivery, but the
incident is still tracked so reasoning keeps its evidence.
- The audit decision reason strings (`settled`, `material change`,
`flapping`, `healthy for ...`, `stable for ...`, `startup summary`) are
stable strings people grep for.
`flapping`, `healthy for ...`, `stable for ...`, `startup summary`,
`digest`) are stable strings people grep for.

## Extension contract

Expand Down
43 changes: 43 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@
`-max-peak-per-hour` to 30. The new histogram
`kwatch_pipeline_decision_lag_seconds` measures the time from an
observation being submitted to its decisions being applied.
- **Chart: state volume placement.** When the StorageClass's CSI driver is
registered on only some nodes, `helm install` and `helm upgrade` now add a
node affinity on the driver's topology label so the state claim can bind
where the Pod lands (`persistence.pi 10000 nToStorageDriverNodes`, default
`true`; `persistence.storageDriverTopologyKey` sets the label for offline
renders). Before, the Pod could stay `Pending` with the claim reporting
`no topology key found for node`.
- **Chart.** `tolerations` are now merged with `defaultTolerations`; an entry
with the same key and effect wins (an entry without an effect covers every
effect of its key), so a `not-ready` `NoSchedule` toleration keeps the
Expand Down Expand Up @@ -331,6 +338,42 @@
full within hours; a lost PVC with a resize error stays Critical; a
restored recovering incident no longer sends an empty update; crash log
excerpts keep the end of the log, where the crash message is.
- **Webhooks share their backend as root.** Several admission webhooks
that call one Service with no ready endpoints, or one Service that does
not exist, are now one incident rooted at that Service instead of one
incident per webhook configuration. A single webhook keeps its own root.
- **Tier never drops while open.** An announced incident keeps the loudest
tier it reached; a crash loop whose critical member clears for a moment
no longer flips between page and notify with a message per flip.
- **Zones and node pools lead their incidents.** An incident caused by a
zone or node pool failing as a whole now opens with the place and its
nodes ("Node pool dev-arm-np is failing as a whole: two nodes have not
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.
- **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
minutes lists what opened and what resolved; an incident that gets worse
is announced at once. Paging tools and issue trackers never receive it.
- **"The second time this week" counts heard times.** A blip that recovered
before it was announced still counts for flapping and routines, but is
no longer called an earlier time in the next message.
- **One message when incidents merge.** When another incident takes over
an incident's failures (a node pool explaining a dozen crashing
Deployments), the absorbed incident's close now goes only to paging tools
and issue trackers, which hold an alert under its key; chat channels read
about those failures in the merged incident's update instead of one
"cause revised" message per workload.
- **Bursts settle longer.** Three or more incidents settling at the same
time take the 75-second settle even at page tier, so a shared cause can
surface and be announced once instead of each incident paging and then
being revised seconds later.
- **Startup summary holds pages too.** At a cold start, pre-existing
page-tier problems are listed in the startup summary instead of being
announced one by one to chat channels; paging tools and issue trackers,
which never receive summaries, still get each of those announcements on
its own.
- **Fewer wrong roots.** A zone or node pool is no longer blamed for a
crash on a healthy node; stack-trace locations such as `Pool.java:512`
are no longer read as external endpoints; one pod's lookup of a
Expand Down
13 changes: 11 additions & 2 deletions deploy/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ kubectl get pods -n kwatch
kubectl logs -n kwatch deployment/kwatch
```

The pod should show `READY 1/1` and `STATUS Running`.
The pod should show `READY 1/1` and `STATUS Running`. A Pod that stays
`Pending` while `kubectl get pvc -n kwatch` shows the claim `Pending` is
waiting for storage: `kubectl describe pvc -n kwatch kwatch-data` names the
cause. `no topology key found for node` means the StorageClass's CSI driver
runs on only some nodes. `helm install` and `helm upgrade` detect this and
pin the Pod to those nodes (`persistence.pinToStorageDriverNodes`); an offline
render needs `persistence.storageDriverTopologyKey`, or use
`persistence.emptyDir` (see the production guide, "Volume requirements").

## ⬆️ Upgrade

Expand Down Expand Up @@ -122,6 +129,8 @@ kubectl delete namespace kwatch
| `persistence.size` | Size of the state volume (PVC). The state file is capped at 512 MiB of logical data (evidence 128 MiB), is rewritten at startup when it grows more than a quarter past that, and no backups are kept; the file and the temporary rewrite copy share the volume | `2Gi` |
| `persistence.existingClaim` | Reuse an existing PVC for the state file | `""` |
| `persistence.emptyDir` | Keep state in an `emptyDir` instead of a PVC. All state is lost when the Pod is rescheduled, so use it only for evaluation; installing with it prints a warning | `false` |
| `persistence.pinToStorageDriverNodes` | When the StorageClass's CSI driver is registered on only some nodes, require the driver's topology label so the state claim can bind where the Pod lands. Looked up at install/upgrade; `helm template` and Argo CD renders cannot look it up | `true` |
| `persistence.storageDriverTopologyKey` | The driver's topology label to require explicitly (for offline renders), for example `topology.ebs.csi.aws.com/zone` | `""` |
| `persistence.emptyDirSizeLimit` | `sizeLimit` of the `emptyDir`; also passed to kwatch as `KWATCH_VOLUME_LIMIT` so the startup rewrite checks the real limit | `2Gi` |
| `watch.secrets` | Watch Secrets; `false` removes all Secret RBAC (in both `rbac.mode` values) and Secret-based checks report that they cannot verify | `true` |
| `resources` | CPU and memory requests/limits; kwatch sets `GOMEMLIMIT` to 90% of the memory limit | `100m` CPU, `512Mi` memory limit |
Expand All @@ -134,7 +143,7 @@ kubectl delete namespace kwatch
| `podLabels` | Additional Pod labels | `{}` |
| `nodeSelector` | Choose nodes by label | `{}` |
| `tolerations` | Allow configured taints | `[]` |
| `affinity` | Control Pod placement | `{}` |
| `affinity` | Control Pod placement; also the way to keep kwatch on nodes where the StorageClass's CSI driver is registered when the state claim stays `Pending` | `{}` |
| `config.upgrader.disableUpdateCheck` | Disable the update check (GitHub API at startup, then daily); with `configSecretName`, set `upgrader.disableUpdateCheck` in the Secret's `config.yaml` | `false` |
| `config.kubelet.insecureSkipVerify` | Skip kubelet serving-certificate verification for node stats; only for kubelets with self-signed certificates | `false` |
| `defaultTolerations` | Not-ready/unreachable `NoExecute` tolerations (30s) merged after `tolerations`, so kwatch leaves a failed node quickly | 30s not-ready and unreachable |
Expand Down
86 changes: 86 additions & 0 deletions deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,89 @@ with the same name in different namespaces must not share one role.
{{- $fullname := include "kwatch.fullname" . -}}
{{- printf "%s-%s" $fullname .Release.Namespace | trunc 253 | trimSuffix "-" -}}
{{- end }}

{{/*
Topology label of the StorageClass's CSI driver, when that driver is
registered on only some nodes and the class binds WaitForFirstConsumer. Such
a claim is provisioned for the node the scheduler picks; on a node without
the driver it never binds, and the Pod stays Pending. Nodes carry the
driver's own topology label only once the driver is registered there, so
requiring that label keeps kwatch where its volume can exist. Labels every
node has (kubernetes.io/*, topology.kubernetes.io/*) are skipped. The driver
is learned from the cluster: a CSI class names it as the provisioner; an
in-tree class is served by whatever driver provisioned a volume of that
class before, else by Kubernetes' in-tree-to-CSI translation. Empty when
the driver is everywhere, nowhere or unknown, when the class binds
Immediately, when the volume is not a claim, or when the render cannot look
the cluster up.
*/}}
{{- define "kwatch.storageTopologyKey" -}}
{{- if .Values.persistence.emptyDir -}}
{{- else if .Values.persistence.storageDriverTopologyKey -}}
{{- .Values.persistence.storageDriverTopologyKey -}}
{{- else if and .Values.persistence.pinToStorageDriverNodes (not .Values.persistence.existingClaim) -}}
{{- $class := "" -}}
{{- $provisioner := "" -}}
{{- $binding := "" -}}
{{- with (lookup "storage.k8s.io/v1" "StorageClass" "" "") -}}
{{- range .items -}}
{{- $ann := .metadata.annotations | default dict -}}
{{- $chosen := false -}}
{{- if $.Values.persistence.storageClass -}}
{{- $chosen = eq .metadata.name $.Values.persistence.storageClass -}}
{{- else -}}
{{- $chosen = or (eq (index $ann "storageclass.kubernetes.io/is-default-class" | default "") "true") (eq (index $ann "storageclass.beta.kubernetes.io/is-default-class" | default "") "true") -}}
{{- end -}}
{{- if $chosen -}}
{{- $class = .metadata.name -}}
{{- $provisioner = .provisioner -}}
{{- $binding = .volumeBindingMode | default "Immediate" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $registered := dict -}}
{{- $total := 0 -}}
{{- with (lookup "storage.k8s.io/v1" "CSINode" "" "") -}}
{{- range .items -}}
{{- $total = add1 $total -}}
{{- with .spec.drivers -}}
{{- range . -}}
{{- $_ := set $registered .name (append (index $registered .name | default list) .) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $driver := "" -}}
{{- if hasKey $registered $provisioner -}}
{{- $driver = $provisioner -}}
{{- else if $provisioner -}}
{{- with (lookup "v1" "PersistentVolume" "" "") -}}
{{- range .items -}}
{{- if and (not $driver) (eq (.spec.storageClassName | default "") $class) .spec.csi -}}
{{- $driver = .spec.csi.driver -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if not $driver -}}
{{- $translation := dict "kubernetes.io/aws-ebs" "ebs.csi.aws.com" "kubernetes.io/gce-pd" "pd.csi.storage.gke.io" "kubernetes.io/azure-disk" "disk.csi.azure.com" "kubernetes.io/azure-file" "file.csi.azure.com" "kubernetes.io/cinder" "cinder.csi.openstack.org" "kubernetes.io/vsphere-volume" "csi.vsphere.vmware.com" "kubernetes.io/portworx-volume" "pxd.portworx.com" "kubernetes.io/rbd" "rbd.csi.ceph.com" -}}
{{- $driver = index $translation $provisioner | default "" -}}
{{- end -}}
{{- end -}}
{{- $key := "" -}}
{{- if and $driver (eq $binding "WaitForFirstConsumer") (hasKey $registered $driver) -}}
{{- $entries := index $registered $driver -}}
{{- if lt (len $entries) $total -}}
{{- range $entries -}}
{{- with .topologyKeys -}}
{{- range . -}}
{{- if and (not $key) (not (hasPrefix "kubernetes.io/" .)) (not (hasPrefix "topology.kubernetes.io/" .)) (not (hasPrefix "node.kubernetes.io/" .)) -}}
{{- $key = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $key -}}
{{- end -}}
{{- end -}}
10 changes: 10 additions & 0 deletions deploy/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ spec:
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- else }}
{{- with (include "kwatch.storageTopologyKey" . | trim) }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: {{ . }}
operator: Exists
{{- end }}
{{- end }}
{{- with (include "kwatch.tolerations" . | trim) }}
tolerations:
Expand Down
8 changes: 8 additions & 0 deletions deploy/chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
"emptyDirSizeLimit": {
"type": "string",
"default": "2Gi"
},
"pinToStorageDriverNodes": {
"type": "boolean",
"default": true
},
"storageDriverTopologyKey": {
"type": "string",
"default": ""
}
},
"additionalProperties": false
Expand Down
10 changes: 10 additions & 0 deletions deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ persistence:
emptyDir: false
# -- sizeLimit applied to the emptyDir volume (emptyDir mode only).
emptyDirSizeLimit: 2Gi
# -- Keep kwatch on the nodes where the StorageClass's CSI driver is
# registered when the driver runs on only some nodes; otherwise a
# WaitForFirstConsumer claim placed on another node never binds. Looked
# up at install and upgrade time; offline renders (helm template, Argo
# CD) cannot look it up and render nothing.
pinToStorageDriverNodes: true
# -- The storage driver's topology label to require explicitly, for
# offline renders (kubectl get csinodes shows each driver's topologyKeys).
# A node carries it only once the driver is registered there.
storageDriverTopologyKey: ""

nodeSelector: {}

Expand Down
6 changes: 5 additions & 1 deletion deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ spec:
claimName: kwatch-data
---
# State store: incidents, change history and baselines. Uses the
# cluster's default StorageClass.
# cluster's default StorageClass. If the claim stays Pending with
# "no topology key found for node", the class's CSI driver runs on only
# some nodes: add a node affinity on the driver's topology label (for
# example topology.ebs.csi.aws.com/zone, operator Exists) to the Pod
# template above, or switch the data volume to emptyDir.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
3 changes: 2 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ the `bad-rollout` scenario in `internal/scenarios`.
cover picks the Deployment as the one cause. The node is not blamed.
6. **The incident manager decides.** `incident.Manager.Apply` attaches the
findings to an incident rooted at the Deployment. Its tier is page. The
incident settles for 15 seconds (75 for lower tiers) so late failures join
incident settles for 15 seconds (75 for lower tiers, and for a burst of
three or more incidents settling at once) so late failures join
it, then `Tick` returns an announce decision.
7. **Investigation joins in.** When the incident opened, a worker read a short
log excerpt, redacted. If it arrives within a short wait it is attached;
Expand Down
12 changes: 9 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ with one status emoji and no links, for example `🟡 kwatch v1.2.0 started.` an
`🟡 kwatch v1.3.0 is available; this cluster runs v1.2.0.`. A restart after an
internal failure, or after a gap in monitoring, uses 🟠 and says which period
went unwatched. When there are problems that were already there at startup,
one startup summary lists them. Summaries and plain notices are information,
one startup summary lists them, page-tier problems included; the paging
tools and issue trackers below receive each page-tier announcement on its
own instead, since they never receive summaries. Summaries and plain
notices are information,
not incidents: PagerDuty, Opsgenie, Squadcast, GoAlert, Zenduty, incident.io,
iLert and SIGNL4 (paging) and GitHub, GitLab, Gitea, Jira and ClickUp (issue
trackers) do not receive them, because nothing would ever close the alert or
Expand Down Expand Up @@ -513,12 +516,15 @@ Severity decides how loudly it is delivered. The values `severityByReason` and
| `critical` | Pages | 🔴 |
| `high` | Notifies | 🟠 |
| `medium` / `warning` | Notifies | 🟠 |
| `normal` | Goes to the digest | 🟡 |
| `normal` | Goes to the digest: one 🟡 message every 30 minutes lists the low-priority problems that opened or resolved | 🟡 |

Without an override, kwatch derives the tier itself: an incident with a critical finding
pages only when it also matches a page rule (for example a lost node, an unavailable
API server or cluster DNS, or an Ingress that lost its backends); otherwise it notifies.
An incident made only of informational or digest-only findings goes to the digest.
An incident made only of informational or digest-only findings goes to the
digest: it is not announced on its own, one digest message every 30 minutes
lists what opened and what resolved, and it is announced at once if it gets
worse. Paging tools and issue trackers never receive digests.

Every message starts with exactly one status emoji and no other: 🔴 page,
🟠 notify, 🟡 low, ✅ resolved. Red is reserved for incidents that page.
Expand Down
29 changes: 29 additions & 0 deletions docs/production-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,35 @@ same file at all. With a shared file system two Pods on two nodes can open the
file at once, and bbolt file locks are not reliable over network file
systems, so the state file can be corrupted.

**The claim stays `Pending`.** With a `WaitForFirstConsumer` StorageClass
the claim is provisioned for the node the scheduler picked for the Pod. When
the class's CSI driver is registered on only some nodes (for example the
driver's DaemonSet does not run on an architecture or node group), a Pod
placed on a node without it never gets a volume, and the claim's events say
`no topology key found for node <name>`. Either keep kwatch on nodes the
driver serves, with a node affinity on the driver's own topology label (the
label exists only where the driver is registered; any CSI driver has one),
or use an `emptyDir`. With the chart:

```yaml
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: <the driver's topology key> # e.g. topology.ebs.csi.aws.com/zone
operator: Exists
```

`kubectl get csinodes -o yaml` lists each node's drivers and their topology
keys. Both installers handle this case before it fails: `helm install` and
`helm upgrade` look the driver up and add that affinity when
`persistence.pinToStorageDriverNodes` is true (the default; offline renders
such as `helm template` or Argo CD cannot look it up and take
`persistence.storageDriverTopologyKey` instead), and `kwatch.sh` checks the
driver's node coverage before applying and pins the Pod the same way. The
raw `deploy/deploy.yaml` cannot ask the cluster; add the affinity by hand.

Initial operating targets are: readiness within 120 seconds after a healthy
startup and graceful shutdown within 45 seconds. These are SLO targets for
capacity planning and alerting, not guarantees. Queue limits and configured
Expand Down
Loading
Loading
0