WIP: Fix Config deletion race condition with finalizer protection #465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #461
Problem
The original Config controller implementation has a race condition during deletion:
Root Cause Analysis
The race occurs because Kubernetes provides the following atomicity guarantees:
DeletionTimestampis set, the resource is marked for deletionThe controller was missing a critical check: distinguish between "resources don't exist because they're being deleted" vs "resources don't exist because they need to be created".
Solution: Finalizer-Based Deletion Coordination
This PR implements a finalizer protection pattern that provides deterministic ordering:
1. Deletion Detection (Race Prevention)
2. Finalizer Management (Deletion Coordination)
3. Coordinated Cleanup
How This Eliminates the Race Condition
Safe Deletion Sequence:
DeletionTimestampset, finalizer blocks actual deletionKey Properties:
DeletionTimestampis setChanges
BpfmanConfigFinalizerconstant for deletion coordinationhandleDeletionmethod for coordinated cleanupconfigs/finalizers)Testing
Added test scripts to prove out the general workflow including Config deletion, cascading resource cleanup, and recreation with modified settings. The logic within these scripts should become unit tests for proper integration into the test suite.
Related to #461