Repository navigation
Conversation
When stop() was requested after Watch yielded an event, the loop dropped that event, but the finally block still copied Watch.resource_version, which had already advanced past it. The next start() resumed after the event, so it was lost until the next relist. Stop copying the Watch's resource version in the finally block; the loop already syncs it for every processed event. Add unit tests for a restart after a dropped event and for an event that fails key_func.
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ilcm96 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
|
/assign @yliaog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
/kind bug
What this PR does / why we need it:
SharedInformercan be stopped and started again, keeping its cache and resource version, for example when a leader loses and regains its lease. Ifstop()lands afterWatchhas read an event but before the informer applies it, the loop drops the event, but thefinallyblock still copiedWatch.resource_version, which already pointed at that event. The nextstart()resumes after it without a relist, so withresync_period=0the event is lost for good and the cache keeps the old object until it changes again.This happens without any injected timing. On a kind cluster, one process patched 20 ConfigMaps (~4 KiB each, ~220 events/s) while the informer was stopped at a random moment and started again, 200 times. On master, 6 of the 200 restarts lost an event and left that ConfigMap stale in the cache (21 of 200 at ~860 events/s). With this change, none did in either run.
This PR stops copying the resource version in
finally. The loop already syncs it after the stop check for every processed event, so other paths, including 410 handling, are unchanged.Which issue(s) this PR fixes:
None filed.
Special notes for your reviewer:
An event whose cache update fails (e.g. a raising
key_func) is still skipped, as before, because retrying it would fail the same way in a loop.How I tested it:
kubernetes/test/test_informer.py:test_event_received_after_stop_is_not_skipped_on_restartfails on master;test_events_after_failing_cache_update_are_still_appliedpins the existing behaviour.kubernetes/e2e_test/test_informer.pyandtest_watch.py(7 passed, same as master).Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: