Repository navigation
Conversation
When Watch cannot find the return type of the list function (no return annotation and no ":rtype:" docstring, e.g. a lambda wrapper around a generated list function), unmarshal_event returned the raw event before recording its resourceVersion. Watch.resource_version stayed at the initial value, even across BOOKMARK events, so Watch reconnected from the initial version, replayed events and raised 410 Gone once that version expired; SharedInformer, which copies it, re-listed. Record the resourceVersion from the raw event dict, sharing the helper with the deserialize=False path. Events are still returned unchanged. As with typed list functions, such a watch started without resource_version and timeout_seconds now reconnects from the last event's version when the server closes the stream instead of ending, and raises ApiException(410) if that version has expired. Add a test that streams through a lambda wrapper and checks the tracked resource version and the version used to reconnect.
SharedInformer never set allow_watch_bookmarks on its watch requests, so the API server sent no BOOKMARK events. BOOKMARK handlers never ran, and a watch with a narrow namespace or selector kept the resource version of the last list. When such a quiet watch reconnected after the server had dropped that version from its watch history, it got 410 Gone and re-listed every object, firing MODIFIED for each of them. Set allow_watch_bookmarks=True on every watch request the informer opens. The list requests are unchanged. Watch already records the resource version of a BOOKMARK event, so the informer now resumes from it, and registered BOOKMARK handlers start to receive the raw bookmark object. Add a unit test that runs the real Watch over typed and dict list responses and a list function without a return type, and checks the watch arguments, the BOOKMARK handler and the resource version of the next watch.
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 |
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
/kind feature
What this PR does / why we need it:
A reconnecting
SharedInformercan resume from its initial list's resource version; once the server no longer keeps it, the watch gets 410 Gone and re-lists, firing MODIFIED for every cached object. Two commits fix this:Watchcannot find the list function's return type, e.g. a lambda wrapper, it never recorded a resource version, soWatchandSharedInformerreconnected from the initial one. It is now read from the raw event; yielded events are unchanged.allow_watch_bookmarksthe server sends no BOOKMARK events, so handlers never run and a namespace- or selector-scoped watch keeps its list's resource version while nothing matching changes. The informer now sets it on watch requests (not lists).On kind, with a lambda
list_func, a watch dropped after the list's resource version expired re-listed once on master and zero times with this PR.Which issue(s) this PR fixes:
None filed.
Special notes for your reviewer:
A custom
list_funcwrapper must acceptallow_watch_bookmarks; all generated list functions do.How I tested it:
test_informer.pyandtest_watch.py: 7 passed, as on master.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: