StageFailed see history edit this page

Talks about: , , , and

Symptom

READY=False, REASON=StageFailed. The Message names the stage and the operation that failed (fetch artifact, build, apply, verify, a pre/post action, or connect to target cluster). The run halts at that stage; later stages keep their previous revisions.

Cause

A stage failed during execution. By operation:

Diagnosis

kubectl --namespace <namespace> describe stageset <name>     # Message: which stage + operation
kubectl --namespace stageset-system logs deploy/stageset-controller --tail=200

# For apply/verify failures, inspect what the stage tried to apply:
kubectl --namespace <namespace> get stageinventory \
  --selector stages.metio.wtf/stage-set=<name>,stages.metio.wtf/stage=<stage>

Remediation

Match the operation in the Message:

An apply that failed with Unauthorized

Unauthorized is authentication, not authorization, so it is not an RBAC problem — checking the tenant ServiceAccount’s Role will send you down the wrong path. The controller applies as spec.serviceAccountName using a short-lived TokenRequest token, and that token is bound to the ServiceAccount’s UID. Deleting and recreating the ServiceAccount — which happens to every ServiceAccount in a namespace that is torn down and rebuilt — gives it the same name and a new UID, so a token minted before the rebuild authenticates as an object the apiserver no longer knows.

The controller handles this: a 401 evicts the cached credential, mints a fresh one, and retries the call once. A message that names the ServiceAccount and says the fresh token was refused too means the retry did not help, so look at the ServiceAccount itself:

kubectl --namespace <namespace> get serviceaccount <sa-name>

A missing ServiceAccount, or a namespace in Terminating, is the answer. Recreate the ServiceAccount (or let the namespace finish terminating) and the next reconcile applies normally.

Retries re-run the same pinned snapshot idempotently — actions already recorded in the stage’s ledger do not re-fire. See stages and sources for how a stage resolves and applies.