Files
Nary YehandGitHub 536ca35690 [Feature][APIServer v2] Support Compute Template in APIServer v2 (#3959)
* feat: extract compute template from spec

Signed-off-by: machichima <[email protected]>

* feat: add compute template middleware

Signed-off-by: machichima <[email protected]>

* fix: extract cluster spec from request correctly

Signed-off-by: machichima <[email protected]>

* feat: convert request to map then to clusterSpec

Signed-off-by: machichima <[email protected]>

* feat: parse anno/cpu/mem from compute template to request

Signed-off-by: machichima <[email protected]>

* fix: get compute template name without converting to ClusterSpec struct

Signed-off-by: machichima <[email protected]>

* feat: apply gpu/extend/toleration

Signed-off-by: machichima <[email protected]>

* feat: forward modified request body

Signed-off-by: machichima <[email protected]>

* feat: deal with case with no head/workerGroupSpec set

Signed-off-by: machichima <[email protected]>

* feat: also support for rayjob and rayservice

Signed-off-by: machichima <[email protected]>

* test: structure for test compute template middleware

Just a structure, test does not work now

Signed-off-by: machichima <[email protected]>

* fix: update field and match types

Signed-off-by: machichima <[email protected]>

* feat: use remote execute for apiserver sdk e2e test

Signed-off-by: machichima <[email protected]>

* feat: pass through if no spec & convert to json

Signed-off-by: machichima <[email protected]>

* feat: check request body type for unmarshal

Signed-off-by: machichima <[email protected]>

* test: enable setitng content type in execCommandWithCurlInPod

* Trigger CI

Signed-off-by: machichima <[email protected]>

* fix: extract client manager for mocking

* Trigger CI

Signed-off-by: machichima <[email protected]>

* fix: add missing methods & clean up code

* refactor: clean up print

* build: go mod tidy

* Trigger CI

Signed-off-by: machichima <[email protected]>

* Trigger CI

Signed-off-by: machichima <[email protected]>

* refactor: remove unused args

* refactor: interface to any

* refactor: remove redundant else block

* refactor: status code 500 to 422

* feat: support memory unit

* fix: use ProxyRoundTripper is apiserver client & remove remote execute client

* fix: base url use kubernetesConfig.Host

---------

Signed-off-by: machichima <[email protected]>
2025-09-28 20:42:33 +08:00

54 lines
1.7 KiB
Go

package apiserversdk
import (
"testing"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
)
func TestGetRayClusterProxy(t *testing.T) {
tCtx, err := NewEnd2EndTestingContext(t)
require.NoError(t, err, "No error expected when creating testing context")
rayClient := tCtx.GetRayHttpClient()
rayCluster := &rayv1.RayCluster{
ObjectMeta: metav1.ObjectMeta{
Name: tCtx.GetRayClusterName(),
Namespace: tCtx.GetNamespaceName(),
},
Spec: rayv1.RayClusterSpec{
HeadGroupSpec: rayv1.HeadGroupSpec{
RayStartParams: map[string]string{},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "ray-head",
Image: tCtx.GetRayImage(),
},
},
},
},
},
},
}
_, err = rayClient.RayClusters(tCtx.GetNamespaceName()).Create(tCtx.GetCtx(), rayCluster, metav1.CreateOptions{})
require.NoError(t, err)
// Wait for the Ray cluster's head pod to be ready so that we can access the dashboard
waitForClusterConditions(t, tCtx, tCtx.GetRayClusterName(), []rayv1.RayClusterConditionType{rayv1.HeadPodReady})
k8sClient := tCtx.GetK8sClient()
serviceName := tCtx.GetRayClusterName() + "-head-svc"
r := k8sClient.CoreV1().Services(tCtx.GetNamespaceName()).ProxyGet("http", serviceName, "8265", "", nil)
resp, err := r.DoRaw(tCtx.GetCtx())
require.NoError(t, err)
require.Contains(t, string(resp), "Ray Dashboard")
err = rayClient.RayClusters(tCtx.GetNamespaceName()).Delete(tCtx.GetCtx(), tCtx.GetRayClusterName(), metav1.DeleteOptions{})
require.NoError(t, err)
}