-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr/v1.13 backport 2023 01 23 2 #23238
Closed
Closed
Conversation
This file contains 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
This introduces a set of centrally managed resource.Resource[T] objects. These aim to replace the current k8s/watchers and k8s/watchers/subscriber, with a single interface (Resource[T]) that one can be observed and its store queried from any cell. With this we'll gradually remove K8sWatcher by moving code from k8s/watchers/ into feature specific packages that subscribe to Resource[T]. See pkg/k8s/resource/example.go for usage example of Resource[T]. To start things off, in this patch the Resource[*Service] and Resource[*Node] are introduced into the object graph and the existing service and node watchers are refactored to be implemented on top of it. This keeps the existing code working, but allows new cells to use these objects directly without dependency on K8sWatcher. Signed-off-by: Jussi Maki <jussi@isovalent.com>
Add Resource[*slim_corev1.Namespace] to the shared resources and refactor the namespace watcher to use it. Signed-off-by: Jussi Maki <jussi@isovalent.com>
In PR #22397 the nodespecer implementation was turned into a cell. That implementation used the localNodeStore to get access to a generic node object that would contain annotations, labels and podCIDRs. However, it turns out that the localNodeStore doesn't function as one might expect and didn't register updates properly. This commit changes the implementation to use resources to subscribe to changes in the node objects of the API server directly. This is very much like the old pre-modularization implementation, but now using resources instead of informers. Fixes: #23155 Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
As Resource[T] was used more it became apparent that making it an stream.Observable and having Event[T] be an interface makes it inconvenient to use: - Almost always we're subscribing to it for the whole duration of the application and do not need to handle completion errors. Consuming the events via a channel is also often the preferred way as it always "for-select" over multiple resources. - Event[T] contains almost the same payload for all event types, we might as well keep it simple and just use a single struct. This changes Observe() into `Events(ctx, opts) <-chan Event[T]` and moves rate limiting and error handling to be per-subscriber options. Event[T] becomes a single struct with a kind tag to specific event type. In order to handle large datasets at startup the events are now emitted immediately rather than waiting for informer to synchronize the store first. The BenchmarkResource in resource_test.go was also ported to current master and the difference between the unbuffered channel approach to callback was about 2x (2600ns/op for channels, 1350ns/op for callbacks), which is negligble enough. Benchmark was also ran with buffered event channel with no difference to unbuffered. Unbuffered is preferable as allows better chances for coalescing away the intermediate updates for objects with the same key. Signed-off-by: Jussi Maki <jussi@isovalent.com>
The commit "resource: Refactor the API for simplified usage" was tested against older master, before the commit "cli: Add configuration flag for service LB" which used the older API, causing the build to fail. This updates StartCECController() to use the new Resource.Events method. Fixes: f3a9b0a ("resource: Refactor the API for simplified usage") Signed-off-by: Jussi Maki <jussi@isovalent.com>
maintainer-s-little-helper
bot
added
backport/1.13
This PR represents a backport for Cilium 1.13.x of a PR that was merged to main.
kind/backports
This PR provides functionality previously merged into master.
labels
Jan 23, 2023
replaced by #23276 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport/1.13
This PR represents a backport for Cilium 1.13.x of a PR that was merged to main.
kind/backports
This PR provides functionality previously merged into master.
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.
Once this PR is merged, you can update the PR labels via:
or with