Skip to content

Commit

Permalink
feat(operator): handle resources as a whole in PTS, instead of reques…
Browse files Browse the repository at this point in the history
…ts and limits separately
  • Loading branch information
jsenko committed Oct 29, 2024
1 parent a5bb212 commit 5418ce8
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private static void mergeDeploymentPodTemplateSpec(
}
var targetPorts = c.getPorts();
ports.forEach(sourcePort -> {
if (!targetPorts.stream()
.anyMatch(targetPort -> sourcePort.getName().equals(targetPort.getName()))) {
if (targetPorts.stream()
.noneMatch(targetPort -> sourcePort.getName().equals(targetPort.getName()))) {
targetPorts.add(sourcePort);
}
});
Expand All @@ -155,11 +155,7 @@ private static void mergeDeploymentPodTemplateSpec(
}
if (c.getResources() == null) {
c.setResources(new ResourceRequirements());
}
if (c.getResources().getRequests() == null || c.getResources().getRequests().isEmpty()) {
c.getResources().setRequests(requests);
}
if (c.getResources().getLimits() == null || c.getResources().getLimits().isEmpty()) {
c.getResources().setLimits(limits);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,42 @@ cases:
cpu: 1
memory: 1Gi

- id: 'Resources 1'
spec:
spec:
containers:
- name: apicurio-registry-app
resources: { }
expected:
metadata:
labels:
app.kubernetes.io/name: apicurio-registry
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: test
app.kubernetes.io/part-of: apicurio-registry
app.kubernetes.io/component: app
app.kubernetes.io/managed-by: apicurio-registry-operator
app: test
spec:
containers:
- name: apicurio-registry-app
image: quay.io/apicurio/apicurio-registry:latest-snapshot
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /health/ready
port: 8080
scheme: HTTP
livenessProbe:
httpGet:
path: /health/live
port: 8080
scheme: HTTP
resources: { }

- id: 'Requests 1'
spec:
spec:
Expand Down Expand Up @@ -505,9 +541,6 @@ cases:
resources:
requests:
cpu: 750m
limits:
cpu: 1
memory: 1Gi

- id: 'Limits 1'
spec:
Expand Down Expand Up @@ -546,8 +579,5 @@ cases:
port: 8080
scheme: HTTP
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 750m
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,42 @@ cases:
cpu: 200m
memory: 512Mi

- id: 'Resources 1'
spec:
spec:
containers:
- name: apicurio-registry-ui
resources: { }
expected:
metadata:
labels:
app.kubernetes.io/name: apicurio-registry
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: test
app.kubernetes.io/part-of: apicurio-registry
app.kubernetes.io/component: ui
app.kubernetes.io/managed-by: apicurio-registry-operator
app: test
spec:
containers:
- name: apicurio-registry-ui
image: quay.io/apicurio/apicurio-registry-ui:latest-snapshot
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /config.js
port: 8080
scheme: HTTP
livenessProbe:
httpGet:
path: /config.js
port: 8080
scheme: HTTP
resources: { }

- id: 'Requests 1'
spec:
spec:
Expand Down Expand Up @@ -505,9 +541,6 @@ cases:
resources:
requests:
cpu: 750m
limits:
cpu: 200m
memory: 512Mi

- id: 'Limits 1'
spec:
Expand Down Expand Up @@ -546,8 +579,5 @@ cases:
port: 8080
scheme: HTTP
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 750m

0 comments on commit 5418ce8

Please sign in to comment.