Skip to content

Commit 823a012

Browse files
committed
parameterize init resources
Signed-off-by: Humair Khan <[email protected]>
1 parent f6689a8 commit 823a012

File tree

19 files changed

+183
-41
lines changed

19 files changed

+183
-41
lines changed

.github/workflows/build-tags.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ env:
9090
IMAGE_REPO_SWF: ds-pipelines-scheduledworkflow
9191
IMAGE_REPO_LAUNCHER: ds-pipelines-launcher
9292
IMAGE_REPO_DRIVER: ds-pipelines-driver
93-
IMAGE_REPO_PIELINES_RUNTIME_GENERIC: ds-pipelines-runtime-generic
93+
IMAGE_REPO_PIPELINES_RUNTIME_GENERIC: ds-pipelines-runtime-generic
9494
SOURCE_DSPO_BRANCH: ${{ inputs.src_dspo_branch }}
9595
SOURCE_DSP_BRANCH: ${{ inputs.src_dsp_branch }}
9696
SOURCE_DSP_PIPELINES_BRANCH: ${{ inputs.src_pipelines_branch }}
@@ -223,7 +223,7 @@ jobs:
223223
env:
224224
SOURCE_BRANCH: ${{ env.SOURCE_DSP_PIPELINES_BRANCH }}
225225
with:
226-
IMAGE_REPO: ${{ env.IMAGE_REPO_PIELINES_RUNTIME_GENERIC }}
226+
IMAGE_REPO: ${{ env.IMAGE_REPO_PIPELINES_RUNTIME_GENERIC }}
227227
DOCKERFILE: Dockerfile
228228
GH_REPO: ${{ inputs.pipelines_org_repo }}
229229
OVERWRITE: ${{ env.OVERWRITE_IMAGES }}

