-
Bug
-
Resolution: Not an Issue
-
P3
-
17.0.5
-
x86_64
-
linux
A DESCRIPTION OF THE PROBLEM :
since `17.0.5`, I've noticed that my java application running in a container has access to all the cores on my host machine even when setting cpu contraints on container runtime (either with `--cpus`, `--cpu-shares` or in kubernetes with resource limits).
Here is a test app with cpu limit set to "1", running in a kubernetes pod:
https://user-images.githubusercontent.com/7240895/203778182-03a36ab1-f711-481d-a57a-1cb586317c43.png
As we can see, it seems that our app disregards the limits set on cpu completely.
we could also exec into the container and run `java -XshowSettings:system -version`:
https://user-images.githubusercontent.com/7240895/203779882-689ffc96-d69a-41b0-be65-e0f62f570055.png
=> `Effective CPU Count: 32`
or with `jshell`:
https://user-images.githubusercontent.com/7240895/203779617-608c8148-31f4-496d-add2-02b942a6943a.png
the observed behaviour might be caused by this update: https://bugs.openjdk.org/browse/JDK-8289568
---
When running the same test on `eclipse-temurin:17.0.4.1_1-jdk` (with `{"resources":{"requests":{"cpu":"1000m"}}}` or when explicitly setting `-XX:ActiveProcessorCount=1` this behaviour is no longer observed:
https://user-images.githubusercontent.com/7240895/203781211-fbc43cb5-d24a-40bb-8487-3b4eae33f5cf.png
and `Effective CPU Count` is "1" and `Runtime.getRuntime().availableProcessors()` returns "1"
REGRESSION : Last worked in version 17
FREQUENCY : always
since `17.0.5`, I've noticed that my java application running in a container has access to all the cores on my host machine even when setting cpu contraints on container runtime (either with `--cpus`, `--cpu-shares` or in kubernetes with resource limits).
Here is a test app with cpu limit set to "1", running in a kubernetes pod:
https://user-images.githubusercontent.com/7240895/203778182-03a36ab1-f711-481d-a57a-1cb586317c43.png
As we can see, it seems that our app disregards the limits set on cpu completely.
we could also exec into the container and run `java -XshowSettings:system -version`:
https://user-images.githubusercontent.com/7240895/203779882-689ffc96-d69a-41b0-be65-e0f62f570055.png
=> `Effective CPU Count: 32`
or with `jshell`:
https://user-images.githubusercontent.com/7240895/203779617-608c8148-31f4-496d-add2-02b942a6943a.png
the observed behaviour might be caused by this update: https://bugs.openjdk.org/browse/JDK-8289568
---
When running the same test on `eclipse-temurin:17.0.4.1_1-jdk` (with `{"resources":{"requests":{"cpu":"1000m"}}}` or when explicitly setting `-XX:ActiveProcessorCount=1` this behaviour is no longer observed:
https://user-images.githubusercontent.com/7240895/203781211-fbc43cb5-d24a-40bb-8487-3b4eae33f5cf.png
and `Effective CPU Count` is "1" and `Runtime.getRuntime().availableProcessors()` returns "1"
REGRESSION : Last worked in version 17
FREQUENCY : always
- relates to
-
JDK-8281181 Do not use CPU Shares to compute active processor count
- Resolved
-
JDK-8289568 Do not use CPU Shares to compute active processor count
- Resolved