RuncContainerRuntime extends OCIContainerRuntime { public static boolean isRuncContainerRequested(Configuration daemonConf, Map<String, String> env) { String type = (env == null) ? null : env.get(ContainerRuntimeConstants.ENV_CONTAINER_TYPE); if (type == null) { type = daemonConf.get(YarnConfiguration.LINUX_CONTAINER_RUNTIME_TYPE); } return type != null && type.equals( ContainerRuntimeConstants.CONTAINER_RUNTIME_RUNC); } RuncContainerRuntime(PrivilegedOperationExecutor
      privilegedOperationExecutor); @VisibleForTesting  RuncContainerRuntime(PrivilegedOperationExecutor
      privilegedOperationExecutor, CGroupsHandler cGroupsHandler); @Override void initialize(Configuration configuration, Context nmCtx); @Override void start(); @Override void stop(); @Override void launchContainer(ContainerRuntimeContext ctx); Map<String, LocalResource> getLocalResources(
      Container container); String writeCommandToFile(
      RuncContainerExecutorConfig runcContainerExecutorConfig,
      Container container); String getExposedPorts(Container container); String[] getIpAndHost(Container container); IOStreamPair execContainer(ContainerExecContext ctx); void reapContainer(ContainerRuntimeContext ctx); void relaunchContainer(ContainerRuntimeContext ctx); static boolean isRuncContainerRequested(Configuration daemonConf,
      Map<String, String> env); @Override boolean isRuntimeRequested(Map<String, String> env); @Override void signalContainer(ContainerRuntimeContext ctx); @InterfaceAudience.Private
  static final String ENV_RUNC_CONTAINER_IMAGE; @InterfaceAudience.Private
  static final String ENV_RUNC_CONTAINER_MOUNTS; @InterfaceAudience.Private
  static final String ENV_RUNC_CONTAINER_HOSTNAME; @InterfaceAudience.Private
  final static String ENV_RUNC_CONTAINER_PID_NAMESPACE; @InterfaceAudience.Private
  final static String ENV_RUNC_CONTAINER_RUN_PRIVILEGED_CONTAINER; }
@Test public void testSelectRuncContainerType() { Map<String, String> envRuncType = new HashMap<>(); Map<String, String> envOtherType = new HashMap<>(); envRuncType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, ContainerRuntimeConstants.CONTAINER_RUNTIME_RUNC); envOtherType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, "other"); Assert.assertFalse(RuncContainerRuntime .isRuncContainerRequested(conf, null)); Assert.assertTrue(RuncContainerRuntime .isRuncContainerRequested(conf, envRuncType)); Assert.assertFalse(RuncContainerRuntime .isRuncContainerRequested(conf, envOtherType)); }
@Test public void testSelectRuncContainerTypeWithRuncAsDefault() { Map<String, String> envRuncType = new HashMap<>(); Map<String, String> envOtherType = new HashMap<>(); conf.set(YarnConfiguration.LINUX_CONTAINER_RUNTIME_TYPE, ContainerRuntimeConstants.CONTAINER_RUNTIME_RUNC); envRuncType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, ContainerRuntimeConstants.CONTAINER_RUNTIME_RUNC); envOtherType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, "other"); Assert.assertTrue(RuncContainerRuntime .isRuncContainerRequested(conf, null)); Assert.assertTrue(RuncContainerRuntime .isRuncContainerRequested(conf, envRuncType)); Assert.assertFalse(RuncContainerRuntime .isRuncContainerRequested(conf, envOtherType)); }
@Test public void testSelectRuncContainerTypeWithDefaultSet() { Map<String, String> envRuncType = new HashMap<>(); Map<String, String> envOtherType = new HashMap<>(); conf.set(YarnConfiguration.LINUX_CONTAINER_RUNTIME_TYPE, "default"); envRuncType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, ContainerRuntimeConstants.CONTAINER_RUNTIME_RUNC); envOtherType.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, "other"); Assert.assertFalse(RuncContainerRuntime .isRuncContainerRequested(conf, null)); Assert.assertTrue(RuncContainerRuntime .isRuncContainerRequested(conf, envRuncType)); Assert.assertFalse(RuncContainerRuntime .isRuncContainerRequested(conf, envOtherType)); }