@InterfaceAudience.Private @InterfaceStability.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 and Description | 
|---|---|
| static String | ENV_RUNC_CONTAINER_HOSTNAME | 
| static String | ENV_RUNC_CONTAINER_IMAGE | 
| static String | ENV_RUNC_CONTAINER_MOUNTS | 
| static String | ENV_RUNC_CONTAINER_PID_NAMESPACE | 
| static String | ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER | 
CONTAINER_PID_NAMESPACE_SUFFIX, RUN_PRIVILEGED_CONTAINER_SUFFIX, RUNTIME_PREFIX| Constructor and Description | 
|---|
| RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor) | 
| RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor,
                    CGroupsHandler cGroupsHandler) | 
| Modifier and Type | Method and Description | 
|---|---|
| protected RuncImageTagToManifestPlugin | chooseImageTagToManifestPlugin() | 
| protected RuncManifestToResourcesPlugin | chooseManifestToResourcesPlugin() | 
| org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair | execContainer(ContainerExecContext ctx)Run a program in container. | 
| protected List<String> | extractImageEntrypoint(File config) | 
| protected List<String> | extractImageEnv(File config) | 
| String | getExposedPorts(Container container)Return the exposed ports of the container. | 
| String[] | getIpAndHost(Container container)Return the host and ip of the container. | 
| Map<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,
                        Map<String,String> env)Return whether the given environment variables indicate that the operation
 is requesting a Runc container. | 
| boolean | isRuntimeRequested(Map<String,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() | 
| String | writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig,
                  Container container) | 
allowHostPidNamespace, allowPrivilegedContainerExecution, formatOciEnvKey, getCsiClients, getGroupIdInfo, getUserIdInfo, initiateCsiClients, isContainerRequestedAsPrivileged, isOCICompliantContainerRequested, mountReadOnlyPath, prepareContainer, validateContainerNetworkType, validateContainerRuntimeType, validateHostname@InterfaceAudience.Private public static final String ENV_RUNC_CONTAINER_IMAGE
@InterfaceAudience.Private public static final String ENV_RUNC_CONTAINER_MOUNTS
@InterfaceAudience.Private public static final String ENV_RUNC_CONTAINER_HOSTNAME
@InterfaceAudience.Private public static final String ENV_RUNC_CONTAINER_PID_NAMESPACE
@InterfaceAudience.Private public static final String ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER
public RuncContainerRuntime(PrivilegedOperationExecutor privilegedOperationExecutor)
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 Map<String,org.apache.hadoop.yarn.api.records.LocalResource> getLocalResources(Container container) throws IOException
IOExceptionprotected RuncImageTagToManifestPlugin chooseImageTagToManifestPlugin() throws ContainerExecutionException
ContainerExecutionExceptionprotected RuncManifestToResourcesPlugin chooseManifestToResourcesPlugin() throws ContainerExecutionException
ContainerExecutionExceptionprotected List<String> extractImageEnv(File config) throws IOException
IOExceptionprotected List<String> extractImageEntrypoint(File config) throws IOException
IOExceptionpublic String writeCommandToFile(RuncContainerExecutorConfig runcContainerExecutorConfig, Container container) throws ContainerExecutionException
ContainerExecutionExceptionpublic String getExposedPorts(Container container)
ContainerRuntimecontainer - the Containerpublic 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,
                                               Map<String,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(Map<String,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–2023 Apache Software Foundation. All rights reserved.