Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update
Browse files Browse the repository at this point in the history
kevin85421 committed Aug 15, 2023
1 parent 4892ac1 commit f0d4469
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ray-operator/controllers/ray/raycluster_controller.go
Original file line number Diff line number Diff line change
@@ -754,8 +754,8 @@ func (r *RayClusterReconciler) createWorkerPod(ctx context.Context, instance ray
// Build head instance pod(s).
func (r *RayClusterReconciler) buildHeadPod(instance rayv1alpha1.RayCluster) corev1.Pod {
podName := strings.ToLower(instance.Name + common.DashSymbol + string(rayv1alpha1.HeadNode) + common.DashSymbol)
podName = utils.CheckName(podName) // making sure the name is valid
fqdnRayIP := utils.GenerateFQDNServiceName(instance.Name, instance.Namespace) // Fully Qualified Domain Name
podName = utils.CheckName(podName) // making sure the name is valid
fqdnRayIP := utils.GenerateFQDNServiceName(instance, instance.Namespace) // Fully Qualified Domain Name
// The Ray head port used by workers to connect to the cluster (GCS server port for Ray >= 1.11.0, Redis port for older Ray.)
headPort := common.GetHeadPort(instance.Spec.HeadGroupSpec.RayStartParams)
autoscalingEnabled := instance.Spec.EnableInTreeAutoscaling
@@ -787,8 +787,8 @@ func getCreator(instance rayv1alpha1.RayCluster) string {
// Build worker instance pods.
func (r *RayClusterReconciler) buildWorkerPod(instance rayv1alpha1.RayCluster, worker rayv1alpha1.WorkerGroupSpec) corev1.Pod {
podName := strings.ToLower(instance.Name + common.DashSymbol + string(rayv1alpha1.WorkerNode) + common.DashSymbol + worker.GroupName + common.DashSymbol)
podName = utils.CheckName(podName) // making sure the name is valid
fqdnRayIP := utils.GenerateFQDNServiceName(instance.Name, instance.Namespace) // Fully Qualified Domain Name
podName = utils.CheckName(podName) // making sure the name is valid
fqdnRayIP := utils.GenerateFQDNServiceName(instance, instance.Namespace) // Fully Qualified Domain Name
// The Ray head port used by workers to connect to the cluster (GCS server port for Ray >= 1.11.0, Redis port for older Ray.)
headPort := common.GetHeadPort(instance.Spec.HeadGroupSpec.RayStartParams)
autoscalingEnabled := instance.Spec.EnableInTreeAutoscaling
3 changes: 3 additions & 0 deletions ray-operator/controllers/ray/utils/dashboard_httpclient.go
Original file line number Diff line number Diff line change
@@ -69,6 +69,9 @@ type RayDashboardClient struct {
func FetchHeadServiceURL(ctx context.Context, log *logr.Logger, cli client.Client, rayCluster *rayv1alpha1.RayCluster, defaultPortName string) (string, error) {
headSvc := &corev1.Service{}
headSvcName := GenerateServiceName(rayCluster.Name)
if rayCluster.Spec.HeadGroupSpec.HeadService != nil && rayCluster.Spec.HeadGroupSpec.HeadService.Name != "" {
headSvcName = rayCluster.Spec.HeadGroupSpec.HeadService.Name
}
if err := cli.Get(ctx, client.ObjectKey{Name: headSvcName, Namespace: rayCluster.Namespace}, headSvc); err != nil {
if errors.IsNotFound(err) {
log.Error(err, "Head service is not found", "head service name", headSvcName, "namespace", rayCluster.Namespace)
8 changes: 6 additions & 2 deletions ray-operator/controllers/ray/utils/util.go
Original file line number Diff line number Diff line change
@@ -135,8 +135,12 @@ func GenerateServiceName(clusterName string) string {
}

// GenerateFQDNServiceName generates a Fully Qualified Domain Name.
func GenerateFQDNServiceName(clusterName string, namespace string) string {
return fmt.Sprintf("%s.%s.svc.%s", GenerateServiceName(clusterName), namespace, GetClusterDomainName())
func GenerateFQDNServiceName(cluster rayv1alpha1.RayCluster, namespace string) string {
headSvcName := GenerateServiceName(cluster.Name)
if cluster.Spec.HeadGroupSpec.HeadService != nil && cluster.Spec.HeadGroupSpec.HeadService.Name != "" {
headSvcName = cluster.Spec.HeadGroupSpec.HeadService.Name
}
return fmt.Sprintf("%s.%s.svc.%s", headSvcName, namespace, GetClusterDomainName())
}

// ExtractRayIPFromFQDN extracts the head service name (i.e., RAY_IP, deprecated) from a fully qualified

0 comments on commit f0d4469

Please sign in to comment.