diff --git a/docs/reference/api.md b/docs/reference/api.md index 6ae199a930..5d0a2ed062 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -212,7 +212,7 @@ _Appears in:_ | `upgradeStrategy` _[RayServiceUpgradeStrategy](#rayserviceupgradestrategy)_ | UpgradeStrategy represents the strategy used when upgrading the RayService. Currently supports `NewCluster` and `None` | | | | `serveConfigV2` _string_ | Important: Run "make" to regenerate code after modifying this file
Defines the applications and deployments to deploy, should be a YAML multi-line scalar string. | | | | `rayClusterConfig` _[RayClusterSpec](#rayclusterspec)_ | | | | -| `excludeHeadPodFromServeSvc` _boolean_ | If the field is set to true, the value of the label `ray.io/serve` on the head Pod should always be false. | | | +| `excludeHeadPodFromServeSvc` _boolean_ | If the field is set to true, the value of the label `ray.io/serve` on the head Pod should always be false.
Therefore, the head Pod's endpoint will not be added to the Kubernetes Serve service. | | | diff --git a/ray-operator/apis/ray/v1/rayservice_types.go b/ray-operator/apis/ray/v1/rayservice_types.go index eeb3039972..b81d9cbc8d 100644 --- a/ray-operator/apis/ray/v1/rayservice_types.go +++ b/ray-operator/apis/ray/v1/rayservice_types.go @@ -73,6 +73,7 @@ type RayServiceSpec struct { ServeConfigV2 string `json:"serveConfigV2,omitempty"` RayClusterSpec RayClusterSpec `json:"rayClusterConfig,omitempty"` // If the field is set to true, the value of the label `ray.io/serve` on the head Pod should always be false. + // Therefore, the head Pod's endpoint will not be added to the Kubernetes Serve service. ExcludeHeadPodFromServeSvc bool `json:"excludeHeadPodFromServeSvc,omitempty"` } diff --git a/ray-operator/controllers/ray/rayservice_controller_unit_test.go b/ray-operator/controllers/ray/rayservice_controller_unit_test.go index c27e79a8de..44b234bd80 100644 --- a/ray-operator/controllers/ray/rayservice_controller_unit_test.go +++ b/ray-operator/controllers/ray/rayservice_controller_unit_test.go @@ -921,18 +921,11 @@ func initFakeDashboardClient(appName string, deploymentStatus string, appStatus return &fakeDashboardClient } -type FakeRayHttpProxyClient struct { - isHealthy bool -} - -func (*FakeRayHttpProxyClient) InitClient() {} -func (f *FakeRayHttpProxyClient) CheckProxyActorHealth(_ context.Context) error { - if f.isHealthy { - return nil +func initFakeRayHttpProxyClient(isHealthy bool) utils.RayHttpProxyClientInterface { + return &utils.FakeRayHttpProxyClient{ + IsHealthy: isHealthy, } - return fmt.Errorf("the proxy actor is unhealthy") } -func (*FakeRayHttpProxyClient) SetHostIp(_, _, _ string, _ int) {} func TestLabelHeadPodForServeStatus(t *testing.T) { tests := map[string]struct { @@ -995,15 +988,15 @@ func TestLabelHeadPodForServeStatus(t *testing.T) { runtimeObjects := []runtime.Object{headPod} fakeClient := clientFake.NewClientBuilder().WithScheme(newScheme).WithRuntimeObjects(runtimeObjects...).Build() ctx := context.TODO() + + fakeRayHttpProxyClient := initFakeRayHttpProxyClient(tc.isHealthy) // Initialize RayService reconciler. r := &RayServiceReconciler{ Client: fakeClient, Recorder: &record.FakeRecorder{}, Scheme: newScheme, httpProxyClientFunc: func() utils.RayHttpProxyClientInterface { - return &FakeRayHttpProxyClient{ - isHealthy: tc.isHealthy, - } + return fakeRayHttpProxyClient }, } diff --git a/ray-operator/controllers/ray/utils/fake_httpproxy_httpclient.go b/ray-operator/controllers/ray/utils/fake_httpproxy_httpclient.go index 6529f9cf35..ccd0f99bda 100644 --- a/ray-operator/controllers/ray/utils/fake_httpproxy_httpclient.go +++ b/ray-operator/controllers/ray/utils/fake_httpproxy_httpclient.go @@ -3,27 +3,19 @@ package utils import ( "context" "fmt" - "net/http" - "time" ) type FakeRayHttpProxyClient struct { - client http.Client - httpProxyURL string + IsHealthy bool } -func (r *FakeRayHttpProxyClient) InitClient() { - r.client = http.Client{ - Timeout: 20 * time.Millisecond, - } -} +func (fc *FakeRayHttpProxyClient) InitClient() {} -func (r *FakeRayHttpProxyClient) SetHostIp(hostIp, _, _ string, port int) { - r.httpProxyURL = fmt.Sprintf("http://%s:%d", hostIp, port) -} +func (fc *FakeRayHttpProxyClient) SetHostIp(_, _, _ string, _ int) {} -func (r *FakeRayHttpProxyClient) CheckProxyActorHealth(_ context.Context) error { - // TODO: test check return error cases. - // Always return successful. +func (fc *FakeRayHttpProxyClient) CheckProxyActorHealth(_ context.Context) error { + if !fc.IsHealthy { + return fmt.Errorf("fake proxy actor is not healthy") + } return nil }