Skip to content

Clear Resolved Incidents at the cap

The analyzer keeps at most 500 Incidents (--max-incidents) and counts every one, Resolved ones included. At the cap a new fingerprint is refused. The analyzer has no delete on Incidents, so an admin of the operator namespace removes the ones that are safe to delete. Background: design 3.2, ADR-0007.

built The analyzer moves an Incident to Resolved, and writes status.resolvedTime in the same update, when nothing happened to it for an hour and no request naming it is active, or when its request Succeeded (design 3.2); the condition Lifecycle says which. A request in Merged counts as ended until verification is built (#92). An Incident resolved by quiet time before any analysis goes back to Open if its symptom returns within 24 hours; any other Resolved Incident is escalated then. Keep the 24 hour safety window described below. Automatic retention with an archive is planned (#458); until then the steps are manual.

Know that the cap is near

The gauge shadewright_incidents reports Incidents by phase built. At 80% of the cap (400 of 500) the gauge shadewright_incident_cap_near turns 1 and the analyzer's Pod gets a Warning event IncidentCapNear built; alert on max(shadewright_incident_cap_near) == 1 (metrics reference). At the cap, shadewright_incident_observations_refused_total rises and the analyzer's Pod gets a Warning event IncidentCapReached.

Steps

  1. Pick. List Resolved Incidents:
kubectl -n shadewright-system get incidents -o json \
  | jq -r '.items[] | select(.status.phase=="Resolved") | .metadata.name'
  1. Keep the last 24 hours. Skip Incidents resolved less than 24 hours ago: their recurrence must still be escalated, not analyzed as a new occurrence. The analyzer writes status.resolvedTime in the same status update that sets Resolved. This filter lists only Incidents resolved at least 24 hours ago; missing or unreadable times are skipped:
kubectl -n shadewright-system get incidents -o json \
  | jq -r 'now as $now | .items[]
    | select(.status.phase=="Resolved")
    | (try (.status.resolvedTime | fromdateiso8601) catch null) as $resolved
    | select($resolved != null)
    | select($resolved <= ($now - 86400))
    | .metadata.name'

An Incident set Resolved by hand, or by an analyzer older than the closure rules, may have no resolvedTime: wait 24 hours while it remains Resolved before deleting it. Do not use lastSeen as the resolution time.

  1. Skip the ones an active request names. Keep every Incident named by a request that has not reached a final phase (Succeeded, Denied, Failed, Expired, Cancelled, Superseded, NeedsIntervention):
kubectl -n shadewright-system get remediationrequests -o json \
  | jq -r '.items[] | [.spec.incidentRef.name, .status.phase] | @tsv'

This step protects the fix too. A request whose Incident is deleted before its pull request opens ends Cancelled with reason IncidentGone, with no pull request (#794): deleting the Incident stops that fix.

  1. Export. Keep the evidence with your incident records. An Incident holds the redacted symptom, counters and times, not logs:
kubectl -n shadewright-system get incident <name> -o yaml > <name>.yaml
  1. Delete.
kubectl -n shadewright-system delete incident <name>
  1. Restart the analyzer. It counts Incidents, and finds the latest occurrence of each fingerprint (incident-<64 hex>-<n>), only when it starts; deleting an earlier occurrence does not make it open that one again. A deleted Incident is not created again from what the analyzer counted before the delete; a new occurrence of the symptom (a kill it did not see before) opens it again (#893). A kill that arrives in the moment between the delete and the analyzer seeing it (normally milliseconds, longer after a watch outage) is dropped with the old ones, as the analyzer cannot tell it from them; the next kill opens the Incident. That memory does not survive the restart: an old kill still shown in the status of a pod that still exists can then open it again, so delete the Incident of a workload whose pods have been replaced. Deleting the latest occurrence of a fingerprint makes the one before it the latest again: if that one is Resolved, the next recurrence more than 24 hours after its resolvedTime opens a new occurrence under the deleted name; within 24 hours it escalates that earlier Incident:
kubectl -n shadewright-system rollout restart deploy/shadewright-analyzer
  1. Check. shadewright_incidents fell, and shadewright_incident_observations_refused_total stopped rising.

If the cap fills again at once, the namespaces produce many fingerprints: see Limit the namespaces it watches.

Not yet run

The commands were moved here from the troubleshooting entry and were not run again against a live cluster for this guide.