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

Contributed by Jim Brennan
This commit is contained in:
Eric Yang 2019-03-25 15:53:24 -04:00
parent e5d72f504e
commit 3c45762a0b
2 changed files with 5 additions and 10 deletions

View File

@ -431,16 +431,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

@ -476,10 +476,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