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

Move matching labels to association.go #2734

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

owenowenisme
Copy link
Contributor

@owenowenisme owenowenisme commented Jan 13, 2025

Why are these changes needed?

#2733

Related issue number

Closes #2733

Checks

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

@owenowenisme owenowenisme force-pushed the move-matchingLabels-to-association.go branch from f89cc2d to 9e9031f Compare January 13, 2025 01:01
@owenowenisme
Copy link
Contributor Author

@rueian please take a look🙏🙏🙏

@rueian
Copy link
Contributor

rueian commented Jan 13, 2025

Hi @owenowenisme,

I noticed that there are RayClusterHeadPodsAssociationOptions and RayClusterWorkerPodsAssociationOptions in the association.go. Could you reuse them?

@@ -100,6 +100,16 @@ func RayClusterWorkerPodsAssociationOptions(instance *rayv1.RayCluster) Associat
}
}

func RayClusterRedisPodsAssociationOptions(instance *rayv1.RayCluster) AssociationOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test for this new method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

utils.RayNodeTypeLabelKey: "head",
}
if err := r.List(ctx, &rayHeadSvc, client.InNamespace(instance.Namespace), filterLabels); err != nil {
filterLabels := common.RayClusterAllPodsAssociationOptions(instance).ToListOptions()
Copy link
Member

Choose a reason for hiding this comment

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

Use RayClusterHeadServiceListOptions instead?

@@ -544,9 +544,9 @@ func (r *RayClusterReconciler) reconcileIngressKubernetes(ctx context.Context, i
func (r *RayClusterReconciler) reconcileHeadService(ctx context.Context, instance *rayv1.RayCluster) error {
logger := ctrl.LoggerFrom(ctx)
services := corev1.ServiceList{}
filterLabels := client.MatchingLabels{utils.RayClusterLabelKey: instance.Name, utils.RayNodeTypeLabelKey: string(rayv1.HeadNode)}
filterLabels := common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
filterLabels := common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()
filterLabels := common.RayClusterHeadServiceListOptions(instance).ToListOptions()

@@ -286,9 +286,9 @@ func (r *RayClusterReconciler) rayClusterReconcile(ctx context.Context, instance
}

// We can start the Redis cleanup process now because the head Pod has been terminated.
filterLabels := client.MatchingLabels{utils.RayClusterLabelKey: instance.Name, utils.RayNodeTypeLabelKey: string(rayv1.RedisCleanupNode)}
filterLabels := common.RayClusterRedisPodsAssociationOptions(instance).ToListOptions()
Copy link
Member

Choose a reason for hiding this comment

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

  1. It is used to associate a K8s Job instead of Pod.
  2. It is not a Redis Pod.

Please rename to RayClusterRedisCleanupJobAssociationOptions

@@ -481,8 +481,8 @@ func (r *RayClusterReconciler) reconcileIngress(ctx context.Context, instance *r
func (r *RayClusterReconciler) reconcileRouteOpenShift(ctx context.Context, instance *rayv1.RayCluster) error {
logger := ctrl.LoggerFrom(ctx)
headRoutes := routev1.RouteList{}
filterLabels := client.MatchingLabels{utils.RayClusterLabelKey: instance.Name}
if err := r.List(ctx, &headRoutes, client.InNamespace(instance.Namespace), filterLabels); err != nil {
filterLabels := common.RayClusterAllPodsAssociationOptions(instance).ToListOptions()
Copy link
Member

Choose a reason for hiding this comment

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

It's misleading to use RayClusterAllPodsAssociationOptions to associate K8s ingress / route. Please create a new function RayClusterNetworkResourcesOptions for both ingress and route instead.

@owenowenisme owenowenisme force-pushed the move-matchingLabels-to-association.go branch from 4fa5f6a to 1c1c6b7 Compare January 15, 2025 03:09
@@ -194,3 +194,12 @@ func GetRayClusterHeadPod(ctx context.Context, reader client.Reader, instance *r
}
return &runtimePods.Items[0], nil
}

func RayClusterNetworkResourcesOptions(instance *rayv1.RayCluster) AssociationOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the new function is created, please add a test for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] Move MatchingLabels to association.go [2/N]
3 participants