TL;DR the orphan finalizer only ensures that children become orphans. Depending on the orphan finalizer being present during deletion/teardown is racy when there are other finalizers on the same object.
Orphaning deletion adds the orphan finalizer during deletion to ensure that all ownerReferences pointing to this object will be removed BEFORE the object gets deleted.
After all children had their ownerReferences
removed, the orphan
finalizer gets removed to unblock deletion of the parent object.
This means that if the parent has another finalizer and someone watches the parent they:
- Will probably see the orphan finalizer being added on deletion and then removed again afterwards.
- Are not guaranteed to see the orphan finalizer on the deleted object at all.
An illustrated example:
- create parent configmap:
kubectl apply -f parent.yaml