Skip to content

Commit 9bb25cd

Browse files
author
lynnyuan
committed
YARN-9906. Fix Docker container multi volume mounts bug
1 parent c39e9fc commit 9bb25cd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/DockerLinuxContainerRuntime.java

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ public void launchContainer(ContainerRuntimeContext ctx)
717717
}
718718
runCommand.addMountLocation(src, dst, mode);
719719
}
720-
long commaCount = environment.get(ENV_DOCKER_CONTAINER_MOUNTS).chars()
721-
.filter(c -> c == ',').count();
722-
if (mountCount != commaCount + 1) {
720+
long semicolonCount = environment.get(ENV_DOCKER_CONTAINER_MOUNTS).chars()
721+
.filter(c -> c == ';').count();
722+
if (mountCount != semicolonCount + 1) {
723723
// this means the matcher skipped an improperly formatted mount
724724
throw new ContainerExecutionException(
725725
"Unable to parse some mounts in user supplied mount list: "

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/OCIContainerRuntime.java

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public abstract class OCIContainerRuntime implements LinuxContainerRuntime {
7171
private static final Pattern HOSTNAME_PATTERN = Pattern.compile(
7272
"^[a-zA-Z0-9][a-zA-Z0-9_.-]+$");
7373
static final Pattern USER_MOUNT_PATTERN = Pattern.compile(
74-
"(?<=^|,)([^:\\x00]+):([^:\\x00]+)" +
75-
"(:(r[ow]|(r[ow][+])?(r?shared|r?slave|r?private)))?(?:,|$)");
74+
"(?<=^|;)([^:\\x00]+):([^:\\x00]+)" +
75+
"(:(r[ow]|(r[ow][+])?(r?shared|r?slave|r?private)))?(?:;|$)");
7676
static final Pattern TMPFS_MOUNT_PATTERN = Pattern.compile(
7777
"^/[^:\\x00]+$");
7878
static final String PORTS_MAPPING_PATTERN =

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestDockerContainerRuntime.java

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ public void testMountMultiple()
13451345

13461346
env.put(
13471347
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
1348-
"test_dir/test_resource_file:test_mount1:ro," +
1348+
"test_dir/test_resource_file:test_mount1:ro;" +
13491349
"test_dir/test_resource_file:test_mount2:ro");
13501350

13511351
runtime.launchContainer(builder.build());
@@ -1395,8 +1395,8 @@ public void testUserMounts()
13951395

13961396
env.put(
13971397
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
1398-
"/tmp/foo:/tmp/foo:ro,/tmp/bar:/tmp/bar:rw,/tmp/baz:/tmp/baz," +
1399-
"/a:/a:shared,/b:/b:ro+shared,/c:/c:rw+rshared,/d:/d:private");
1398+
"/tmp/foo:/tmp/foo:ro;/tmp/bar:/tmp/bar:rw;/tmp/baz:/tmp/baz;" +
1399+
"/a:/a:shared;/b:/b:ro+shared;/c:/c:rw+rshared;/d:/d:private");
14001400

14011401
runtime.launchContainer(builder.build());
14021402
List<String> dockerCommands = readDockerCommands();
@@ -1444,7 +1444,7 @@ public void testUserMountInvalid() throws ContainerExecutionException {
14441444

14451445
env.put(
14461446
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
1447-
"/source:target:ro,/source:target:other,/source:target:rw");
1447+
"/source:target:ro;/source:target:other;/source:target:rw");
14481448

14491449
try {
14501450
runtime.launchContainer(builder.build());

0 commit comments

Comments
 (0)