YARN-9391. Fixed node manager environment leaks into Docker containers.

Contributed by Jim Brennan

(cherry picked from commit 3c45762a0b)
This commit is contained in:
Eric Yang 2019-03-25 15:53:24 -04:00
parent ade3af6ef2
commit 10642a6205
2 changed files with 5 additions and 10 deletions

View File

@ -406,16 +406,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) {

View File

@ -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