Investigation & Containment

Investigation

Before you roll anything back, find out which image is really running - and what chooses it. Every cluster command names the cluster with --context (Chapter 01); the git and docker commands run in your clone of the platform repository. On your kind cluster the same commands answer for your own environments.

  1. What does each environment ask for? The Deployments’ image references:

    kubectl --context kind-sre-control-plane get deploy -A -l app=backend \
      -o custom-columns='NAMESPACE:.metadata.namespace,IMAGE:.spec.template.spec.containers[0].image'
    

    One tag per environment - for example develop-v0.0.0-…, staging-v0.0.0-165ecab-…, production-v0.0.0-165ecab-…; yours may be newer. A tag is a name - it says what was asked for, not what runs.

  2. What do the pods really run? The digest the node pulled:

    kubectl --context kind-sre-control-plane get pods -A -l app=backend \
      -o custom-columns='NAMESPACE:.metadata.namespace,POD:.metadata.name,DIGEST:.status.containerStatuses[0].imageID'
    

    Right after a promotion, staging and production show the same sha256:… - the same content under two names. Once staging has moved on, its pods run a newer build; production’s digest is then the one of the staging build it was promoted from (step 3). develop shows another one: it is a separate build, from the develop branch.

  3. What do the tags point to in the registry?

    PROD_TAG=$(yq '.images[0].newTag' flux/apps/backend/production/kustomization.yaml)
    STAGING_TAG="staging-${PROD_TAG#production-}"      # the staging build production was promoted from
    for TAG in "$STAGING_TAG" "$PROD_TAG"; do
      echo "$TAG $(docker buildx imagetools inspect "ghcr.io/safeops-course/backend:$TAG" --format '{{json .Manifest}}' | jq -r .digest)"
    done
    

    The production tag comes from your checkout’s overlay, and the staging tag it was promoted from has the same suffix. The same digest twice - the one production’s pods run. The production tag was made from the staging tag, not built.

  4. What does the app say it is?

    kubectl --context kind-sre-control-plane -n production exec deploy/backend -- wget -qO- http://localhost:8080/version
    

    "version" is $STAGING_TAG from step 3, and "commit" the commit in its name - production reports the staging build it was promoted from. The version is baked in at build time; a promotion does not change a byte. (On Hetzner the everyday sign-in has no exec in production - there the digests of steps 2 and 3 are the proof.)

  5. Who changed the version, and when?

    git log -4 --format='%ad  %<(24)%an  %s' --date=short -- flux/apps/backend/production/kustomization.yaml
    

    Every version change is a commit - by a person, or by Flux Image Automation with Update production backend image. In the story, the automation’s commit after the revert was the answer.

  6. What chooses the next version? On the cloud cluster, the production ImagePolicy and its automation - on Hetzner, the everyday sign-in may read them:

    flux --context hetzner-sre-control-plane get image policy -n production
    flux --context hetzner-sre-control-plane get image update -n production
    

    The policy’s latest tag is what the automation will write. If it is still the broken tag, a revert of newTag will not last. On kind there is nothing to show - kind has no image automation; the lab builds the same policy in lab to watch it choose.

The root cause is not Git, Flux or the automation. It is a rollback of the output while the input still chose the broken version: the ImagePolicy picked the newest production tag, and newTag only recorded that choice.

Containment

  1. On the cloud cluster, change what chooses: one pull request that narrows the production ImagePolicy’s pattern to the last good tag and sets newTag to it. The policy, the automation and Git then agree.
  2. On kind - no automation - a revert of newTag is enough, through Git like every change.
  3. Prove it by digest: the pods’ imageID is the good tag’s digest, and /version reports the good build.
  4. Restore the pattern in a second pull request once the fix has been promoted from staging - or every later release stays pinned out.

Roll back what chooses the version, not only what records it - and prove the result by digest, not by tag.


Pause and Predict: Someone pushes a new production-v1.4.1-… tag built on a laptop, with a newer timestamp. Which tag does the production ImagePolicy pick - and what does that say about what the policy can and cannot check?