kuberay icon indicating copy to clipboard operation
kuberay copied to clipboard

[Refactor][RayCluster] RayClusterHeadPodsAssociationOptions and RayClusterWorkerPodsAssociationOptions

Open rueian opened this issue 1 year ago • 2 comments
trafficstars

Why are these changes needed?

Introduce the following association functions to centralize many ad-hoc MatchingLabels that are scattered around:

  • RayClusterHeadPodsAssociationOptions
  • RayClusterWorkerPodsAssociationOptions
  • RayClusterGroupPodsAssociationOptions
  • RayClusterAllPodsAssociationOptions

These functions return options of a new type AssociationOptions that can convert the options into either a []client.ListOption or a []client.DeleteAllOfOption so that we can use them like this:

filters := common.RayClusterWorkerPodsAssociationOptions(instance)

r.List(ctx, &corev1.Pod{}, filters.ToListOptions()...)

r.DeleteAllOf(ctx, &corev1.Pod{}, filters.ToDeleteOptions()...)

Checks

  • [x] I've made sure the tests are passing.
  • Testing Strategy
    • [x] Unit tests
    • [x] Manual tests
    • [ ] This PR is not tested :(

rueian avatar Mar 15 '24 16:03 rueian

Hi @kevin85421,

What do you think about the new AssociationOptions that allows us to convert associations to either a slice of ListOption or DeleteAllOfOption?

I'd like to have your feedback, thanks!

rueian avatar Mar 16 '24 03:03 rueian

What do you think about the new AssociationOptions that allows us to convert associations to either a slice of ListOption or DeleteAllOfOption?

LGTM

kevin85421 avatar Mar 16 '24 06:03 kevin85421

Hi @evalaiyc98, could you also help review this?

rueian avatar Mar 18 '24 12:03 rueian

Sure!

evalaiyc98 avatar Mar 18 '24 13:03 evalaiyc98

I've noticed that the logic used here still resembles the original approach. I believe it would be beneficial to maintain consistency with the previous refactor part. What are your thoughts on this?

https://github.com/ray-project/kuberay/blob/a87f9a6a6d8ead0ffd81dc823f2fd7f38f2af027/ray-operator/controllers/ray/suite_helpers_test.go#L206-L209

evalaiyc98 avatar Mar 21 '24 15:03 evalaiyc98