Skip to content

Commit

Permalink
fix compute class test, update doc and bring in generated code
Browse files Browse the repository at this point in the history
Signed-off-by: dciangot <[email protected]>
  • Loading branch information
dciangot committed Dec 20, 2023
1 parent db08e8b commit 06977b0
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 38 deletions.
7 changes: 6 additions & 1 deletion docs/docs/40-admin/03-computeclasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ memory:
values: # Specific values that are only allowed to be used. Default must be included in these values and max/min cannot be set.
- 1.5Gi
cpuScaler: 1 # This is used as a ratio of how many VCPUs to schedule per Gibibyte of memory. In this case it is 1 to 1.
resources: # The same resources fields for Pods: memory and CPU values will be overwritten by memory and cpuScaler fields
limits:
gpu-vendor.example/example-limit: 1
requests:
gpu-vendor.example/example-request: 1
priorityClassName: foo # The priority class to use for Pods
runtimeClassName: bar # The runtime class name to use for Pods
tolerations: # The same toleration fields for Pods
Expand All @@ -43,7 +48,7 @@ affinity: # The same affinity fields for Pods
supportedRegions: ["local"] # should always be set to ["local"]
```
If `memory.min`, `memory.max`, `memory.values`, `affinity`, and `tolerations` are not given, then there are no scheduling rules for workloads using the compute class.
If `memory.min`, `memory.max`, `memory.values`, `resources`, `affinity`, and `tolerations` are not given, then there are no scheduling rules for workloads using the compute class.

## Cluster Compute Classes

Expand Down
20 changes: 0 additions & 20 deletions integration/client/computeclass/computeclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,6 @@ func TestCreatingComputeClasses(t *testing.T) {
},
fail: true,
},
// // Raise error to avoid conflicts with
// // the "first class" fields for memory and cpu scaling
// {
// name: "invalid-custom-resources-limits",
// resources: corev1.ResourceRequirements{
// Limits: corev1.ResourceList{
// "cpu": resource.MustParse("1"),
// },
// },
// fail: true,
// },
// {
// name: "invalid-custom-resources-requests",
// resources: corev1.ResourceRequirements{
// Requests: corev1.ResourceList{
// "memory": resource.MustParse("1"),
// },
// },
// fail: true,
// },
}

for _, tt := range checks {
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/admin.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/apis/api.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/apis/internal.admin.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ spec:
port: 81
resources:
limits:
gpu-vendor.example/example-limit: "1"
memory: 1Mi
requests:
cpu: 1m
gpu-vendor.example/example-limit: "1"
memory: 1Mi
- image: foo
name: left
Expand Down Expand Up @@ -259,9 +261,11 @@ status:
- bar
requirements:
limits:
gpu-vendor.example/example-limit: "1"
memory: 1Mi
requests:
cpu: 1m
gpu-vendor.example/example-limit: "1"
memory: 1Mi
staged:
appImage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ status:
- bar
requirements:
limits:
gpu-vendor.example/example-limit: 1
memory: 1Mi
requests:
cpu: 1m
gpu-vendor.example/example-limit: 1
memory: 1Mi
left:
requirements:
Expand Down
20 changes: 8 additions & 12 deletions pkg/controller/scheduling/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ func addScheduling(req router.Request, appInstance *v1.AppInstance, workloads ma

for sidecarName, sidecarContainer := range container.Sidecars {
// disable extra resource indication (GPU et al. for sidecars)
if computeClass != nil {
if computeClass.Resources != nil {
computeClass.Resources = &corev1.ResourceRequirements{Limits: corev1.ResourceList{}, Requests: corev1.ResourceList{}}
}
if computeClass != nil && computeClass.Resources != nil {
computeClass.Resources = &corev1.ResourceRequirements{}
}
sidecarRequirements, err := ResourceRequirements(req, appInstance, sidecarName, sidecarContainer, computeClass)
if err != nil {
Expand Down Expand Up @@ -161,14 +159,12 @@ func ResourceRequirements(req router.Request, app *v1.AppInstance, containerName
}

requirements := &corev1.ResourceRequirements{Limits: corev1.ResourceList{}, Requests: corev1.ResourceList{}}
if computeClass != nil {
if computeClass.Resources != nil {
if computeClass.Resources.Requests != nil {
requirements.Requests = computeClass.Resources.Requests
}
if computeClass.Resources.Limits != nil {
requirements.Limits = computeClass.Resources.Limits
}
if computeClass != nil && computeClass.Resources != nil {
if computeClass.Resources.Requests != nil {
requirements.Requests = computeClass.Resources.Requests
}
if computeClass.Resources.Limits != nil {
requirements.Limits = computeClass.Resources.Limits
}
}

Expand Down
35 changes: 30 additions & 5 deletions pkg/openapi/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 06977b0

Please sign in to comment.