This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
Continuous watching by reusing the resourceVersion multiple times #229
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.
Optimize the K8s-watching reconnections by valid resource version
Description
Currently, Kopf does 1 listing and 1 watching query per iteration: the listing is to get the latest valid resource version, from which the watching continues. The listed items are simulated to be yielded as if from a watch-stream.
When the watch-query disconnects (this happens every ~60 seconds if the timeout is not set), the whole list is re-read again. This leads to
@kopf.on.resume
handlers being called multiple times for no actual need.With this PR, the watch-queries will be repeated as long as the known latest resource version value is valid (i.e. accepted by the API). Once 410 GONE error is returned, the stream will stop and escalate to the full re-listing as before.
Types of Changes
Review
List of tasks the reviewer must do to review the PR