This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
Prevent repeated resumes of a resource by remembering its resumed flag #230
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.
Description
This PR does two things:
First, it adds a per-resource in-memory container, which is remembered for the whole lifecycle of an operator. This can lead to more memory consumption on big clusters.
It is different from the persistent storage of the object's data directly on the object's status, as the values stored in the in-memory container are specific to that operator process only, and sometimes not serialisable (e.g. threads, tasks, asyncio events, locks, etc).
Second, it remember every object's resuming status in-memory. Once resumed, the object is never resumed again. Otherwise (i.e. currently), the resuming happens on every reconnection of the API watch-stream (partially remedied by #229, but not fully).
More on that, currently (i.e. before fixing), if there are multiple resume handlers or retries or sub-handlers, only the first attempt will be executed. Also, if the on-resume handlers go after the on-create/on-update handlers, they are ignored. All other attempts after the initial listing will not be interpreted as "initial" (due to event's type not being
None
anymore), thus not detected as resuming.With this PR, the resume handlers are included into the selection until all of them succeed at least one — even for the regular watch-events with
['type']!=None
(i.e. after patching from the previous attempts).Such approach should improve the following for the
@on.resume
handlers:Types of Changes
Review
List of tasks the reviewer must do to review the PR