Class RuncContainerRuntime
java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.OCIContainerRuntime
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.RuncContainerRuntime
- All Implemented Interfaces:
LinuxContainerRuntime,ContainerRuntime
This class is an extension of OCIContainerRuntime that uses the
native container-executor binary via a
PrivilegedOperationExecutor instance to launch processes inside
Runc containers.
The following environment variables are used to configure the Runc engine:
-
YARN_CONTAINER_RUNTIME_TYPEultimately determines whether a runC container will be used. If the value isrunc, a runC container will be used. Otherwise a regular process tree container will be used. This environment variable is checked by theisRuncContainerRequested(org.apache.hadoop.conf.Configuration, java.util.Map<java.lang.String, java.lang.String>)method, which is called by theDelegatingLinuxContainerRuntime. -
YARN_CONTAINER_RUNTIME_RUNC_IMAGEnames which image will be used to launch the Runc container. -
YARN_CONTAINER_RUNTIME_RUNC_MOUNTSallows users to specify additional volume mounts for the runC container. The value of the environment variable should be a comma-separated list of mounts. All such mounts must be given assource:dest[:mode]and the mode must be "ro" (read-only) or "rw" (read-write) to specify the type of access being requested. If neither is specified, read-write will be assumed. The requested mounts will be validated by container-executor based on the values set in container-executor.cfg forrunc.allowed.ro-mountsandrunc.allowed.rw-mounts. -
YARN_CONTAINER_RUNTIME_RUNC_CONTAINER_HOSTNAMEsets the hostname to be used by the Runc container. If not specified, a hostname will be derived from the container ID and set as default hostname for networks other than 'host'.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.OCIContainerRuntime
CONTAINER_PID_NAMESPACE_SUFFIX, RUN_PRIVILEGED_CONTAINER_SUFFIX, RUNTIME_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionRuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor) RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor, CGroupsHandler cGroupsHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected RuncImageTagToManifestPluginprotected RuncManifestToResourcesPluginorg.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPairRun a program in container.extractImageEntrypoint(File config) extractImageEnv(File config) getExposedPorts(Container container) Return the exposed ports of the container.String[]getIpAndHost(Container container) Return the host and ip of the container.getLocalResources(Container container) voidinitialize(org.apache.hadoop.conf.Configuration configuration, Context nmCtx) Initialize the runtime.static booleanisRuncContainerRequested(org.apache.hadoop.conf.Configuration daemonConf, Map<String, String> env) Return whether the given environment variables indicate that the operation is requesting a Runc container.booleanisRuntimeRequested(Map<String, String> env) Return whether the given environment variables indicate that the operation is requesting this runtime.voidLaunch a container.voidPerform any container cleanup that may be required.voidRelaunch a container.voidSignal a container.voidstart()voidstop()writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig, Container container) Methods inherited from class org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.OCIContainerRuntime
allowHostPidNamespace, allowPrivilegedContainerExecution, formatOciEnvKey, getCsiClients, getGroupIdInfo, getUserIdInfo, initiateCsiClients, isContainerRequestedAsPrivileged, isOCICompliantContainerRequested, mountReadOnlyPath, prepareContainer, validateContainerNetworkType, validateContainerRuntimeType, validateHostname
-
Field Details
-
ENV_RUNC_CONTAINER_IMAGE
- See Also:
-
ENV_RUNC_CONTAINER_MOUNTS
- See Also:
-
ENV_RUNC_CONTAINER_HOSTNAME
- See Also:
-
ENV_RUNC_CONTAINER_PID_NAMESPACE
-
ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER
-
-
Constructor Details
-
RuncContainerRuntime
-
RuncContainerRuntime
@VisibleForTesting public RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor, CGroupsHandler cGroupsHandler)
-
-
Method Details
-
initialize
public void initialize(org.apache.hadoop.conf.Configuration configuration, Context nmCtx) throws ContainerExecutionException Description copied from interface:LinuxContainerRuntimeInitialize the runtime.- Specified by:
initializein interfaceLinuxContainerRuntime- Overrides:
initializein classOCIContainerRuntime- Parameters:
configuration- theConfigurationto usenmCtx- NMContext- Throws:
ContainerExecutionException- if an error occurs while initializing the runtime
-
start
public void start() -
stop
public void stop() -
launchContainer
Description copied from interface:ContainerRuntimeLaunch a container.- Parameters:
ctx- theContainerRuntimeContext- Throws:
ContainerExecutionException- if an error occurs while launching the container
-
getLocalResources
public Map<String,org.apache.hadoop.yarn.api.records.LocalResource> getLocalResources(Container container) throws IOException - Throws:
IOException
-
chooseImageTagToManifestPlugin
protected RuncImageTagToManifestPlugin chooseImageTagToManifestPlugin() throws ContainerExecutionException- Throws:
ContainerExecutionException
-
chooseManifestToResourcesPlugin
protected RuncManifestToResourcesPlugin chooseManifestToResourcesPlugin() throws ContainerExecutionException- Throws:
ContainerExecutionException
-
extractImageEnv
- Throws:
IOException
-
extractImageEntrypoint
- Throws:
IOException
-
writeCommandToFile
public String writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig, Container container) throws ContainerExecutionException - Throws:
ContainerExecutionException
-
getExposedPorts
Description copied from interface:ContainerRuntimeReturn the exposed ports of the container.- Parameters:
container- theContainer- Returns:
- List of exposed ports
-
getIpAndHost
Description copied from interface:ContainerRuntimeReturn the host and ip of the container.- Parameters:
container- theContainer
-
execContainer
public org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair execContainer(ContainerExecContext ctx) throws ContainerExecutionException Description copied from interface:ContainerRuntimeRun a program in container.- Parameters:
ctx- theContainerExecContext- Returns:
- stdin and stdout of container exec
- Throws:
ContainerExecutionException
-
reapContainer
Description copied from interface:ContainerRuntimePerform any container cleanup that may be required.- Parameters:
ctx- theContainerRuntimeContext- Throws:
ContainerExecutionException- if an error occurs while reaping the container
-
relaunchContainer
Description copied from interface:ContainerRuntimeRelaunch a container.- Parameters:
ctx- theContainerRuntimeContext- Throws:
ContainerExecutionException- if an error occurs while relaunching the container
-
isRuncContainerRequested
public static boolean isRuncContainerRequested(org.apache.hadoop.conf.Configuration daemonConf, Map<String, String> env) Return whether the given environment variables indicate that the operation is requesting a Runc container. If the environment contains a key calledYARN_CONTAINER_RUNTIME_TYPEwhose value isrunc, this method will return true. Otherwise it will return false.- Parameters:
daemonConf- the NodeManager daemon configurationenv- the environment variable settings for the operation- Returns:
- whether a Runc container is requested
-
isRuntimeRequested
Description copied from interface:LinuxContainerRuntimeReturn whether the given environment variables indicate that the operation is requesting this runtime.- Parameters:
env- the environment variable settings for the operation- Returns:
- whether this runtime is requested
-
signalContainer
Description copied from interface:ContainerRuntimeSignal a container. Signals may be a request to terminate, a status check, etc.- Parameters:
ctx- theContainerRuntimeContext- Throws:
ContainerExecutionException- if an error occurs while signaling the container
-