YARN-6968. Hardcoded absolute pathname in DockerLinuxContainerRuntime. Contributed by Eric Badger
This commit is contained in:
parent
50849ec9eb
commit
10d7493587
@ -173,4 +173,10 @@ void updateCGroupParam(CGroupController controller, String cGroupId,
|
|||||||
*/
|
*/
|
||||||
String getCGroupParam(CGroupController controller, String cGroupId,
|
String getCGroupParam(CGroupController controller, String cGroupId,
|
||||||
String param) throws ResourceHandlerException;
|
String param) throws ResourceHandlerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns CGroup Mount Path.
|
||||||
|
* @return parameter value as read from the parameter file
|
||||||
|
*/
|
||||||
|
String getCGroupMountPath();
|
||||||
}
|
}
|
||||||
|
@ -603,4 +603,9 @@ public String getCGroupParam(CGroupController controller, String cGroupId,
|
|||||||
"Unable to read from " + cGroupParamPath);
|
"Unable to read from " + cGroupParamPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCGroupMountPath() {
|
||||||
|
return cGroupMountPath;
|
||||||
|
}
|
||||||
}
|
}
|
@ -167,13 +167,12 @@ 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;
|
||||||
private Set<String> allowedNetworks = new HashSet<>();
|
private Set<String> allowedNetworks = new HashSet<>();
|
||||||
private String defaultNetwork;
|
private String defaultNetwork;
|
||||||
|
private String cgroupsRootDirectory;
|
||||||
private CGroupsHandler cGroupsHandler;
|
private CGroupsHandler cGroupsHandler;
|
||||||
private AccessControlList privilegedContainersAcl;
|
private AccessControlList privilegedContainersAcl;
|
||||||
|
|
||||||
@ -228,6 +227,7 @@ public DockerLinuxContainerRuntime(PrivilegedOperationExecutor
|
|||||||
LOG.info("cGroupsHandler is null - cgroups not in use.");
|
LOG.info("cGroupsHandler is null - cgroups not in use.");
|
||||||
} else {
|
} else {
|
||||||
this.cGroupsHandler = cGroupsHandler;
|
this.cGroupsHandler = cGroupsHandler;
|
||||||
|
this.cgroupsRootDirectory = cGroupsHandler.getCGroupMountPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,9 +486,12 @@ public void launchContainer(ContainerRuntimeContext ctx)
|
|||||||
.setContainerWorkDir(containerWorkDir.toString())
|
.setContainerWorkDir(containerWorkDir.toString())
|
||||||
.setNetworkType(network);
|
.setNetworkType(network);
|
||||||
setHostname(runCommand, containerIdStr, hostname);
|
setHostname(runCommand, containerIdStr, hostname);
|
||||||
runCommand.setCapabilities(capabilities)
|
runCommand.setCapabilities(capabilities);
|
||||||
.addMountLocation(CGROUPS_ROOT_DIRECTORY,
|
|
||||||
CGROUPS_ROOT_DIRECTORY + ":ro", false);
|
if(cgroupsRootDirectory != null) {
|
||||||
|
runCommand.addMountLocation(cgroupsRootDirectory,
|
||||||
|
cgroupsRootDirectory + ":ro", false);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> allDirs = new ArrayList<>(containerLocalDirs);
|
List<String> allDirs = new ArrayList<>(containerLocalDirs);
|
||||||
allDirs.addAll(filecacheDirs);
|
allDirs.addAll(filecacheDirs);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationExecutor;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationExecutor;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler;
|
||||||
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerModule;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker.DockerRunCommand;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.docker.DockerRunCommand;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeConstants;
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeConstants;
|
||||||
@ -261,12 +262,18 @@ private String getExpectedTestCapabilitiesArgumentString() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getExpectedCGroupsMountString() {
|
private String getExpectedCGroupsMountString() {
|
||||||
|
CGroupsHandler cgroupsHandler = ResourceHandlerModule.getCGroupsHandler();
|
||||||
|
if(cgroupsHandler == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String cgroupMountPath = cgroupsHandler.getCGroupMountPath();
|
||||||
boolean cGroupsMountExists = new File(
|
boolean cGroupsMountExists = new File(
|
||||||
DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY).exists();
|
cgroupMountPath).exists();
|
||||||
|
|
||||||
if(cGroupsMountExists) {
|
if(cGroupsMountExists) {
|
||||||
return "-v " + DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY
|
return "-v " + cgroupMountPath
|
||||||
+ ":" + DockerLinuxContainerRuntime.CGROUPS_ROOT_DIRECTORY + ":ro ";
|
+ ":" + cgroupMountPath + ":ro ";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user