Skip to content

Commit

Permalink
Use requests, not defaultRequest, in deploy definition
Browse files Browse the repository at this point in the history
Followup to ManageIQ#20661

Previously, it looks like kubernetes was silently ignoring the defaultRequest,
while still honoring the rest of the definition.

We were seeing definitions with the resource limits but no requests:

```
$ oc get deploy 1-generic -o yaml | grep -A 6 "resources:"
        resources:
          limits:
            cpu: "1"
            memory: 1Gi
```

We found that existing deployment definitions in other projects used the key
'requests', so after making this change, we now have both limits and requests
in the deployment definition:

```
$ oc get deploy 1-generic -o yaml | grep -A 6 "resources:"
        resources:
          limits:
            cpu: "1"
            memory: 1Gi
          requests:
            cpu: 150m
           memory: 500Mi
```
  • Loading branch information
jrafanie committed Nov 20, 2020
1 parent 2f8ae23 commit d202b0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/miq_worker/container_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def resource_constraints
h.store_path(:limits, :memory, format_memory_threshold(mem_limit)) if mem_limit
h.store_path(:limits, :cpu, format_cpu_threshold(cpu_limit)) if cpu_limit

h.store_path(:defaultRequest, :memory, format_memory_threshold(mem_request)) if mem_request
h.store_path(:defaultRequest, :cpu, format_cpu_threshold(cpu_request)) if cpu_request
h.store_path(:requests, :memory, format_memory_threshold(mem_request)) if mem_request
h.store_path(:requests, :cpu, format_cpu_threshold(cpu_request)) if cpu_request
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/miq_worker/container_common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def deployment_name_for(name)
it "returns default cpu when it is set" do
allow(MiqGenericWorker).to receive(:worker_settings).and_return(:cpu_request_percent => 10)
constraints = {
:defaultRequest => {
:requests => {
:cpu => "100m"
}
}
Expand All @@ -187,7 +187,7 @@ def deployment_name_for(name)
it "returns default memory when it is set" do
allow(MiqGenericWorker).to receive(:worker_settings).and_return(:memory_request => 250.megabytes)
constraints = {
:defaultRequest => {
:requests => {
:memory => "250Mi",
}
}
Expand All @@ -197,7 +197,7 @@ def deployment_name_for(name)
it "returns memory pair when set" do
allow(MiqGenericWorker).to receive(:worker_settings).and_return(:memory_request => 250.megabytes, :memory_threshold => 600.megabytes)
constraints = {
:defaultRequest => {
:requests => {
:memory => "250Mi",
},
:limits => {
Expand Down

0 comments on commit d202b0e

Please sign in to comment.