Skip to content
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

fix(propeller): Replace SharedIndexInformer with Informer #5129

Conversation

MortalHappiness
Copy link
Member

Tracking issue

Resolves: #5087

Why are the changes needed?

See the issue for detailed information.

What changes were proposed in this pull request?

  • Replace SharedIndexInformer (client-go) with Informer (controller-runtime)
  • Add core.KubeClient to ResourceLevelMonitor
  • Replace objects with PodList

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Mar 28, 2024
@MortalHappiness MortalHappiness marked this pull request as draft March 28, 2024 09:06
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.93%. Comparing base (f1c2231) to head (80037f5).
Report is 1 commits behind head on master.

❗ Current head 80037f5 differs from pull request most recent head 70d0573. Consider uploading reports for the commit 70d0573 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5129      +/-   ##
==========================================
+ Coverage   59.06%   59.93%   +0.86%     
==========================================
  Files         646      463     -183     
  Lines       55714    39030   -16684     
==========================================
- Hits        32910    23394    -9516     
+ Misses      20208    13792    -6416     
+ Partials     2596     1844     -752     
Flag Coverage Δ
unittests 59.93% <ø> (+0.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ByronHsu ByronHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good overall! Thanks for the quick help! But it would be better if you can add the logics behind why you made this change. The reader only knows "what is the issue" and "the solution", but there is a gap in between

counts := r.countList(ctx, objects)

pods := &corev1.PodList{}
if err := r.kubeClient.GetClient().List(ctx, pods); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am uncertain about the change here. Originally, sharedInformer fetches the resources it listens to, but now it changes to only fetches pods. Also, the code seems be metrics collecting and is from four years ago. I am not sure if the code is still relevant. cc @wild-endeavor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it is not safe to update this to a PodList because it will not capture other k8s resource types for other Flyte plugins (ex. Spark, Ray, TF, PyTorch, etc).

@@ -668,16 +668,10 @@ func getPluginGvk(resourceToWatch runtime.Object) (schema.GroupVersionKind, erro
return kinds[0], nil
}

func getPluginSharedInformer(ctx context.Context, kubeClient pluginsCore.KubeClient, resourceToWatch client.Object) (cache.SharedIndexInformer, error) {
func getPluginSharedInformer(ctx context.Context, kubeClient pluginsCore.KubeClient, resourceToWatch client.Object) (cache.Informer, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
func getPluginSharedInformer(ctx context.Context, kubeClient pluginsCore.KubeClient, resourceToWatch client.Object) (cache.Informer, error) {
func getPluginInformer(ctx context.Context, kubeClient pluginsCore.KubeClient, resourceToWatch client.Object) (cache.Informer, error) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@MortalHappiness MortalHappiness force-pushed the bugfix/#5087-limit-namespace-error branch from aa10ed9 to 80037f5 Compare March 29, 2024 01:31
@pingsutw
Copy link
Member

pingsutw commented Apr 4, 2024

@EngHabu @hamersaw mind taking a look

Update unittests corresponding to the changes from SharedIndexInformer to Informer

Resolves: flyteorg#5087
Signed-off-by: Chi-Sheng Liu <[email protected]>
@MortalHappiness MortalHappiness force-pushed the bugfix/#5087-limit-namespace-error branch from 80037f5 to 70d0573 Compare April 4, 2024 13:35
@MortalHappiness MortalHappiness marked this pull request as ready for review April 4, 2024 13:36
@dosubot dosubot bot added the bug Something isn't working label Apr 4, 2024
Copy link
Contributor

@hamersaw hamersaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MortalHappiness thanks for the PR here! Great insight, but I'm actually wondering if we have gone too far here. The original code just retrieves the informer and uses the cache.sharedIndexInformer to periodically retrieve the list of k8s resources so that it can emit a metric. This obviously pulls from a cache.

Does it make more sense to just use the cache (ie. kubeClient.GetCache() ) within the ResourceLevelMonitor and periodically retrieve directly from there depending on object type? So this line could instead be:

rm := monitorIndex.GetOrCreateResourceLevelMonitor(ctx, metricsScope, kubeClient.GetCache(), entry.ResourceToWatch, gvk)

@eapolinario
Copy link
Contributor

Superseded by #5238.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Flytepropeller error and crash when "limit-namespace" is set
5 participants