From fe427c176394d4e1aa133ed20fe249e805025679 Mon Sep 17 00:00:00 2001 From: David Xia Date: Fri, 15 Jul 2022 19:54:28 -0400 Subject: [PATCH] fix controller: use Service's TargetPort instead of NodePort which is usually "0" for updating RayCluster's `status.endpoints`. follow up to #341 --- ray-operator/controllers/ray/raycluster_controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ray-operator/controllers/ray/raycluster_controller.go b/ray-operator/controllers/ray/raycluster_controller.go index ba7c86d4627..0aac200a65f 100644 --- a/ray-operator/controllers/ray/raycluster_controller.go +++ b/ray-operator/controllers/ray/raycluster_controller.go @@ -684,10 +684,16 @@ func (r *RayClusterReconciler) updateStatus(instance *rayiov1alpha1.RayCluster) } for _, port := range svc.Spec.Ports { if len(port.Name) == 0 { - r.Log.Info("updateStatus", "service port name is empty", port) + r.Log.Info("updateStatus", "service port's name is empty. Not adding it to RayCluster status.endpoints", port) continue } - instance.Status.Endpoints[port.Name] = fmt.Sprintf("%d", port.NodePort) + if port.TargetPort.IntVal != 0 { + instance.Status.Endpoints[port.Name] = fmt.Sprintf("%d", port.TargetPort.IntVal) + } else if port.TargetPort.StrVal != "" { + instance.Status.Endpoints[port.Name] = port.TargetPort.StrVal + } else { + r.Log.Info("updateStatus", "service port's targetPort is empty. Not adding it to RayCluster status.endpoints", port) + } } } timeNow := metav1.Now()