WIP: Expose a handle to cleanly cancel a reflector #6602
Closed
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.
@lavalamp need opinions before I move on.
This is the first step in teaching
kubectl stop
to watch status.replicas of an rc, the unittest has a fairly complete example of how I plan to use reflector cancellation in creating an edge trigger watcher (watches a resource for a single value, in this case status.replicas=0).This PR exposes a CancellationController capable of dictating when a reflector should cleanup and unwind the listAndWatch stack. The cancellation controller uses a single channel as a conduit for cancellation signals. The signal might take the form of either a timeout (resync period of the reflector) or a stop event sent from some client of the reflector that no longer cares about what it's watching (all the resizers in kubectl).
For this to WAI we also need to send a stop signal to reflector.RunUnti, or the reflector will just retry. This is how we'd get the stop signal to stop watching, while the resync timeout will not stop watching.
Also fixes #6488