Skip to content

Operator: object stuck on delete – orphaned finalizer

Python & Gotested on Go 1.26, Kubebuilder v4, controller-runtime, envtest

"Deleted" and still there: the object carries a deletionTimestamp, but a finalizer holds it – and no controller feels responsible for that name.

Symptom

kubectl delete site alt --timeout=5s
staticsite.web.lab.example "alt" deleted from default namespace
error: timed out waiting for the condition on staticsites/alt

An old site carries the finalizer web.lab.example/cleanup from version 0.9 of the operator.

Diagnosis

deletionTimestamp and finalizers of all sites side by side (GELOESCHT = deleted).

kubectl get site -o custom-columns="$COLS,FINALIZER:.metadata.finalizers[*]"
NAME   GELOESCHT              FINALIZER
alt    2026-10-10T08:47:33Z   web.lab.example/cleanup
demo   <none>                 <none>
neu    <none>                 <none>

Causes

renamed finalizerNobody responsible

Today's operator uses web.lab.example/finalizer. No controller removes the old name web.lab.example/cleanup any more.

external serviceSecond common cause

If your own finalizer hangs because the external service is down, the log and Degraded show the retry – then waiting or repairing helps, not patching.

Fix

First check that the external cleanup is done, then remove exactly this finalizer – test prevents hitting the wrong index.
kubectl patch site alt --type json -p '[
  {"op":"test","path":"/metadata/finalizers/0","value":"web.lab.example/cleanup"},
  {"op":"remove","path":"/metadata/finalizers/0"}]'
staticsite.web.lab.example/alt patched
Error from server (NotFound): staticsites.web.lab.example "alt" not found

Don't: Patching finalizers: null across the board – that also removes your operator's finalizer and leaves external leftovers.

▶
Break it yourself and find it – free
Kubernetes operators hands-on, Day 15: a competition with eight typical operator faults, from hot loop to orphans.
Go to day 15 →

FAQ

How do I rename a finalizer cleanly?

The operator migrates old objects itself: RemoveFinalizer for the old name, AddFinalizer for the new one, then an Update.

Why do I delete the children by hand in the lab?

envtest has no garbage collector. In a real cluster it removes objects with ownerReferences.

Related error patterns

More