kubernetes: filter event poller fetch by field_selector#6728
Open
geojaz wants to merge 1 commit into
Open
Conversation
Threads a field_selector through KubernetesCluster, KubernetesEventPoller, and kubernetes_commands so the tracker fetches only node events (involvedObject.kind=Node). On runs with >100k events the unfiltered fetch plus yaml.safe_load took minutes; this brings it under a second.
bf5d58b to
29d0c93
Compare
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
Add an optional
field_selectorto the Kubernetes event poller (GetEvents) so callers can have the API server filter events server-side, and use it on the node-change watcher so it polls only Node events.Why
Some benchmarks generate a tremendous volume of Kubernetes events, and collecting them after a run can take several minutes. The node-change tracker is only interested in Node events, but it was fetching and parsing the entire event stream on every poll. Scoping that fetch to
involvedObject.kind=Nodereturns just the events that path consumes and recovers almost all of that collection time.The new
field_selectorparameter defaults toNone(no filtering), so it does not change behavior for callers that do not set it. The behavior that does change is the node-change watcher, which now polls only Node events instead of the full stream.Changes
kubernetes_commands.py,kubernetes_cluster.py,kubernetes_events.py: add an optionalfield_selectortoGetEvents. When unset (the default), the request is unchanged and no--field-selectorflag is added.kubernetes_tracker.py: the node-change watcher now passesfield_selector="involvedObject.kind=Node", so it polls only Node events.kubernetes_tracker_test.py: coverage for the filtered fetch.