mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 05:36:50 +08:00
add resources requests and limits to nodePoolOptions
This commit is contained in:
@@ -104,6 +104,7 @@ func injectArtifactRepositoryConfig(artifact *wfv1.Artifact, namespaceConfig *Na
|
||||
}
|
||||
}
|
||||
|
||||
// injectNvidiaGPUFields adds GPU specific fields if there is a GPU request
|
||||
func injectNvidiaGPUFields(template *wfv1.Template, systemConfig SystemConfig) {
|
||||
limitsGPUCount := template.Container.Resources.Limits["nvidia.com/gpu"]
|
||||
requestsGPUCount := template.Container.Resources.Requests["nvidia.com/gpu"]
|
||||
@@ -129,6 +130,29 @@ func injectNvidiaGPUFields(template *wfv1.Template, systemConfig SystemConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// injectNodeSelectorResources adds resource requests and limits if they exist
|
||||
func injectNodeSelectorResources(template *wfv1.Template, systemConfig SystemConfig) {
|
||||
if template.NodeSelector == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
option *NodePoolOption
|
||||
err error
|
||||
)
|
||||
for k, v := range template.NodeSelector {
|
||||
if k == *systemConfig.NodePoolLabel() {
|
||||
option, err = systemConfig.NodePoolOptionByValue(v)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if option != nil && (option.Resources.Requests != nil || option.Resources.Limits != nil) {
|
||||
template.Container.Resources = option.Resources
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) injectAutomatedFields(namespace string, wf *wfv1.Workflow, opts *WorkflowExecutionOptions) (err error) {
|
||||
if opts.PodGCStrategy == nil {
|
||||
if wf.Spec.PodGC == nil {
|
||||
@@ -209,6 +233,7 @@ func (c *Client) injectAutomatedFields(namespace string, wf *wfv1.Workflow, opts
|
||||
template.Inputs.Artifacts[j] = artifact
|
||||
}
|
||||
|
||||
injectNodeSelectorResources(template, systemConfig)
|
||||
injectNvidiaGPUFields(template, systemConfig)
|
||||
|
||||
//Generate ENV vars from secret, if there is a container present in the workflow
|
||||
|
Reference in New Issue
Block a user