Kubernetes: Unit Tests for deleteObject NotFound Handling in GC
Written by Alessio on 3/10/2026
Problem
The garbage collector's handling of NotFound errors from deleteObject lacked unit test coverage. Edge cases in background and foreground deletion paths weren't verified.
Solution
Added unit tests covering both code paths:
- Default (background propagation): item with dangling owner
- waitingForDependentsDeletion: item whose owner is foreground-deleting
Tests verify that when deleteObject returns NotFound, attemptToDeleteItem enqueues a virtual delete event and returns enqueuedVirtualDeleteEventErr.
Result
Improved test coverage ensures the garbage collector handles externally deleted objects correctly in all scenarios.
Commit: kubernetes/kubernetes@8ed40e7