THREESCALE-10167 Fix cpu detection cgroupsv2 #1410
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Support Cgroups v2 for auto-detection of cpus for worker processes (when
APICAST_WORKERS
env is not set)Adds https://issues.redhat.com/browse/THREESCALE-10167 for apicast
Align with the implementation from 3scale/porta#3565
No testing added. Tried busted stub mechanism on
io.open
without success. The development environment user does not have access to write on files like/sys/fs/cgroup/cpu.weight
. The previous cpu detection implementation did not add tests either #600.Verification Steps
1) Development environment (docker compose)
Using docker 24.0.6
Run APICast without
APICAST_WORKERS
envThe logs show that in docker env cgroups V2 is being used.
Check the number of workers: logs should show N lines like the following. In the example, three of them which matches the
cpu_shares
computation2) Openshift 4.12 (using cgroups v1)
resulting in cgroups v1 computation
cpu.shares
value is2
:Check the number of apicast workers is
1
Let's request resources for cpu:
1400m
(~1.4 cores)New
cpu.shares
value is1433
:Logs show
cpu_shares = 2
Check the number of apicast workers is
2
3) Openshift 4.14 (using cgroups v2)
resulting in cgroups v2 computation
weight
value is1
:Check the number of apicast workers is
1
Let's request resources for cpu:
1400m
(~1.4 cores)New
weight
value is55
:Logs show
cpu_shares = 2
Check the number of apicast workers is
2