-
Notifications
You must be signed in to change notification settings - Fork 630
[Feature][APIServer v2] Support Compute Template in APIServer v2 #3959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rueian
merged 37 commits into
ray-project:master
from
machichima:apiserver-v2-compute-template
Sep 28, 2025
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
cb6f1ea
feat: extract compute template from spec
machichima 2edd8f0
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima 7dd5a70
feat: add compute template middleware
machichima 7106c01
fix: extract cluster spec from request correctly
machichima 7cc1d4e
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima 4417877
feat: convert request to map then to clusterSpec
machichima c8a8f78
feat: parse anno/cpu/mem from compute template to request
machichima 3dc557c
fix: get compute template name without converting to ClusterSpec struct
machichima c4fc102
feat: apply gpu/extend/toleration
machichima fa7eae8
feat: forward modified request body
machichima 0f05fed
feat: deal with case with no head/workerGroupSpec set
machichima ce17d2e
feat: also support for rayjob and rayservice
machichima 1f8db4c
test: structure for test compute template middleware
machichima 062d602
fix: update field and match types
machichima d6e2cb5
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima abeaa5d
feat: use remote execute for apiserver sdk e2e test
machichima b17b879
feat: pass through if no spec & convert to json
machichima 740e8f4
feat: check request body type for unmarshal
machichima 20efd19
test: enable setitng content type in execCommandWithCurlInPod
machichima b796540
Trigger CI
machichima 7695daf
fix: extract client manager for mocking
machichima 39e8919
Trigger CI
machichima 9c418f5
fix: add missing methods & clean up code
machichima 0af361e
refactor: clean up print
machichima 44213ea
build: go mod tidy
machichima 4ba14e2
Trigger CI
machichima f772cd5
Trigger CI
machichima edc99ad
refactor: remove unused args
machichima 8ad0573
refactor: interface to any
machichima 559f2ae
refactor: remove redundant else block
machichima 65bbc6a
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima 967c314
refactor: status code 500 to 422
machichima b56867d
feat: support memory unit
machichima d9a9e2c
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima bee12d0
Merge branch 'master' of github.com:ray-project/kuberay into apiserve…
machichima 9561d29
fix: use ProxyRoundTripper is apiserver client & remove remote execut…
machichima f4df39c
fix: base url use kubernetesConfig.Host
machichima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ func (r *ResourceManager) getKubernetesNamespaceClient() clientv1.NamespaceInter | |
// clusters | ||
func (r *ResourceManager) CreateCluster(ctx context.Context, apiCluster *api.Cluster) (*rayv1api.RayCluster, error) { | ||
// populate cluster map | ||
computeTemplateDict, err := r.populateComputeTemplate(ctx, apiCluster.ClusterSpec, apiCluster.Namespace) | ||
computeTemplateDict, err := r.PopulateComputeTemplate(ctx, apiCluster.ClusterSpec, apiCluster.Namespace) | ||
if err != nil { | ||
return nil, util.NewInternalServerError(err, "Failed to populate compute template for (%s/%s)", apiCluster.Namespace, apiCluster.Name) | ||
} | ||
|
@@ -82,13 +82,13 @@ func (r *ResourceManager) CreateCluster(ctx context.Context, apiCluster *api.Clu | |
} | ||
|
||
// Compute template | ||
func (r *ResourceManager) populateComputeTemplate(ctx context.Context, clusterSpec *api.ClusterSpec, nameSpace string) (map[string]*api.ComputeTemplate, error) { | ||
func (r *ResourceManager) PopulateComputeTemplate(ctx context.Context, clusterSpec *api.ClusterSpec, nameSpace string) (map[string]*api.ComputeTemplate, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this public so that we can use in |
||
dict := map[string]*api.ComputeTemplate{} | ||
// populate head compute template | ||
name := clusterSpec.HeadGroupSpec.ComputeTemplate | ||
configMap, err := r.GetComputeTemplate(ctx, name, nameSpace) | ||
if err != nil { | ||
return nil, err | ||
return nil, fmt.Errorf("Cannot get compute template for name '%s' in namespace '%s', error: %w", name, nameSpace, err) | ||
} | ||
computeTemplate := model.FromKubeToAPIComputeTemplate(configMap) | ||
dict[name] = computeTemplate | ||
|
@@ -99,7 +99,7 @@ func (r *ResourceManager) populateComputeTemplate(ctx context.Context, clusterSp | |
if _, exist := dict[name]; !exist { | ||
configMap, err := r.GetComputeTemplate(ctx, name, nameSpace) | ||
if err != nil { | ||
return nil, err | ||
return nil, fmt.Errorf("Cannot get compute template for name '%s' in namespace '%s', error: %w", name, nameSpace, err) | ||
} | ||
computeTemplate := model.FromKubeToAPIComputeTemplate(configMap) | ||
dict[name] = computeTemplate | ||
|
@@ -160,7 +160,7 @@ func (r *ResourceManager) CreateJob(ctx context.Context, apiJob *api.RayJob) (*r | |
|
||
// populate cluster map | ||
if apiJob.ClusterSpec != nil { | ||
computeTemplateMap, err = r.populateComputeTemplate(ctx, apiJob.ClusterSpec, apiJob.Namespace) | ||
computeTemplateMap, err = r.PopulateComputeTemplate(ctx, apiJob.ClusterSpec, apiJob.Namespace) | ||
if err != nil { | ||
return nil, util.NewInternalServerError(err, "Failed to populate compute template for (%s/%s)", apiJob.Namespace, apiJob.JobId) | ||
} | ||
|
@@ -227,7 +227,7 @@ func (r *ResourceManager) DeleteJob(ctx context.Context, jobName string, namespa | |
|
||
func (r *ResourceManager) CreateService(ctx context.Context, apiService *api.RayService) (*rayv1api.RayService, error) { | ||
// populate cluster map | ||
computeTemplateDict, err := r.populateComputeTemplate(ctx, apiService.ClusterSpec, apiService.Namespace) | ||
computeTemplateDict, err := r.PopulateComputeTemplate(ctx, apiService.ClusterSpec, apiService.Namespace) | ||
if err != nil { | ||
return nil, util.NewInternalServerError(err, "Failed to populate compute template for (%s/%s)", apiService.Namespace, apiService.Name) | ||
} | ||
|
@@ -254,7 +254,7 @@ func (r *ResourceManager) UpdateRayService(ctx context.Context, apiService *api. | |
return nil, util.Wrap(err, fmt.Sprintf("Update service fail, no service named: %s ", name)) | ||
} | ||
// populate cluster map | ||
computeTemplateDict, err := r.populateComputeTemplate(ctx, apiService.ClusterSpec, apiService.Namespace) | ||
computeTemplateDict, err := r.PopulateComputeTemplate(ctx, apiService.ClusterSpec, apiService.Namespace) | ||
if err != nil { | ||
return nil, util.NewInternalServerError(err, "Failed to populate compute template for (%s/%s)", apiService.Namespace, apiService.Name) | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this public so that we can use in
apiserversdk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@machichima, can we revert this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need this to be public as we will use it in:
https://github.com/ray-project/kuberay/pull/3959/files#diff-5427afc42b84a19b5dc31e6751e58900f883eb8391e1839b790ff9a85e336b7cR273