On Fri, 28 Nov 2025 15:03:25 GMT, Casper Norrbin <[email protected]> wrote:

> Hi everyone,
> 
> Many container tests verify that various resource limits work as expected. 
> However, when running containers in rootless mode on both Docker and Podman 
> with cgroup v1, resource limits are not supported. This causes tests to fail 
> with error messages like: `Resource limits are not supported and ignored on 
> cgroups V1 rootless systems`.
> 
> To address this, we should skip these tests when running on configurations 
> that don't support resource limits, similar to how we already handle other 
> unsupported configurations (e.g., missing container engine or incompatibility 
> with a specific cgroup version or container runtime).
> 
> To check for this, we now need to use `Metrics.systemMetrics().getProvider()` 
> from `jdk.internal.platform.Metrics` to detect cgroup v1. I've added this 
> functionality to `DockerTestUtils`, which is already used by all container 
> tests. As a result, all container tests now need to include the 
> `java.base/jdk.internal.platform` module, even if they don't directly test 
> resource limits.
> 
> Testing:
> * Oracle tiers 1-5
> * Local testing:
>   - `hotspot/jtreg/containers/` 
>   - `jdk/jdk/internal/platform/docker/`
> on cgroup v1/v2 with Podman and Docker in both rootful and rootless 
> configurations

test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java line 142:

> 140:      *
> 141:      * @return true if resource limits are supported in the current 
> configuration
> 142:      * @throws Exception

I don't like this pattern of making a function seem like it is a query by 
declaring it returns a boolean when in reality it either returns true of 
throws. These should just be void functions with names like 
`check_canUseResourceLimits`, and we can elide the fake `if` conditions with 
unreachable `return` statements in the callers.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28557#discussion_r2575563949

Reply via email to