Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
evalaiyc98 committed Apr 23, 2024
1 parent d75588e commit 0d06e3f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ray-operator/controllers/ray/common/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (list AssociationOptions) ToDeleteOptions() (options []client.DeleteAllOfOp
return options
}

func RayClusterHeadPodsRelatedAssociationOptions(instance *rayv1.RayCluster) AssociationOptions {
func RayClusterHeadPodsAssociationOptions(instance *rayv1.RayCluster) AssociationOptions {
return AssociationOptions{
client.InNamespace(instance.Namespace),
client.MatchingLabels{
Expand Down
14 changes: 7 additions & 7 deletions ray-operator/controllers/ray/raycluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (r *RayClusterReconciler) rayClusterReconcile(ctx context.Context, request
"DeletionTimestamp", instance.ObjectMeta.DeletionTimestamp)

// Delete the head Pod if it exists.
headPods, err := r.deleteAllPods(ctx, common.RayClusterHeadPodsRelatedAssociationOptions(instance))
headPods, err := r.deleteAllPods(ctx, common.RayClusterHeadPodsAssociationOptions(instance))
if err != nil {
return ctrl.Result{RequeueAfter: DefaultRequeueDuration}, err
}
Expand Down Expand Up @@ -504,7 +504,7 @@ func (r *RayClusterReconciler) reconcileHeadService(ctx context.Context, instanc
logger := ctrl.LoggerFrom(ctx)
services := corev1.ServiceList{}

if err := r.List(ctx, &services, common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions()...); err != nil {
if err := r.List(ctx, &services, common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()...); err != nil {
return err
}

Expand Down Expand Up @@ -633,7 +633,7 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv

// check if all the pods exist
headPods := corev1.PodList{}
if err := r.List(ctx, &headPods, common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions()...); err != nil {
if err := r.List(ctx, &headPods, common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()...); err != nil {
return err
}
if EnableBatchScheduler {
Expand Down Expand Up @@ -1292,12 +1292,12 @@ func (r *RayClusterReconciler) getHeadPodIP(ctx context.Context, instance *rayv1
logger := ctrl.LoggerFrom(ctx)

runtimePods := corev1.PodList{}
if err := r.List(ctx, &runtimePods, common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions()...); err != nil {
if err := r.List(ctx, &runtimePods, common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()...); err != nil {
logger.Error(err, "Failed to list pods while getting head pod ip.")
return "", err
}
if len(runtimePods.Items) != 1 {
logger.Info(fmt.Sprintf("Found %d head pods. cluster name %s, filter labels %v", len(runtimePods.Items), instance.Name, common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions()))
logger.Info(fmt.Sprintf("Found %d head pods. cluster name %s, filter labels %v", len(runtimePods.Items), instance.Name, common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()))
return "", nil
}
return runtimePods.Items[0].Status.PodIP, nil
Expand Down Expand Up @@ -1325,7 +1325,7 @@ func (r *RayClusterReconciler) updateEndpoints(ctx context.Context, instance *ra
// We assume we can find the right one by filtering Services with appropriate label selectors
// and picking the first one. We may need to select by name in the future if the Service naming is stable.
rayHeadSvc := corev1.ServiceList{}
if err := r.List(ctx, &rayHeadSvc, common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions()...); err != nil {
if err := r.List(ctx, &rayHeadSvc, common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions()...); err != nil {
return err
}

Expand All @@ -1350,7 +1350,7 @@ func (r *RayClusterReconciler) updateEndpoints(ctx context.Context, instance *ra
}
}
} else {
logger.Info("updateEndpoints", "unable to find a Service for this RayCluster. Not adding RayCluster status.endpoints", instance.Name, "Service selectors", common.RayClusterHeadPodsRelatedAssociationOptions(instance).ToListOptions())
logger.Info("updateEndpoints", "unable to find a Service for this RayCluster. Not adding RayCluster status.endpoints", instance.Name, "Service selectors", common.RayClusterHeadPodsAssociationOptions(instance).ToListOptions())
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions ray-operator/controllers/ray/raycluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Context("Inside the default namespace", func() {
headPods := corev1.PodList{}
workerPods := corev1.PodList{}
workerFilters := common.RayClusterGroupPodsAssociationOptions(rayCluster, rayCluster.Spec.WorkerGroupSpecs[0].GroupName).ToListOptions()
headFilters := common.RayClusterHeadPodsRelatedAssociationOptions(rayCluster).ToListOptions()
headFilters := common.RayClusterHeadPodsAssociationOptions(rayCluster).ToListOptions()

It("Verify RayCluster spec", func() {
// These test are designed based on the following assumptions:
Expand Down Expand Up @@ -318,7 +318,7 @@ var _ = Context("Inside the default namespace", func() {
workerPods := corev1.PodList{}
allPods := corev1.PodList{}
workerFilters := common.RayClusterGroupPodsAssociationOptions(rayCluster, rayCluster.Spec.WorkerGroupSpecs[0].GroupName).ToListOptions()
headFilters := common.RayClusterHeadPodsRelatedAssociationOptions(rayCluster).ToListOptions()
headFilters := common.RayClusterHeadPodsAssociationOptions(rayCluster).ToListOptions()
allFilters := common.RayClusterRelatedAssociationOptions(rayCluster).ToListOptions()

It("Verify RayCluster spec", func() {
Expand Down Expand Up @@ -573,7 +573,7 @@ var _ = Context("Inside the default namespace", func() {
headPods := corev1.PodList{}
workerPods := corev1.PodList{}
workerFilters := common.RayClusterGroupPodsAssociationOptions(rayCluster, rayCluster.Spec.WorkerGroupSpecs[0].GroupName).ToListOptions()
headFilters := common.RayClusterHeadPodsRelatedAssociationOptions(rayCluster).ToListOptions()
headFilters := common.RayClusterHeadPodsAssociationOptions(rayCluster).ToListOptions()

It("Create a RayCluster with PodTemplate referencing a different namespace.", func() {
rayCluster.Spec.HeadGroupSpec.Template.ObjectMeta.Namespace = "not-default"
Expand Down
2 changes: 1 addition & 1 deletion ray-operator/controllers/ray/suite_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func updateHeadPodToRunningAndReady(ctx context.Context, rayClusterName string,
time.Second*3, time.Millisecond*500).Should(gomega.BeNil(), "RayCluster %v not found", rayClusterName)

headPods := corev1.PodList{}
headLabels := common.RayClusterHeadPodsRelatedAssociationOptions(&instance).ToListOptions()
headLabels := common.RayClusterHeadPodsAssociationOptions(&instance).ToListOptions()

gomega.Eventually(
listResourceFunc(ctx, &headPods, headLabels...),
Expand Down

0 comments on commit 0d06e3f

Please sign in to comment.