fix: end a watch-list stream's initial events with the initial-events-end bookmark - #45
Merged
Merged
Conversation
…-end bookmark kubectl v1.37 (delete, wait --for=delete) and any client-go reflector with WatchListClient open the sandboxes watch with sendInitialEvents=true and wait for the k8s.io/initial-events-end bookmark before they read the initial state. toScaleListOptions dropped the flag and runWatch never sent the bookmark, so the initial sync never completed: a `kubectl delete sandbox` whose release had already succeeded blocked until the server ended the watch. The store now carries the watch-list mode, emits the bookmark after the initial Added events, and ends a watch-list stream whose initial list failed instead of presenting the failure as an empty initial state, so the client retries. Plain watches are unchanged.
…nctest the bookmark test The store field is on only for a watch-list request and never stops the initial Added events, so it is WatchList, not SendInitialEvents. The early return on a failed initial List is dropped with its test and stub: the served store reads NewInventoryCache, which syncs before it returns, so that List cannot fail. The bookmark test runs under testing/synctest instead of real waits, and the docs say the bookmark ends the initial events, not the stream. The comment on toScaleListOptions and the second ListOptions godoc line restated the code.
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
kubectl v1.37's
deleteandwait --for=delete, and any client-go reflector withWatchListClient, open thesandboxeswatch as a watch-list stream (sendInitialEvents=true&allowWatchBookmarks=true&resourceVersionMatch=NotOlderThan). They read the initial state only after thek8s.io/initial-events-endbookmark. k8s.io/apiserver hands that request straight tosandboxREST.Watch. For etcd-backed resources the cacher synthesizes the bookmark; here nothing did.On master the flag never reaches the store:
toScaleListOptionscopies only the namespace and the selectors intoscale.ListOptions.runWatchthen sends the initialAddedevents and moves on to its 1 s poll, with no bookmark. The client's initial sync never completes.The changes:
scale.ListOptionsgainsWatchList.toScaleListOptionssets it under the same condition the apiserver uses to recognise a watch-list request (isListWatchRequest).runWatchsends aBookmarkannotatedk8s.io/initial-events-end: "true"after the initialAddedevents.docs/usage.mdstates when a delete returns and what a watch-list request gets.Evidence
Two-host E2E on 2026-09-24 against sandbox-operator 1a4fadb, on the L3 path through the aggregated apiserver.
kubectl delete sandbox e2el3anever returned after the release succeeded.kubectl getreturned NotFound.kubectl wait --for=delete -v=8shows the watch-list request, answered with 200.awaiting required bookmark event for initial events streamevery 10 s for 49 minutes and did not recover when the 583 s server watch timeout passed. The process was killed by hand.Tests
TestScatterGatherWatch_EndsTheInitialEventsWithABookmarkForAWatchList(undertesting/synctest): a watch-list stream getsAdded, Added, Bookmark, the bookmark carrying the annotation; a plain watch getsAdded, Addedand nothing else. It fails without therunWatchchange.TestToScaleListOptions_CarriesWatchListMode: the request-to-store mapping, includingsendInitialEventswithout bookmarks andsendInitialEvents=false.Cost
One extra event at the start of a watch-list watch. Nothing on the claim or release path.
Gates
GOWORK=off make fmt-check: clean.make lint(every target OS plus the tagged harnesses): 0 issues ×6.make test(race): green.asl -forwarder=false ./...on darwin and linux: 0 findings. The two advisoryforwarderfindings inpkg/envdproxyalso exist on master.