api/v1/dspipeline_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ type APIServer struct {
8484
RHELAIImage string `json:"rhelAIImage,omitempty"`
8585
// Specify custom Pod resource requirements for this component.
8686
Resources *ResourceRequirements `json:"resources,omitempty"`
87+
// Specify init container resource requirements. The init container
88+
// is used to build managed-pipelines and store them in a shared volume.
89+
InitResources *ResourceRequirements `json:"initResources,omitempty"`
8790

8891
// If the Object store/DB is behind a TLS secured connection that is
8992
// unrecognized by the host OpenShift/K8s cluster, then you can

api/v1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/dspipeline_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ type APIServer struct {
8484
RHELAIImage string `json:"rhelAIImage,omitempty"`
8585
// Specify custom Pod resource requirements for this component.
8686
Resources *ResourceRequirements `json:"resources,omitempty"`
87+
// Specify init container resource requirements. The init container
88+
// is used to build managed-pipelines and store them in a shared volume.
89+
InitResources *ResourceRequirements `json:"initResources,omitempty"`
8790

8891
// If the Object store/DB is behind a TLS secured connection that is
8992
// unrecognized by the host OpenShift/K8s cluster, then you can

api/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml

+72
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,42 @@ spec:
120120
image:
121121
description: Specify a custom image for DSP API Server.
122122
type: string
123+
initResources:
124+
description: Specify init container resource requirements. The
125+
init container is used to build managed-pipelines and store
126+
them in a shared volume.
127+
properties:
128+
limits:
129+
properties:
130+
cpu:
131+
anyOf:
132+
- type: integer
133+
- type: string
134+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
135+
x-kubernetes-int-or-string: true
136+
memory:
137+
anyOf:
138+
- type: integer
139+
- type: string
140+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
141+
x-kubernetes-int-or-string: true
142+
type: object
143+
requests:
144+
properties:
145+
cpu:
146+
anyOf:
147+
- type: integer
148+
- type: string
149+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
150+
x-kubernetes-int-or-string: true
151+
memory:
152+
anyOf:
153+
- type: integer
154+
- type: string
155+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
156+
x-kubernetes-int-or-string: true
157+
type: object
158+
type: object
123159
resources:
124160
description: Specify custom Pod resource requirements for this
125161
component.
@@ -1018,6 +1054,42 @@ spec:
10181054
image:
10191055
description: Specify a custom image for DSP API Server.
10201056
type: string
1057+
initResources:
1058+
description: Specify init container resource requirements. The
1059+
init container is used to build managed-pipelines and store
1060+
them in a shared volume.
1061+
properties:
1062+
limits:
1063+
properties:
1064+
cpu:
1065+
anyOf:
1066+
- type: integer
1067+
- type: string
1068+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1069+
x-kubernetes-int-or-string: true
1070+
memory:
1071+
anyOf:
1072+
- type: integer
1073+
- type: string
1074+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1075+
x-kubernetes-int-or-string: true
1076+
type: object
1077+
requests:
1078+
properties:
1079+
cpu:
1080+
anyOf:
1081+
- type: integer
1082+
- type: string
1083+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1084+
x-kubernetes-int-or-string: true
1085+
memory:
1086+
anyOf:
1087+
- type: integer
1088+
- type: string
1089+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1090+
x-kubernetes-int-or-string: true
1091+
type: object
1092+
type: object
10211093
injectDefaultScript:
10221094
default: true
10231095
description: 'Inject the archive step script. Default: true Deprecated:

config/internal/apiserver/default/deployment.yaml.tmpl

+17-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,25 @@ spec:
3636
value: {{.APIServer.ToolboxImage}}
3737
- name: RHELAI_IMAGE
3838
value: {{.APIServer.RHELAIImage}}
39+
{{ if .APIServer.InitResources }}
3940
resources:
40-
limits:
41-
memory: 200Mi
42-
cpu: '1'
4341
requests:
44-
memory: 200Mi
45-
cpu: '1'
42+
{{ if .APIServer.InitResources.Requests.CPU }}
43+
cpu: {{.APIServer.InitResources.Requests.CPU}}
44+
{{ end }}
45+
{{ if .APIServer.InitResources.Requests.Memory }}
46+
memory: {{.APIServer.InitResources.Requests.Memory}}
47+
{{ end }}
48+
{{ end }}
49+
{{ if .APIServer.InitResources.Limits }}
50+
limits:
51+
{{ if .APIServer.InitResources.Limits.CPU }}
52+
cpu: {{.APIServer.InitResources.Limits.CPU}}
53+
{{ end }}
54+
{{ if .APIServer.InitResources.Limits.Memory }}
55+
memory: {{.APIServer.InitResources.Limits.Memory}}
56+
{{ end }}
57+
{{ end }}
4658
volumeMounts:
4759
- mountPath: /opt/app-root/src/build
4860
name: managed-pipelines

controllers/config/defaults.go

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func GetConfigRequiredFields() []string {
165165
// Default ResourceRequirements
166166
var (
167167
APIServerResourceRequirements = createResourceRequirement(resource.MustParse("250m"), resource.MustParse("500Mi"), resource.MustParse("500m"), resource.MustParse("1Gi"))
168+
APIServerInitResourceRequirements = createResourceRequirement(resource.MustParse("250m"), resource.MustParse("128Mi"), resource.MustParse("500m"), resource.MustParse("256Mi"))
168169
PersistenceAgentResourceRequirements = createResourceRequirement(resource.MustParse("120m"), resource.MustParse("500Mi"), resource.MustParse("250m"), resource.MustParse("1Gi"))
169170
ScheduledWorkflowResourceRequirements = createResourceRequirement(resource.MustParse("120m"), resource.MustParse("100Mi"), resource.MustParse("250m"), resource.MustParse("250Mi"))
170171
WorkflowControllerResourceRequirements = createResourceRequirement(resource.MustParse("120m"), resource.MustParse("500Mi"), resource.MustParse("250m"), resource.MustParse("1Gi"))

controllers/dspipeline_params.go

+1
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
607607
setStringDefault(rhelAIImageFromConfig, &p.APIServer.RHELAIImage)
608608

609609
setResourcesDefault(config.APIServerResourceRequirements, &p.APIServer.Resources)
610+
setResourcesDefault(config.APIServerInitResourceRequirements, &p.APIServer.InitResources)
610611

611612
if p.APIServer.CustomServerConfig == nil {
612613
p.APIServer.CustomServerConfig = &dspa.ScriptConfigMap{

controllers/testdata/declarative/case_0/expected/created/apiserver_deployment.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test0
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 256Mi
44+
cpu: '500m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 128Mi
47+
cpu: '250m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testdata/declarative/case_2/deploy/cr.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ spec:
2323
limits:
2424
cpu: "2522m"
2525
memory: "5Gi"
26+
initResources:
27+
requests:
28+
cpu: "1232m"
29+
memory: "2Gi"
30+
limits:
31+
cpu: "2523m"
32+
memory: "6Gi"
2633
persistenceAgent:
2734
deploy: true
2835
image: persistenceagent:test2

controllers/testdata/declarative/case_2/expected/created/apiserver_deployment.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
initContainers:
2626
- name: init-pipelines
27-
image: runtimegeneric:test0
27+
image: runtimegeneric:test2
2828
workingDir: /opt/app-root/src/pipelines/distributed-ilab
2929
command: ['/bin/sh', '-c']
3030
args:
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test2
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 6Gi
44+
cpu: '2523m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 2Gi
47+
cpu: '1232m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testdata/declarative/case_3/expected/created/apiserver_deployment.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
initContainers:
2626
- name: init-pipelines
27-
image: runtimegeneric:test0
27+
image: runtimegeneric:test3
2828
workingDir: /opt/app-root/src/pipelines/distributed-ilab
2929
command: ['/bin/sh', '-c']
3030
args:
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test3
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 256Mi
44+
cpu: '500m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 128Mi
47+
cpu: '250m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testdata/declarative/case_4/expected/created/apiserver_deployment.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
initContainers:
2626
- name: init-pipelines
27-
image: runtimegeneric:test0
27+
image: runtimegeneric:test4
2828
workingDir: /opt/app-root/src/pipelines/distributed-ilab
2929
command: ['/bin/sh', '-c']
3030
args:
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test4
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 256Mi
44+
cpu: '500m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 128Mi
47+
cpu: '250m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testdata/declarative/case_5/expected/created/apiserver_deployment.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
initContainers:
2626
- name: init-pipelines
27-
image: runtimegeneric:test0
27+
image: runtimegeneric:test5
2828
workingDir: /opt/app-root/src/pipelines/distributed-ilab
2929
command: ['/bin/sh', '-c']
3030
args:
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test5
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 256Mi
44+
cpu: '500m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 128Mi
47+
cpu: '250m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testdata/declarative/case_6/expected/created/apiserver_deployment.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
spec:
2525
initContainers:
2626
- name: init-pipelines
27-
image: runtimegeneric:test0
27+
image: runtimegeneric:test6
2828
workingDir: /opt/app-root/src/pipelines/distributed-ilab
2929
command: ['/bin/sh', '-c']
3030
args:
@@ -40,11 +40,11 @@ spec:
4040
value: rhelai:test6
4141
resources:
4242
limits:
43-
memory: 200Mi
44-
cpu: '1'
43+
memory: 256Mi
44+
cpu: '500m'
4545
requests:
46-
memory: 200Mi
47-
cpu: '1'
46+
memory: 128Mi
47+
cpu: '250m'
4848
volumeMounts:
4949
- mountPath: /opt/app-root/src/build
5050
name: managed-pipelines

controllers/testutil/equalities.go

+24-5
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,37 @@ func deploymentsAreEqual(expected, actual *unstructured.Unstructured) (bool, err
168168
return false, notDeeplyEqualMsg("Volumes", diff)
169169
}
170170

171-
if len(expectedDep.Spec.Template.Spec.Containers) != len(actualDep.Spec.Template.Spec.Containers) {
171+
_, err = compareContainers(expectedDep.Spec.Template.Spec.InitContainers, actualDep.Spec.Template.Spec.InitContainers)
172+
if err != nil {
173+
return false, err
174+
}
175+
176+
_, err = compareContainers(expectedDep.Spec.Template.Spec.Containers, actualDep.Spec.Template.Spec.Containers)
177+
if err != nil {
178+
return false, err
179+
}
180+
181+
return true, nil
182+
}
183+
184+
func compareContainers(expectedContainers []v1.Container, actualContainers []v1.Container) (bool, error) {
185+
186+
if len(expectedContainers) != len(actualContainers) {
172187
return false, notEqualMsg("Container lengths")
173188
}
174-
for i := range expectedDep.Spec.Template.Spec.Containers {
175-
expectedContainer := expectedDep.Spec.Template.Spec.Containers[i]
176-
actualContainer := actualDep.Spec.Template.Spec.Containers[i]
177189

178-
diffEnvsMsg := compareEnvs(expectedContainer.Env, actualContainer.Env)
190+
for i := range expectedContainers {
179191

192+
expectedContainer := expectedContainers[i]
193+
actualContainer := actualContainers[i]
194+
195+
diffEnvsMsg := compareEnvs(expectedContainer.Env, actualContainer.Env)
180196
if len(expectedContainer.Env) != len(actualContainer.Env) {
181197
return false, notEqualMsg(fmt.Sprintf("Container Env Lengths [expected: %d, actual: %d]\nDivergence(s): %s", len(expectedContainer.Env), len(actualContainer.Env), diffEnvsMsg))
182198
}
199+
200+
var diff []string
201+
183202
// Check each env individually for a more meaningful response upon failure.
184203
for i, expectedEnv := range expectedContainer.Env {
185204
actualEnv := actualContainer.Env[i]

0 commit comments

Comments
 (0)