Investigation & Containment

Investigation

Four questions, in this order: what did the canary decide, which version serves, does the analysis have data, and does the traffic pass through the split at all. Every kubectl names the cluster with --context (Chapter 01).

  1. What did the canary decide? The Canary’s status is the verdict on the last release; its events are the reasoning:

    kubectl --context kind-sre-control-plane -n develop get canary frontend
    kubectl --context kind-sre-control-plane -n develop get events --field-selector involvedObject.kind=Canary --sort-by=.lastTimestamp | tail
    

    Succeeded - the last release was promoted; Failed - it was rolled back; Progressing with a weight - it is being measured now. Each check that does not pass leaves an event with the reason: a success rate below the threshold, a latency above it - or no values found.

  2. Which version serves? With a canary, the Deployment named in Git is not the one that serves. Flagger copies a promoted version into frontend-primary, and keeps frontend - the canary - at 0 between releases:

    kubectl --context kind-sre-control-plane -n develop get deploy frontend frontend-primary \
      -o custom-columns='NAME:.metadata.name,READY:.status.readyReplicas,IMAGE:.spec.template.spec.containers[0].image'
    

    Git’s tag on frontend, and a different, older tag on frontend-primary that serves: the release was not promoted. In the story, frontend-primary showed March.

  3. Does the analysis have data? Flagger asks Prometheus about the canary’s own requests, as Traefik counts them. Ask two things - through the API server, no port-forward needed: is Traefik scraped at all, and which requests did it count:

    prom() { kubectl --context kind-sre-control-plane get --raw \
      "/api/v1/namespaces/observability/services/kube-prometheus-stack-prometheus:http-web/proxy/api/v1/query?query=$(jq -rn --arg q "$1" '$q|@uri')" \
      | jq -r '.data.result[] | "\(.metric | del(.__name__) | tostring) \(.value[1])"'; }
    prom 'up{job="observability/traefik"}'
    prom 'sum by (service, code) (rate(traefik_service_requests_total{service=~"develop-frontend-.*"}[2m]))'
    

    The first: Traefik’s metrics target with the value 1 - scraped; nothing or 0 - the analysis can never have data. The second: rows for develop-frontend-primary-… and, while a release runs, develop-frontend-canary-…, each with its status codes. No rows means no matching requests in the last two minutes - no traffic through the split, not necessarily a broken scrape. Only the primary while the canary has weight - the canary’s share of the traffic does not reach it. In Flagger, a check with no data fails: it is the safe default for a single check, and the reason a canary without traffic rejects every release.

  4. Does the traffic pass through the split? Flagger splits at one place: the TraefikService it writes, with a weight for the primary and one for the canary. A request reaches it only along a route that points there:

    kubectl --context kind-sre-control-plane -n develop get traefikservice frontend -o jsonpath='{.spec.weighted.services}{"\n"}'
    kubectl --context kind-sre-control-plane -n develop get ingressroute -o custom-columns='NAME:.metadata.name,MATCH:.spec.routes[*].match,PRIORITY:.spec.routes[*].priority'
    

    Between releases one entry - frontend-primary, weight 100; while a release is measured, a second one for frontend-canary with its share. And a route that matches the host users send. In the story the routes matched a name no request carries, and the frontend’s calls to the backend never touch Traefik at all.

The root cause is not Flagger or its threshold. It is an analysis that could never see a request, and a rejection that reached nobody: no metrics, no traffic through the split, no alert.

Containment

  1. Keep the threshold; give the check its data. Metrics first (Traefik scraped), then traffic that passes the split - real users, or synthetic requests where there are none. Then a release, to see the check pass.
  2. Make a rejection loud. An alert when a canary is rolled back: the release process failing is an incident of its own.
  3. Close the doors the canary opened. Every route made for it is reviewed like any public route - here, the routes to the backend’s internal name are removed.
  4. Do not switch the canary off to “fix” it. Without it, the next bad release reaches everyone (Chapter 15). Off is a decision with a date to turn it back on, not a fix.

A canary is only as good as the requests it can see: no traffic, no metric - and then no release, and nobody knows.


Pause and Predict: The canary’s success rate is 100% for the first minute of a bad release and then drops. Name one reason the errors might reach the analysis late.