diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java index 9714731adf6..dbee0484ee5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java @@ -403,16 +403,6 @@ public abstract class ContainerExecutor implements Configurable { sb.env(env.getKey(), env.getValue()); } } - // Add the whitelist vars to the environment. Do this after writing - // environment variables so they are not written twice. - for(String var : whitelistVars) { - if (!environment.containsKey(var)) { - String val = getNMEnvVar(var); - if (val != null) { - environment.put(var, val); - } - } - } } if (resources != null) { 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 ab5d47e0fd0..9cfa6a5cd8e 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 @@ -468,10 +468,15 @@ public class TestContainerLaunch extends BaseContainerManagerTest { for (String envVar : env.keySet()) { Assert.assertTrue(shellContent.contains(envVar + "=")); } + // The whitelist vars should not have been added to env + // They should only be in the launch script for (String wlVar : whitelistVars) { + Assert.assertFalse(env.containsKey(wlVar)); Assert.assertTrue(shellContent.contains(wlVar + "=")); } + // Non-whitelist nm vars should be in neither env nor in launch script for (String nwlVar : nonWhiteListEnv) { + Assert.assertFalse(env.containsKey(nwlVar)); Assert.assertFalse(shellContent.contains(nwlVar + "=")); } // Explicitly Set NM vars should be before user vars