Skip to content
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

fix: override resource requests #15

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ type patchOp struct {
Value interface{} `json:"value,omitempty"`
}

var resourcePath = "/spec/template/spec/containers/%d/resources"
var resourcePath = "/spec/template/spec/containers/%d/resources/limits"
var envPath = "/spec/template/spec/containers/%d/env/%s"

// CreatePatchForDeployment add gpu env for deployment and returns patch bytes.
Expand All @@ -381,9 +381,7 @@ func addResourceLimits(tpl *corev1.PodTemplateSpec, namespace string, gpuRequire
Op: constants.PatchOpAdd,
Path: fmt.Sprintf(resourcePath, i),
Value: map[string]interface{}{
"limits": map[string]interface{}{
typeKey: "1",
},
typeKey: "1",
},
})
} else {
Expand All @@ -399,7 +397,7 @@ func addResourceLimits(tpl *corev1.PodTemplateSpec, namespace string, gpuRequire
patch = append(patch, patchOp{
Op: constants.PatchOpReplace,
Path: fmt.Sprintf(resourcePath, i),
Value: t,
Value: t["limits"],
})
}
if typeKey == constants.VirtAiTechVGPU {
Expand Down
Loading