Skip to content

Commit 3265e4e

Browse files
YARN-1964 Removed arbitrary docker options
This removes the option to provide arbitrary options to the docker run command for DockerContainerExecutor. Now the yarn administrator will set up the docker executor, and the user will provide the docker image. The docker image must container all resources and environment variables setup to run the users job.
1 parent 6951caf commit 3265e4e

File tree

10 files changed

+417
-351
lines changed

10 files changed

+417
-351
lines changed

hadoop-project/src/site/site.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<item name="YARN Commands" href="hadoop-yarn/hadoop-yarn-site/YarnCommands.html"/>
125125
<item name="Scheduler Load Simulator" href="hadoop-sls/SchedulerLoadSimulator.html"/>
126126
<item name="NodeManager Restart" href="hadoop-yarn/hadoop-yarn-site/NodeManagerRestart.html"/>
127+
<item name="DockerContainerExecutor" href="hadoop-yarn/hadoop-yarn-site/DockerContainerExecutor.html"/>
127128
</menu>
128129

129130
<menu name="YARN REST APIs" inherit="top">

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,6 @@ private static void addDeprecatedKeys() {
896896
public static final String NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME =
897897
NM_PREFIX + "docker-container-executor.image-name";
898898

899-
/** Args passed to docker run(For DockerContainerExecutor).*/
900-
public static final String NM_DOCKER_CONTAINER_EXECUTOR_RUN_ARGS =
901-
NM_PREFIX + "docker-container-executor.run-args";
902-
903899
/** The name of the docker executor (For DockerContainerExecutor).*/
904900
public static final String NM_DOCKER_CONTAINER_EXECUTOR_EXEC_NAME =
905901
NM_PREFIX + "docker-container-executor.exec-name";

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,22 +1147,6 @@
11471147
</property>
11481148

11491149
<!--Docker configuration-->
1150-
<property>
1151-
<name>yarn.nodemanager.docker-container-executor.image-name</name>
1152-
<value></value>
1153-
<description>
1154-
This image is used by all nodemanagers to launch containers.
1155-
This maybe modified by the users.
1156-
</description>
1157-
</property>
1158-
1159-
<property>
1160-
<name>yarn.nodemanager.docker-container-executor.run-args</name>
1161-
<value>--rm --net=host</value>
1162-
<description>
1163-
This arguments to pass to the 'docker run' invocation.
1164-
</description>
1165-
</property>
11661150

11671151
<property>
11681152
<name>yarn.nodemanager.docker-container-executor.exec-name</name>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ContainerExecutor.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020

2121
import java.io.File;
2222
import java.io.IOException;
23+
import java.io.OutputStream;
24+
import java.io.PrintStream;
2325
import java.net.InetSocketAddress;
2426
import java.util.ArrayList;
2527
import java.util.Arrays;
2628
import java.util.List;
29+
import java.util.Map;
2730
import java.util.concurrent.ConcurrentHashMap;
2831
import java.util.concurrent.ConcurrentMap;
2932
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -211,6 +214,34 @@ public int reacquireContainer(String user, ContainerId containerId)
211214
}
212215
}
213216

217+
public void writeLaunchEnv(OutputStream out, Map<String, String> environment, Map<Path, List<String>> resources, List<String> command) throws IOException{
218+
ContainerLaunch.ShellScriptBuilder sb = ContainerLaunch.ShellScriptBuilder.create();
219+
if (environment != null) {
220+
for (Map.Entry<String,String> env : environment.entrySet()) {
221+
sb.env(env.getKey().toString(), env.getValue().toString());
222+
}
223+
}
224+
if (resources != null) {
225+
for (Map.Entry<Path,List<String>> entry : resources.entrySet()) {
226+
for (String linkName : entry.getValue()) {
227+
sb.symlink(entry.getKey(), new Path(linkName));
228+
}
229+
}
230+
}
231+
232+
sb.command(command);
233+
234+
PrintStream pout = null;
235+
try {
236+
pout = new PrintStream(out);
237+
sb.write(pout);
238+
} finally {
239+
if (out != null) {
240+
out.close();
241+
}
242+
}
243+
}
244+
214245
public enum ExitCode {
215246
FORCE_KILLED(137),
216247
TERMINATED(143),

0 commit comments

Comments
 (0)