Foreground-deleting an in-deletion object

179 views
Skip to first unread message

Ingo Bürk

unread,
May 8, 2024, 11:01:25 AM5/8/24
to K8s API Machinery SIG
Hi everyone,

I noticed some behavior that I'd like to discuss. Say we have some object with a finalizer to prevent it from being deleted, e.g.

```
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
  finalizers:
  - acme.org/keep
  name: test
  namespace: default
EOF
```

If I now foreground-delete this object repeatedly, 

```
kubectl delete cm test --cascade=foreground
```

Kubernetes will happily keep adding the foregroundDeletion finalizer (and instantly remove it, but that's not relevant here). 

My question is: is it intentional that repeated DELETEs will re-add the foreground finalizer? I would rather expect that it is only set once, when the object actually goes into the in-deletion state (deletionTimestamp being set).

Where this can actually matter is if you write a controller that owns some resources (creates them with owner references), but actually also "manually" deletes those objects when the owner is being deleted. This essentially can cause a feedback loop where the controller deletes the dependent, adding a finalizer, GC removes that finalizer, causing the owner to be reconciled, causing the controller to delete the dependent, and so on.

Arguably this would be incorrect usage and the controller should just leave the deletion to GC, however I'm just wondering if there's a particular reason that the finalizer will be re-added every time.


Best
Ingo


Reply all
Reply to author
Forward
0 new messages