YARN-9391. Fixed node manager environment leaks into Docker containers.
Contributed by Jim Brennan
This commit is contained in:
parent
e5d72f504e
commit
3c45762a0b
|
@ -431,16 +431,6 @@ public abstract class ContainerExecutor implements Configurable {
|
||||||
sb.env(env.getKey(), env.getValue());
|
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) {
|
if (resources != null) {
|
||||||
|
|
|
@ -476,10 +476,15 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
||||||
for (String envVar : env.keySet()) {
|
for (String envVar : env.keySet()) {
|
||||||
Assert.assertTrue(shellContent.contains(envVar + "="));
|
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) {
|
for (String wlVar : whitelistVars) {
|
||||||
|
Assert.assertFalse(env.containsKey(wlVar));
|
||||||
Assert.assertTrue(shellContent.contains(wlVar + "="));
|
Assert.assertTrue(shellContent.contains(wlVar + "="));
|
||||||
}
|
}
|
||||||
|
// Non-whitelist nm vars should be in neither env nor in launch script
|
||||||
for (String nwlVar : nonWhiteListEnv) {
|
for (String nwlVar : nonWhiteListEnv) {
|
||||||
|
Assert.assertFalse(env.containsKey(nwlVar));
|
||||||
Assert.assertFalse(shellContent.contains(nwlVar + "="));
|
Assert.assertFalse(shellContent.contains(nwlVar + "="));
|
||||||
}
|
}
|
||||||
// Explicitly Set NM vars should be before user vars
|
// Explicitly Set NM vars should be before user vars
|
||||||
|
|
Loading…
Reference in New Issue