Distinguish between initial and resumed watch phases for streaming lists#1882
Merged
Merged
Conversation
…r streaming lists Signed-off-by: doxxx93 <[email protected]>
0eb30f4 to
42c3bb9
Compare
Signed-off-by: doxxx93 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1882 +/- ##
=======================================
+ Coverage 76.0% 76.1% +0.2%
=======================================
Files 85 85
Lines 8267 8285 +18
=======================================
+ Hits 6275 6301 +26
+ Misses 1992 1984 -8
🚀 New features to boost your workflow:
|
Member
Author
|
I will add some tests |
clux
approved these changes
Jan 3, 2026
Member
clux
left a comment
There was a problem hiding this comment.
Thanks a lot! This looks great to me. Did a quick sanity run and it does indeed fix the underlying problem.
Member
|
Happy to merge? |
Member
Author
|
Yeah 😀 |
Closed
hugoponthieu
pushed a commit
to hugoponthieu/kube
that referenced
this pull request
Jan 29, 2026
…sts (kube-rs#1882) * fix(watcher): distinguish between initial and resumed watch phases for streaming lists Signed-off-by: doxxx93 <[email protected]> * test(watcher): add unit tests for WatchPhase behavior Signed-off-by: doxxx93 <[email protected]> --------- Signed-off-by: doxxx93 <[email protected]>
cchndl
pushed a commit
to cchndl/kube
that referenced
this pull request
Feb 19, 2026
…sts (kube-rs#1882) * fix(watcher): distinguish between initial and resumed watch phases for streaming lists Signed-off-by: doxxx93 <[email protected]> * test(watcher): add unit tests for WatchPhase behavior Signed-off-by: doxxx93 <[email protected]> --------- Signed-off-by: doxxx93 <[email protected]>
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.
Motivation
Fixes #1844
When using
streaming_lists()mode, users observe duplicate events every ~290 seconds. This happens because watch connections timeout after 290s (Kubernetes API limitation), and when reconnecting, the watcher incorrectly setssendInitialEvents=true, causing the API server to resend all objects.The root cause is that
to_watch_params()always setssend_initial_events=truefor StreamingList mode, regardless of whether it's an initial watch or a reconnection.Solution
Introduce a
WatchPhaseenum to distinguish between initial and resumed watches:This aligns with how client-go handles streaming lists - it uses watchList() for initial sync and watch() for reconnections, never requesting initial events on reconnection.