-
Notifications
You must be signed in to change notification settings - Fork 436
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
Move matching labels to association.go #2734
Conversation
f89cc2d
to
9e9031f
Compare
@rueian please take a look🙏🙏🙏 |
Hi @owenowenisme, I noticed that there are |
@@ -100,6 +100,16 @@ func RayClusterWorkerPodsAssociationOptions(instance *rayv1.RayCluster) Associat | |||
} | |||
} | |||
|
|||
func RayClusterRedisPodsAssociationOptions(instance *rayv1.RayCluster) AssociationOptions { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It is used to associate a K8s Job instead of Pod.
- 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() |
There was a problem hiding this comment.
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.
4fa5f6a
to
1c1c6b7
Compare
@@ -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 { |
There was a problem hiding this comment.
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.
72c369f
to
e570111
Compare
@@ -292,3 +293,77 @@ func TestGetRayClusterHeadPod(t *testing.T) { | |||
assert.Nil(t, err) | |||
assert.Equal(t, ret, headPod) | |||
} | |||
|
|||
func TestRayClusterRedisPodsAssociationOptions(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestRayClusterRedisPodsAssociationOptions(t *testing.T) { | |
func TestRayClusterRedisCleanupJobAssociationOptions(t *testing.T) { |
|
||
_ = &corev1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "redis-pod", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name: "redis-pod", | |
Name: "redis-cleanup", |
@rueian @kevin85421 |
rerun the test |
CI still fails. @owenowenisme could you rebase with the master branch? |
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
Signed-off-by: owenowenisme <[email protected]>
b36aea0
to
e8ddab1
Compare
@kevin85421 Only unrelated test failed is remaining. |
@@ -573,8 +572,8 @@ func (r *RayClusterReconciler) reconcileRouteOpenShift(ctx context.Context, inst | |||
func (r *RayClusterReconciler) reconcileIngressKubernetes(ctx context.Context, instance *rayv1.RayCluster) error { | |||
logger := ctrl.LoggerFrom(ctx) | |||
headIngresses := networkingv1.IngressList{} | |||
filterLabels := client.MatchingLabels{utils.RayClusterLabelKey: instance.Name} | |||
if err := r.List(ctx, &headIngresses, client.InNamespace(instance.Namespace), filterLabels); err != nil { | |||
filterLabels := common.RayClusterAllPodsAssociationOptions(instance).ToListOptions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filterLabels := common.RayClusterAllPodsAssociationOptions(instance).ToListOptions() | |
filterLabels := common.RayClusterNetworkResourcesOptions(instance).ToListOptions() |
utils.RayNodeTypeLabelKey: string(rayv1.RedisCleanupNode), | ||
}), | ||
} | ||
for k, v := range expected { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
Signed-off-by: owenowenisme <[email protected]>
@kevin85421 |
Why are these changes needed?
#2733
Related issue number
Closes #2733
Checks