YARN-5596. Fix failing unit test in TestDockerContainerRuntime. Contributed by Sidharta Seethana.
This commit is contained in:
parent
6c600360ca
commit
08f55ccbb0
@ -146,6 +146,8 @@ public class DockerLinuxContainerRuntime implements LinuxContainerRuntime {
|
||||
public static final String ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS =
|
||||
"YARN_CONTAINER_RUNTIME_DOCKER_LOCAL_RESOURCE_MOUNTS";
|
||||
|
||||
static final String CGROUPS_ROOT_DIRECTORY = "/sys/fs/cgroup";
|
||||
|
||||
private Configuration conf;
|
||||
private DockerClient dockerClient;
|
||||
private PrivilegedOperationExecutor privilegedOperationExecutor;
|
||||
@ -437,7 +439,6 @@ public void launchContainer(ContainerRuntimeContext ctx)
|
||||
LOCALIZED_RESOURCES);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> userLocalDirs = ctx.getExecutionAttribute(USER_LOCAL_DIRS);
|
||||
|
||||
Set<String> capabilities = new HashSet<>(Arrays.asList(conf.getStrings(
|
||||
YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
||||
YarnConfiguration.DEFAULT_NM_DOCKER_CONTAINER_CAPABILITIES)));
|
||||
@ -449,7 +450,8 @@ public void launchContainer(ContainerRuntimeContext ctx)
|
||||
.setContainerWorkDir(containerWorkDir.toString())
|
||||
.setNetworkType(network)
|
||||
.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);
|
||||
|
||||
allDirs.addAll(filecacheDirs);
|
||||
|
@ -257,6 +257,18 @@ private String getExpectedTestCapabilitiesArgumentString() {
|
||||
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
|
||||
public void testDockerContainerLaunch()
|
||||
throws ContainerExecutionException, PrivilegedOperationException,
|
||||
@ -276,7 +288,7 @@ public void testDockerContainerLaunch()
|
||||
.append("--workdir=%3$s ")
|
||||
.append("--net=host ")
|
||||
.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 %6$s:%6$s ")
|
||||
@ -382,7 +394,7 @@ public void testContainerLaunchWithNetworkingDefaults()
|
||||
.append("--workdir=%3$s ")
|
||||
.append("--net=" + allowedNetwork + " ")
|
||||
.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 %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||
@ -437,7 +449,7 @@ public void testContainerLaunchWithCustomNetworks()
|
||||
.append("--workdir=%3$s ")
|
||||
.append("--net=" + customNetwork1 + " ")
|
||||
.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 %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||
@ -474,7 +486,7 @@ public void testContainerLaunchWithCustomNetworks()
|
||||
.append("--workdir=%3$s ")
|
||||
.append("--net=" + customNetwork2 + " ")
|
||||
.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 %6$s:%6$s ").append("-v %7$s:%7$s ")
|
||||
.append("-v %8$s:%8$s ").append("%9$s ")
|
||||
|
Loading…
Reference in New Issue
Block a user