[OpinionatedReconciler] Add debug logging and tracing, change some logic to avoid retry loops on deletes #560
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 #559, added debug logging and tracing similar to what
OpinionatedWatcher
already has. While testing, changed the logic in theOpinionatedReconciler
to resolve two issues:deletionTimestamp
, theOpinionatedReconciler
would remove the finalizer and return, and then rely on the subsequent delete event to be propagated down to the downstream reconciler for delete behavior. This introduces an edge case that is addressed inOpinionatedWatcher
but missed here, where, if the downstream's processing of the delete fails, the object is still deleted in the API server, possibly leaving a bad state (inOpinionatedWatcher
, the finalizer is not removed until the downstream delete is successfully processed). The logic has now been changed to mimic that of theOpinionatedWatcher
, sending the "adddeletionTimestamp
" event to the downstream reconciler as a delete event, and only removing the finalizer once this is successful. As a side effect, actual delete events are no long propagated to the downstream.deletionTimestamp
, a delete event is emitted in the watch stream which still contains the last finalizer to be removed (if there were multiple finalizers, only the last one is present in the list, i.e. the last state the object was in before the finalizers list became empty), rather than an empty finalizers list. To combat having this make us attempt to then remove the finalizer again (because the object is actually deleted now and this will result in an error which will be retried by default), the swallowing of delete events has been moved to before any of the other deletionTimestamp checks.Example of deletion finalizers list behavior from (2):
Here a new
issue
is created (from the tutorial project), the reconciler adds its finalizer, then an extrafoo
finalizer is added. The object is deleted, and the reconciler automatically removes its finalizer. Thefoo
finalizer is removed, but the state of the object doesn't change and the delete happens with that state.