Skip to content

Commit 94e31e5

Browse files
committedSep 30, 2021
8274506: TestPids.java and TestPidsLimit.java fail with podman run as root
Reviewed-by: mbaesken, cjplummer
1 parent a8210c5 commit 94e31e5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎test/hotspot/jtreg/containers/docker/TestPids.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@
4040
import jdk.test.lib.containers.docker.DockerRunOptions;
4141
import jdk.test.lib.containers.docker.DockerTestUtils;
4242
import jdk.test.lib.Asserts;
43+
import jdk.test.lib.Container;
4344
import jdk.test.lib.Platform;
4445
import jdk.test.lib.Utils;
4546

4647
public class TestPids {
4748
private static final String imageName = Common.imageName("pids");
49+
private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman");
50+
private static final int UNLIMITED_PIDS_PODMAN = 0;
51+
private static final int UNLIMITED_PIDS_DOCKER = -1;
4852

4953
static final String warning_kernel_no_pids_support = "WARNING: Your kernel does not support pids limit capabilities";
5054

@@ -139,7 +143,8 @@ private static void testPids(String value) throws Exception {
139143

140144
DockerRunOptions opts = commonOpts();
141145
if (value.equals("Unlimited")) {
142-
opts.addDockerOpts("--pids-limit=-1");
146+
int unlimited = IS_PODMAN ? UNLIMITED_PIDS_PODMAN : UNLIMITED_PIDS_DOCKER;
147+
opts.addDockerOpts("--pids-limit=" + unlimited);
143148
} else {
144149
opts.addDockerOpts("--pids-limit="+value);
145150
}

‎test/jdk/jdk/internal/platform/docker/TestPidsLimit.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@
3939
import jdk.test.lib.containers.docker.DockerTestUtils;
4040
import jdk.test.lib.process.OutputAnalyzer;
4141
import jdk.test.lib.Asserts;
42+
import jdk.test.lib.Container;
4243

4344
public class TestPidsLimit {
4445
private static final String imageName = Common.imageName("pids");
46+
private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman");
47+
private static final int UNLIMITED_PIDS_PODMAN = 0;
48+
private static final int UNLIMITED_PIDS_DOCKER = -1;
4549

4650
public static void main(String[] args) throws Exception {
4751
if (!DockerTestUtils.canTestDocker()) {
@@ -107,7 +111,8 @@ private static void testPidsLimit(String pidsLimit) throws Exception {
107111
Common.logNewTestCase("testPidsLimit (limit: " + pidsLimit + ")");
108112
DockerRunOptions opts = Common.newOptsShowSettings(imageName);
109113
if (pidsLimit.equals("Unlimited")) {
110-
opts.addDockerOpts("--pids-limit=-1");
114+
int unlimited = IS_PODMAN ? UNLIMITED_PIDS_PODMAN : UNLIMITED_PIDS_DOCKER;
115+
opts.addDockerOpts("--pids-limit=" + unlimited);
111116
} else {
112117
opts.addDockerOpts("--pids-limit="+pidsLimit);
113118
}

0 commit comments

Comments
 (0)
Please sign in to comment.