Skip to content

Commit

Permalink
Updated to v1 endponts
Browse files Browse the repository at this point in the history
Fixed failing tests
  • Loading branch information
z103cb committed Oct 31, 2023
1 parent a874d66 commit 6c8cc28
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
44 changes: 22 additions & 22 deletions apiserver/pkg/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewKuberayAPIServerClient(baseURL string, httpClient *http.Client) *Kuberay

// CreateComputeTemplate creates a new compute template.
func (krc *KuberayAPIServerClient) CreateComputeTemplate(request *api.CreateComputeTemplateRequest) (*api.ComputeTemplate, *rpcStatus.Status, error) {
createURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/compute_templates"
createURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/compute_templates"

bytez, err := krc.marshaler.Marshal(request.ComputeTemplate)
if err != nil {
Expand Down Expand Up @@ -89,13 +89,13 @@ func (krc *KuberayAPIServerClient) CreateComputeTemplate(request *api.CreateComp

// DeleteComputeTemplate deletes a compute template.
func (krc *KuberayAPIServerClient) DeleteComputeTemplate(request *api.DeleteComputeTemplateRequest) (*rpcStatus.Status, error) {
deleteURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/compute_templates/" + request.Name
deleteURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/compute_templates/" + request.Name
return krc.doDelete(deleteURL)
}

// Finds a specific compute template by its name and namespace.
func (krc *KuberayAPIServerClient) GetComputeTemplate(request *api.GetComputeTemplateRequest) (*api.ComputeTemplate, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/compute_templates/" + request.Name
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/compute_templates/" + request.Name
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -116,7 +116,7 @@ func (krc *KuberayAPIServerClient) GetComputeTemplate(request *api.GetComputeTem

// GetAllComputeTemplates finds all compute templates in all namespaces.
func (krc *KuberayAPIServerClient) GetAllComputeTemplates() (*api.ListAllComputeTemplatesResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/compute_templates"
getURL := krc.baseURL + "/apis/v1/compute_templates"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -137,7 +137,7 @@ func (krc *KuberayAPIServerClient) GetAllComputeTemplates() (*api.ListAllCompute

// GetAllComputeTemplatesInNamespace Finds all compute templates in a given namespace.
func (krc *KuberayAPIServerClient) GetAllComputeTemplatesInNamespace(request *api.ListComputeTemplatesRequest) (*api.ListComputeTemplatesResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/compute_templates"
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/compute_templates"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -158,7 +158,7 @@ func (krc *KuberayAPIServerClient) GetAllComputeTemplatesInNamespace(request *ap

// CreateCluster creates a new cluster.
func (krc *KuberayAPIServerClient) CreateCluster(request *api.CreateClusterRequest) (*api.Cluster, *rpcStatus.Status, error) {
createURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/clusters"
createURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/clusters"

bytez, err := krc.marshaler.Marshal(request.Cluster)
if err != nil {
Expand Down Expand Up @@ -186,13 +186,13 @@ func (krc *KuberayAPIServerClient) CreateCluster(request *api.CreateClusterReque

// DeleteCluster deletes a cluster
func (krc *KuberayAPIServerClient) DeleteCluster(request *api.DeleteClusterRequest) (*rpcStatus.Status, error) {
deleteURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/clusters/" + request.Name
deleteURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/clusters/" + request.Name
return krc.doDelete(deleteURL)
}

// GetCluster finds a specific Cluster by ID.
func (krc *KuberayAPIServerClient) GetCluster(request *api.GetClusterRequest) (*api.Cluster, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/clusters/" + request.Name
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/clusters/" + request.Name
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -213,7 +213,7 @@ func (krc *KuberayAPIServerClient) GetCluster(request *api.GetClusterRequest) (*

// ListCluster finds all clusters in a given namespace.
func (krc *KuberayAPIServerClient) ListClusters(request *api.ListClustersRequest) (*api.ListClustersResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/clusters"
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/clusters"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -234,7 +234,7 @@ func (krc *KuberayAPIServerClient) ListClusters(request *api.ListClustersRequest

// ListAllClusters finds all Clusters in all namespaces. Supports pagination, and sorting on certain fields.
func (krc *KuberayAPIServerClient) ListAllClusters() (*api.ListAllClustersResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/clusters"
getURL := krc.baseURL + "/apis/v1/clusters"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -255,7 +255,7 @@ func (krc *KuberayAPIServerClient) ListAllClusters() (*api.ListAllClustersRespon

// CreateRayJob creates a new job.
func (krc *KuberayAPIServerClient) CreateRayJob(request *api.CreateRayJobRequest) (*api.RayJob, *rpcStatus.Status, error) {
createURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/jobs"
createURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/jobs"
bytez, err := krc.marshaler.Marshal(request.Job)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal api.Cluster to JSON: %w", err)
Expand All @@ -282,7 +282,7 @@ func (krc *KuberayAPIServerClient) CreateRayJob(request *api.CreateRayJobRequest

// GetRayJob finds a specific job by its name and namespace.
func (krc *KuberayAPIServerClient) GetRayJob(request *api.GetRayJobRequest) (*api.RayJob, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/jobs/" + request.Name
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/jobs/" + request.Name
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -303,7 +303,7 @@ func (krc *KuberayAPIServerClient) GetRayJob(request *api.GetRayJobRequest) (*ap

// Finds all job in a given namespace.
func (krc *KuberayAPIServerClient) ListRayJobs(request *api.ListRayJobsRequest) (*api.ListRayJobsResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/jobs"
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/jobs"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -324,7 +324,7 @@ func (krc *KuberayAPIServerClient) ListRayJobs(request *api.ListRayJobsRequest)

// ListAllRayJobs Finds all job in all namespaces.
func (krc *KuberayAPIServerClient) ListAllRayJobs() (*api.ListAllRayJobsResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/jobs"
getURL := krc.baseURL + "/apis/v1/jobs"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -345,13 +345,13 @@ func (krc *KuberayAPIServerClient) ListAllRayJobs() (*api.ListAllRayJobsResponse

// Deletes a job by its name and namespace.
func (krc *KuberayAPIServerClient) DeleteRayJob(request *api.DeleteRayJobRequest) (*rpcStatus.Status, error) {
deleteURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/jobs/" + request.Name
deleteURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/jobs/" + request.Name
return krc.doDelete(deleteURL)
}

// CreateRayService create a new ray serve.
func (krc *KuberayAPIServerClient) CreateRayService(request *api.CreateRayServiceRequest) (*api.RayService, *rpcStatus.Status, error) {
createURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services"
createURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services"
bytez, err := krc.marshaler.Marshal(request.Service)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal api.Cluster to JSON: %w", err)
Expand All @@ -378,7 +378,7 @@ func (krc *KuberayAPIServerClient) CreateRayService(request *api.CreateRayServic

// UpdateRayService updates a ray serve service.
func (krc *KuberayAPIServerClient) UpdateRayService(request *api.UpdateRayServiceRequest) (*api.RayService, *rpcStatus.Status, error) {
updateURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services/" + request.Name
updateURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services/" + request.Name
bytez, err := krc.marshaler.Marshal(request.Service)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal api.Cluster to JSON: %w", err)
Expand Down Expand Up @@ -407,7 +407,7 @@ func (krc *KuberayAPIServerClient) UpdateRayService(request *api.UpdateRayServic
// Patch mode update without possible deletion the existing raycluster under the hood.
// only support update the service configs and worker.
func (krc *KuberayAPIServerClient) UpdateRayServiceConfigs(request *api.UpdateRayServiceConfigsRequest) (*api.RayService, *rpcStatus.Status, error) {
updateURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services/" + request.Name + "/configs"
updateURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services/" + request.Name + "/configs"
bytez, err := krc.marshaler.Marshal(request.UpdateService)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal api.Cluster to JSON: %w", err)
Expand All @@ -434,7 +434,7 @@ func (krc *KuberayAPIServerClient) UpdateRayServiceConfigs(request *api.UpdateRa

// Find a specific ray serve by name and namespace.
func (krc *KuberayAPIServerClient) GetRayService(request *api.GetRayServiceRequest) (*api.RayService, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services/" + request.Name
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services/" + request.Name
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -455,7 +455,7 @@ func (krc *KuberayAPIServerClient) GetRayService(request *api.GetRayServiceReque

// Finds all ray services in a given namespace. Supports pagination, and sorting on certain fields.
func (krc *KuberayAPIServerClient) ListRayServices(request *api.ListRayServicesRequest) (*api.ListRayServicesResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services"
getURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -476,7 +476,7 @@ func (krc *KuberayAPIServerClient) ListRayServices(request *api.ListRayServicesR

// Finds all ray services in a given namespace. Supports pagination, and sorting on certain fields.
func (krc *KuberayAPIServerClient) ListAllRayServices() (*api.ListAllRayServicesResponse, *rpcStatus.Status, error) {
getURL := krc.baseURL + "/apis/v1alpha2/services"
getURL := krc.baseURL + "/apis/v1/services"
httpRequest, err := krc.createHttpRequest("GET", getURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to create http request for url '%s': %w", getURL, err)
Expand All @@ -497,7 +497,7 @@ func (krc *KuberayAPIServerClient) ListAllRayServices() (*api.ListAllRayServices

// DeleteRayService deletes a ray service by its name and namespace
func (krc *KuberayAPIServerClient) DeleteRayService(request *api.DeleteRayServiceRequest) (*rpcStatus.Status, error) {
deleteURL := krc.baseURL + "/apis/v1alpha2/namespaces/" + request.Namespace + "/services/" + request.Name
deleteURL := krc.baseURL + "/apis/v1/namespaces/" + request.Namespace + "/services/" + request.Name
return krc.doDelete(deleteURL)
}

Expand Down
6 changes: 2 additions & 4 deletions apiserver/test/e2e/service_server_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ func TestServiceServerV1Update(t *testing.T) {
require.Nil(t, actualRpcStatus, "No RPC status expected")
require.NotNil(t, actualService, "A service is expected")
waitForRunningService(t, tCtx, actualService.Name)
tCtx.DeleteRayService(t, actualService.Name)
} else {
require.EqualError(t, err, tc.ExpectedError.Error(), "Matching error expected")
require.NotNil(t, actualRpcStatus, "A not nill RPC status is required")
Expand Down Expand Up @@ -743,9 +742,8 @@ func TestServiceServerV1Patch(t *testing.T) {
require.NoError(t, err, "No error expected")
require.Nil(t, actualRpcStatus, "No RPC status expected")
require.NotNil(t, actualService, "A service is expected")
waitForRunningServiceWithWorkGroupSpec(t, tCtx, actualService.Name, tc.Input.UpdateService.WorkerGroupUpdateSpec[0].Replicas,
tc.Input.UpdateService.WorkerGroupUpdateSpec[0].MinReplicas, tc.Input.UpdateService.WorkerGroupUpdateSpec[0].MaxReplicas)
tCtx.DeleteRayService(t, actualService.Name)
waitForRunningServiceWithWorkGroupSpec(t, tCtx, actualService.Name, tc.Input.UpdateService.WorkerGroupUpdateSpec[0].MinReplicas,
tc.Input.UpdateService.WorkerGroupUpdateSpec[0].MaxReplicas, tc.Input.UpdateService.WorkerGroupUpdateSpec[0].Replicas)
} else {
require.EqualError(t, err, tc.ExpectedError.Error(), "Matching error expected")
require.NotNil(t, actualRpcStatus, "A not nill RPC status is required")
Expand Down
8 changes: 4 additions & 4 deletions apiserver/test/e2e/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (e2etc *End2EndTestingContext) DeleteRayCluster(t *testing.T, clusterName s
Name: clusterName,
Namespace: e2etc.namespaceName,
})
require.NoErrorf(t, err, "No error expected when deleting ray cluster: '%s, err %v", clusterName, err)
require.NoErrorf(t, err, "No error expected when deleting ray cluster: '%s', err %v", clusterName, err)

// wait for the cluster to be deleted for 3 minutes
// if is not in that state, return an error
Expand All @@ -359,7 +359,7 @@ func (e2etc *End2EndTestingContext) DeleteRayService(t *testing.T, serviceName s
Namespace: e2etc.namespaceName,
})

require.NoErrorf(t, err, "No error expected when deleting ray job: '%s, err %v", serviceName, err)
require.NoErrorf(t, err, "No error expected when deleting ray service: '%s', err %v", serviceName, err)

// wait for the cluster to be deleted for 3 minutes
// if is not in that state, return an error
Expand All @@ -368,7 +368,7 @@ func (e2etc *End2EndTestingContext) DeleteRayService(t *testing.T, serviceName s
if err00 != nil && k8sApiErrors.IsNotFound(err00) {
return true, nil
}
t.Logf("Found job state of '%s' for ray cluster '%s'", rayService.Status.ServiceStatus, serviceName)
t.Logf("Found service state of '%s' for ray cluster '%s'", rayService.Status.ServiceStatus, serviceName)
return false, nil
})
require.NoErrorf(t, err, "No error expected when waiting to delete ray service: '%s', err %v", serviceName, err)
Expand All @@ -380,7 +380,7 @@ func (e2etc *End2EndTestingContext) DeleteRayJobByName(t *testing.T, rayJobName
Namespace: e2etc.namespaceName,
})

require.NoErrorf(t, err, "No error expected when deleting ray job: '%s, err %v", rayJobName, err)
require.NoErrorf(t, err, "No error expected when deleting ray job: '%s', err %v", rayJobName, err)

// wait for the cluster to be deleted for 3 minutes
// if is not in that state, return an error
Expand Down

0 comments on commit 6c8cc28

Please sign in to comment.