Skip to content
Latchkey

Kubernetes Resource Stuck Deleting on a Finalizer in CI

A finalizer is a key in metadata.finalizers that blocks deletion until a controller does cleanup and removes it. If that controller is uninstalled or broken, the finalizer is never cleared and the object is stuck Terminating forever.

What this error means

kubectl delete hangs and the object stays in Terminating. kubectl get <obj> -o yaml shows a non-empty metadata.finalizers and a set deletionTimestamp, but nothing removes the finalizer.

kubectl output
$ kubectl get widget my-widget -o yaml | grep -A2 finalizers
  finalizers:
  - example.com/cleanup
  deletionTimestamp: "2026-06-25T10:00:00Z"   # stuck Terminating

Common causes

The owning controller is gone or broken

The controller responsible for the finalizer (an operator, a namespace cleanup controller) was uninstalled or is crashing, so it never completes cleanup and never removes the finalizer.

External cleanup that can never succeed

The finalizer waits on an external resource (a cloud load balancer, a remote API) that no longer exists or is unreachable, so the controller blocks indefinitely.

How to fix it

Restore the controller so it can finish cleanup

The correct fix is to make the finalizer’s owner run again so it removes the finalizer after real cleanup.

Terminal
kubectl get pods -n <operator-ns> -l app=<operator>
kubectl logs -n <operator-ns> deploy/<operator> --tail=50

Remove the finalizer only as a last resort

If the controller is permanently gone and the external resource is already cleaned up, drop the finalizer to release the object.

Terminal
kubectl patch widget my-widget --type=json \
  -p='[{"op":"remove","path":"/metadata/finalizers"}]'

How to prevent it

  • Keep the controllers that own finalizers installed and healthy.
  • Make finalizer cleanup bounded so an unreachable external resource cannot deadlock forever.
  • Audit metadata.finalizers before deleting operators that add them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →