YARN-5596. Fix failing unit test in TestDockerContainerRuntime. Contributed by Sidharta Seethana.
(cherry picked from commit 08f55ccbb0
)
This commit is contained in:
parent
776eccd873
commit
34f9330651
|
@ -146,6 +146,8 @@ public class DockerLinuxContainerRuntime implements LinuxContainerRuntime {
|
||||||
public static final String ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS =
|
public static final String ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS =
|
||||||
"YARN_CONTAINER_RUNTIME_DOCKER_LOCAL_RESOURCE_MOUNTS";
|
"YARN_CONTAINER_RUNTIME_DOCKER_LOCAL_RESOURCE_MOUNTS";
|
||||||
|
|
||||||
|
static final String CGROUPS_ROOT_DIRECTORY = "/sys/fs/cgroup";
|
||||||
|
|
||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
private DockerClient dockerClient;
|
private DockerClient dockerClient;
|
||||||
private PrivilegedOperationExecutor privilegedOperationExecutor;
|
private PrivilegedOperationExecutor privilegedOperationExecutor;
|
||||||
|
@ -437,7 +439,6 @@ public class DockerLinuxContainerRuntime implements LinuxContainerRuntime {
|
||||||
LOCALIZED_RESOURCES);
|
LOCALIZED_RESOURCES);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> userLocalDirs = ctx.getExecutionAttribute(USER_LOCAL_DIRS);
|
List<String> userLocalDirs = ctx.getExecutionAttribute(USER_LOCAL_DIRS);
|
||||||
|
|
||||||
Set<String> capabilities = new HashSet<>(Arrays.asList(conf.getStrings(
|
Set<String> capabilities = new HashSet<>(Arrays.asList(conf.getStrings(
|
||||||
YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
||||||
YarnConfiguration.DEFAULT_NM_DOCKER_CONTAINER_CAPABILITIES)));
|
YarnConfiguration.DEFAULT_NM_DOCKER_CONTAINER_CAPABILITIES)));
|
||||||
|
@ -449,7 +450,8 @@ public class DockerLinuxContainerRuntime implements LinuxContainerRuntime {
|
||||||
.setContainerWorkDir(containerWorkDir.toString())
|
.setContainerWorkDir(containerWorkDir.toString())
|
||||||
.setNetworkType(network)
|
.setNetworkType(network)
|
||||||
.setCapabilities(capabilities)
|
.setCapabilities(capabilities)
|
||||||
.addMountLocation("/sys/fs/cgroup", "/sys/fs/cgroup:ro", false);
|
.addMountLocation(CGROUPS_ROOT_DIRECTORY,
|
||||||
|
CGROUPS_ROOT_DIRECTORY + ":ro", false);
|
||||||
List<String> allDirs = new ArrayList<>(containerLocalDirs);
|
List<String> allDirs = new ArrayList<>(containerLocalDirs);
|
||||||
|
|
||||||
allDirs.addAll(filecacheDirs);
|
allDirs.addAll(filecacheDirs);
|
||||||
|
|
|
@ -257,6 +257,18 @@ public class TestDockerContainerRuntime {
|
||||||
return expectedCapabilitiesString.toString();
|
return expectedCapabilitiesString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getExpectedCGroupsMountString() {
|
||||||
|
boolean cGroupsMountExists = new File(
|
||||||
|
DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY).exists();
|
||||||
|
|
||||||
|
if(cGroupsMountExists) {
|
||||||
|
return "-v " + DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY
|
||||||
|
+ ":" + DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY + ":ro ";
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDockerContainerLaunch()
|
public void testDockerContainerLaunch()
|
||||||
throws ContainerExecutionException, PrivilegedOperationException,
|
throws ContainerExecutionException, PrivilegedOperationException,
|
||||||
|
@ -276,7 +288,7 @@ public class TestDockerContainerRuntime {
|
||||||
.append("--workdir=%3$s ")
|
.append("--workdir=%3$s ")
|
||||||
.append("--net=host ")
|
.append("--net=host ")
|
||||||
.append(getExpectedTestCapabilitiesArgumentString())
|
.append(getExpectedTestCapabilitiesArgumentString())
|
||||||
.append("-v /sys/fs/cgroup:/sys/fs/cgroup:ro ")
|
.append(getExpectedCGroupsMountString())
|
||||||
.append("-v %4$s:%4$s ")
|
.append("-v %4$s:%4$s ")
|
||||||
.append("-v %5$s:%5$s ")
|
.append("-v %5$s:%5$s ")
|
||||||
.append("-v %6$s:%6$s ")
|
.append("-v %6$s:%6$s ")
|
||||||
|
@ -382,7 +394,7 @@ public class TestDockerContainerRuntime {
|
||||||
.append("--workdir=%3$s ")
|
.append("--workdir=%3$s ")
|
||||||
.append("--net=" + allowedNetwork + " ")
|
.append("--net=" + allowedNetwork + " ")
|
||||||
.append(getExpectedTestCapabilitiesArgumentString())
|
.append(getExpectedTestCapabilitiesArgumentString())
|
||||||
.append("-v /sys/fs/cgroup:/sys/fs/cgroup:ro ")
|
.append(getExpectedCGroupsMountString())
|
||||||
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
||||||
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||||
|
@ -437,7 +449,7 @@ public class TestDockerContainerRuntime {
|
||||||
.append("--workdir=%3$s ")
|
.append("--workdir=%3$s ")
|
||||||
.append("--net=" + customNetwork1 + " ")
|
.append("--net=" + customNetwork1 + " ")
|
||||||
.append(getExpectedTestCapabilitiesArgumentString())
|
.append(getExpectedTestCapabilitiesArgumentString())
|
||||||
.append("-v /sys/fs/cgroup:/sys/fs/cgroup:ro ")
|
.append(getExpectedCGroupsMountString())
|
||||||
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
||||||
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||||
|
@ -474,7 +486,7 @@ public class TestDockerContainerRuntime {
|
||||||
.append("--workdir=%3$s ")
|
.append("--workdir=%3$s ")
|
||||||
.append("--net=" + customNetwork2 + " ")
|
.append("--net=" + customNetwork2 + " ")
|
||||||
.append(getExpectedTestCapabilitiesArgumentString())
|
.append(getExpectedTestCapabilitiesArgumentString())
|
||||||
.append("-v /sys/fs/cgroup:/sys/fs/cgroup:ro ")
|
.append(getExpectedCGroupsMountString())
|
||||||
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
.append("-v %4$s:%4$s ").append("-v %5$s:%5$s ")
|
||||||
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
.append("-v %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||||
|
|
Loading…
Reference in New Issue