LinuxContainerRuntime, ContainerRuntime@Private @Unstable public class RuncContainerRuntime extends OCIContainerRuntime
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_TYPE ultimately determines whether a
runC container will be used. If the value is runc, a runC
container will be used. Otherwise a regular process tree container will
be used. This environment variable is checked by the
isRuncContainerRequested(org.apache.hadoop.conf.Configuration, java.util.Map<java.lang.String, java.lang.String>) method, which is called by the
DelegatingLinuxContainerRuntime.
YARN_CONTAINER_RUNTIME_RUNC_IMAGE names which image
will be used to launch the Runc container.
YARN_CONTAINER_RUNTIME_RUNC_MOUNTS allows 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 as source: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 for
runc.allowed.ro-mounts and runc.allowed.rw-mounts.
YARN_CONTAINER_RUNTIME_RUNC_CONTAINER_HOSTNAME sets 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'.
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
ENV_RUNC_CONTAINER_HOSTNAME |
|
static java.lang.String |
ENV_RUNC_CONTAINER_IMAGE |
|
static java.lang.String |
ENV_RUNC_CONTAINER_MOUNTS |
|
static java.lang.String |
ENV_RUNC_CONTAINER_PID_NAMESPACE |
|
static java.lang.String |
ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER |
CONTAINER_PID_NAMESPACE_SUFFIX, RUN_PRIVILEGED_CONTAINER_SUFFIX, RUNTIME_PREFIX| Constructor | Description |
|---|---|
RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor) |
|
RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor,
CGroupsHandler cGroupsHandler) |
| Modifier and Type | Method | Description |
|---|---|---|
protected RuncImageTagToManifestPlugin |
chooseImageTagToManifestPlugin() |
|
protected RuncManifestToResourcesPlugin |
chooseManifestToResourcesPlugin() |
|
org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair |
execContainer(ContainerExecContext ctx) |
Run a program in container.
|
protected java.util.List<java.lang.String> |
extractImageEntrypoint(java.io.File config) |
|
protected java.util.List<java.lang.String> |
extractImageEnv(java.io.File config) |
|
java.lang.String |
getExposedPorts(Container container) |
Return the exposed ports of the container.
|
java.lang.String[] |
getIpAndHost(Container container) |
Return the host and ip of the container.
|
java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> |
getLocalResources(Container container) |
|
void |
initialize(org.apache.hadoop.conf.Configuration configuration,
Context nmCtx) |
Initialize the runtime.
|
static boolean |
isRuncContainerRequested(org.apache.hadoop.conf.Configuration daemonConf,
java.util.Map<java.lang.String,java.lang.String> env) |
Return whether the given environment variables indicate that the operation
is requesting a Runc container.
|
boolean |
isRuntimeRequested(java.util.Map<java.lang.String,java.lang.String> env) |
Return whether the given environment variables indicate that the operation
is requesting this runtime.
|
void |
launchContainer(ContainerRuntimeContext ctx) |
Launch a container.
|
void |
reapContainer(ContainerRuntimeContext ctx) |
Perform any container cleanup that may be required.
|
void |
relaunchContainer(ContainerRuntimeContext ctx) |
Relaunch a container.
|
void |
signalContainer(ContainerRuntimeContext ctx) |
Signal a container.
|
void |
start() |
|
void |
stop() |
|
java.lang.String |
writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig,
Container container) |
allowHostPidNamespace, allowPrivilegedContainerExecution, formatOciEnvKey, getCsiClients, getGroupIdInfo, getUserIdInfo, initiateCsiClients, isContainerRequestedAsPrivileged, isOCICompliantContainerRequested, mountReadOnlyPath, prepareContainer, validateContainerNetworkType, validateContainerRuntimeType, validateHostname@Private public static final java.lang.String ENV_RUNC_CONTAINER_IMAGE
@Private public static final java.lang.String ENV_RUNC_CONTAINER_MOUNTS
@Private public static final java.lang.String ENV_RUNC_CONTAINER_HOSTNAME
@Private public static final java.lang.String ENV_RUNC_CONTAINER_PID_NAMESPACE
@Private public static final java.lang.String ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER
public RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor)
@VisibleForTesting public RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor, CGroupsHandler cGroupsHandler)
public void initialize(org.apache.hadoop.conf.Configuration configuration,
Context nmCtx)
throws ContainerExecutionException
LinuxContainerRuntimeinitialize in interface LinuxContainerRuntimeinitialize in class OCIContainerRuntimeconfiguration - the Configuration to usenmCtx - NMContextContainerExecutionException - if an error occurs while initializing
the runtimepublic void start()
public void stop()
public void launchContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException
ContainerRuntimectx - the ContainerRuntimeContextContainerExecutionException - if an error occurs while launching
the containerpublic java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> getLocalResources(Container container) throws java.io.IOException
java.io.IOExceptionprotected RuncImageTagToManifestPlugin chooseImageTagToManifestPlugin() throws ContainerExecutionException
ContainerExecutionExceptionprotected RuncManifestToResourcesPlugin chooseManifestToResourcesPlugin() throws ContainerExecutionException
ContainerExecutionExceptionprotected java.util.List<java.lang.String> extractImageEnv(java.io.File config)
throws java.io.IOException
java.io.IOExceptionprotected java.util.List<java.lang.String> extractImageEntrypoint(java.io.File config)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig, Container container) throws ContainerExecutionException
ContainerExecutionExceptionpublic java.lang.String getExposedPorts(Container container)
ContainerRuntimecontainer - the Containerpublic java.lang.String[] getIpAndHost(Container container)
ContainerRuntimecontainer - the Containerpublic org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair execContainer(ContainerExecContext ctx) throws ContainerExecutionException
ContainerRuntimectx - the ContainerExecContextContainerExecutionExceptionpublic void reapContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException
ContainerRuntimectx - the ContainerRuntimeContextContainerExecutionException - if an error occurs while reaping
the containerpublic void relaunchContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException
ContainerRuntimectx - the ContainerRuntimeContextContainerExecutionException - if an error occurs while relaunching
the containerpublic static boolean isRuncContainerRequested(org.apache.hadoop.conf.Configuration daemonConf,
java.util.Map<java.lang.String,java.lang.String> env)
YARN_CONTAINER_RUNTIME_TYPE whose value is runc,
this method will return true. Otherwise it will return false.daemonConf - the NodeManager daemon configurationenv - the environment variable settings for the operationpublic boolean isRuntimeRequested(java.util.Map<java.lang.String,java.lang.String> env)
LinuxContainerRuntimeenv - the environment variable settings for the operationpublic void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException
ContainerRuntimectx - the ContainerRuntimeContextContainerExecutionException - if an error occurs while signaling
the containerCopyright © 2008–2025 Apache Software Foundation. All rights reserved.