@@ -26,6 +26,7 @@ import (
26
26
"sigs.k8s.io/controller-runtime/pkg/manager"
27
27
28
28
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
29
+ "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils/dashboardclient"
29
30
)
30
31
31
32
const (
@@ -640,7 +641,7 @@ func EnvVarByName(envName string, envVars []corev1.EnvVar) (corev1.EnvVar, bool)
640
641
}
641
642
642
643
type ClientProvider interface {
643
- GetDashboardClient (mgr manager.Manager ) func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error )
644
+ GetDashboardClient (mgr manager.Manager ) func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient. RayDashboardClientInterface , error )
644
645
GetHttpProxyClient (mgr manager.Manager ) func (hostIp , podNamespace , podName string , port int ) RayHttpProxyClientInterface
645
646
}
646
647
@@ -757,8 +758,9 @@ func FetchHeadServiceURL(ctx context.Context, cli client.Client, rayCluster *ray
757
758
return headServiceURL , nil
758
759
}
759
760
760
- func GetRayDashboardClientFunc (mgr manager.Manager , useKubernetesProxy bool ) func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error ) {
761
- return func (rayCluster * rayv1.RayCluster , url string ) (RayDashboardClientInterface , error ) {
761
+ func GetRayDashboardClientFunc (mgr manager.Manager , useKubernetesProxy bool ) func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient.RayDashboardClientInterface , error ) {
762
+ return func (rayCluster * rayv1.RayCluster , url string ) (dashboardclient.RayDashboardClientInterface , error ) {
763
+ dashboardClient := & dashboardclient.RayDashboardClient {}
762
764
if useKubernetesProxy {
763
765
var err error
764
766
headSvcName := rayCluster .Status .Head .ServiceName
@@ -769,20 +771,20 @@ func GetRayDashboardClientFunc(mgr manager.Manager, useKubernetesProxy bool) fun
769
771
return nil , err
770
772
}
771
773
}
772
- return & RayDashboardClient {
774
+
775
+ dashboardClient .InitClient (
773
776
// Use `mgr.GetHTTPClient()` instead of `http.Client{}` so that the client has proper authentication
774
777
// configured to communicate with the Kubernetes API server.
775
- client : mgr .GetHTTPClient (),
776
- dashboardURL : fmt .Sprintf ("%s/api/v1/namespaces/%s/services/%s:dashboard/proxy" , mgr .GetConfig ().Host , rayCluster .Namespace , headSvcName ),
777
- }, nil
778
+ mgr .GetHTTPClient (),
779
+ fmt .Sprintf ("%s/api/v1/namespaces/%s/services/%s:dashboard/proxy" , mgr .GetConfig ().Host , rayCluster .Namespace , headSvcName ),
780
+ )
781
+ return dashboardClient , nil
778
782
}
779
783
780
- return & RayDashboardClient {
781
- client : & http.Client {
782
- Timeout : 2 * time .Second ,
783
- },
784
- dashboardURL : "http://" + url ,
785
- }, nil
784
+ dashboardClient .InitClient (& http.Client {
785
+ Timeout : 2 * time .Second ,
786
+ }, "http://" + url )
787
+ return dashboardClient , nil
786
788
}
787
789
}
788
790
0 commit comments