diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 8dfaab4f0d8..48c2b72125e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -112,6 +112,9 @@ Release 2.3.0 - UNRELEASED YARN-1400. yarn.cmd uses HADOOP_RESOURCEMANAGER_OPTS. Should be YARN_RESOURCEMANAGER_OPTS. (Raja Aluri via cnauroth) + YARN-1401. With zero sleep-delay-before-sigkill.ms, no signal is ever sent + (Gera Shegalov via Sandy Ryza) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java index edc31466f67..8b08965b15d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/ContainerLaunch.java @@ -375,13 +375,19 @@ public class ContainerLaunch implements Callable { LOG.debug("Sending signal to pid " + processId + " as user " + user + " for container " + containerIdStr); + + final Signal signal = sleepDelayBeforeSigKill > 0 + ? Signal.TERM + : Signal.KILL; + + boolean result = exec.signalContainer(user, processId, signal); + + LOG.debug("Sent signal " + signal + " to pid " + processId + + " as user " + user + + " for container " + containerIdStr + + ", result=" + (result? "success" : "failed")); + if (sleepDelayBeforeSigKill > 0) { - boolean result = exec.signalContainer(user, - processId, Signal.TERM); - LOG.debug("Sent signal to pid " + processId - + " as user " + user - + " for container " + containerIdStr - + ", result=" + (result? "success" : "failed")); new DelayedProcessKiller(container, user, processId, sleepDelayBeforeSigKill, Signal.KILL, exec).start(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java index 2f0565d92c4..696ebb9796c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java @@ -97,7 +97,6 @@ public class TestContainerLaunch extends BaseContainerManagerTest { conf.setClass( YarnConfiguration.NM_CONTAINER_MON_RESOURCE_CALCULATOR, LinuxResourceCalculatorPlugin.class, ResourceCalculatorPlugin.class); - conf.setLong(YarnConfiguration.NM_SLEEP_DELAY_BEFORE_SIGKILL_MS, 1000); super.setup(); } @@ -590,8 +589,9 @@ public class TestContainerLaunch extends BaseContainerManagerTest { AuxiliaryServiceHelper.getServiceDataFromEnv(serviceName, env)); } - @Test - public void testDelayedKill() throws Exception { + private void internalKillTest(boolean delayed) throws Exception { + conf.setLong(YarnConfiguration.NM_SLEEP_DELAY_BEFORE_SIGKILL_MS, + delayed ? 1000 : 0); containerManager.start(); // ////// Construct the Container-id @@ -675,7 +675,8 @@ public class TestContainerLaunch extends BaseContainerManagerTest { BaseContainerManagerTest.waitForContainerState(containerManager, cId, ContainerState.COMPLETE); - // container stop sends a sigterm followed by a sigkill + // if delayed container stop sends a sigterm followed by a sigkill + // otherwise sigkill is sent immediately GetContainerStatusesRequest gcsRequest = GetContainerStatusesRequest.newInstance(containerIds); @@ -690,7 +691,7 @@ public class TestContainerLaunch extends BaseContainerManagerTest { // Windows, because the process is not notified when killed by winutils. // There is no way for the process to trap and respond. Instead, we can // verify that the job object with ID matching container ID no longer exists. - if (Shell.WINDOWS) { + if (Shell.WINDOWS || !delayed) { Assert.assertFalse("Process is still alive!", DefaultContainerExecutor.containerIsAlive(cId.toString())); } else { @@ -713,6 +714,16 @@ public class TestContainerLaunch extends BaseContainerManagerTest { } } + @Test + public void testDelayedKill() throws Exception { + internalKillTest(true); + } + + @Test + public void testImmediateKill() throws Exception { + internalKillTest(false); + } + @SuppressWarnings("rawtypes") @Test public void testCallFailureWithNullLocalizedResources() {