Skip to content

Commit 233359b

Browse files
committed
YARN-2424. LCE should support non-cgroups, non-secure mode (Chris Douglas via aw)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1619421 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0c648ba commit 233359b

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

hadoop-yarn-project/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ Release 2.6.0 - UNRELEASED
226226
YARN-1919. Potential NPE in EmbeddedElectorService#stop.
227227
(Tsuyoshi Ozawa via kasha)
228228

229+
YARN-2424. LCE should support non-cgroups, non-secure mode (Chris Douglas
230+
via aw)
231+
229232
Release 2.5.0 - 2014-08-11
230233

231234
INCOMPATIBLE CHANGES

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,15 @@ public class YarnConfiguration extends Configuration {
836836
public static final String NM_LINUX_CONTAINER_GROUP =
837837
NM_PREFIX + "linux-container-executor.group";
838838

839+
/**
840+
* True if linux-container-executor should limit itself to one user
841+
* when running in non-secure mode.
842+
*/
843+
public static final String NM_NONSECURE_MODE_LIMIT_USERS = NM_PREFIX +
844+
"linux-container-executor.nonsecure-mode.limit-users";
845+
846+
public static final boolean DEFAULT_NM_NONSECURE_MODE_LIMIT_USERS = true;
847+
839848
/**
840849
* The UNIX user that containers will run as when Linux-container-executor
841850
* is used in nonsecure mode (a use case for this is using cgroups).

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,22 @@
991991
</property>
992992

993993
<property>
994-
<description>The UNIX user that containers will run as when Linux-container-executor
995-
is used in nonsecure mode (a use case for this is using cgroups).</description>
994+
<description>This determines which of the two modes that LCE should use on
995+
a non-secure cluster. If this value is set to true, then all containers
996+
will be launched as the user specified in
997+
yarn.nodemanager.linux-container-executor.nonsecure-mode.local-user. If
998+
this value is set to false, then containers will run as the user who
999+
submitted the application.</description>
1000+
<name>yarn.nodemanager.linux-container-executor.nonsecure-mode.limit-users</name>
1001+
<value>true</value>
1002+
</property>
1003+
1004+
<property>
1005+
<description>The UNIX user that containers will run as when
1006+
Linux-container-executor is used in nonsecure mode (a use case for this
1007+
is using cgroups) if the
1008+
yarn.nodemanager.linux-container-executor.nonsecure-mode.limit-users is
1009+
set to true.</description>
9961010
<name>yarn.nodemanager.linux-container-executor.nonsecure-mode.local-user</name>
9971011
<value>nobody</value>
9981012
</property>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public class LinuxContainerExecutor extends ContainerExecutor {
5757
private LCEResourcesHandler resourcesHandler;
5858
private boolean containerSchedPriorityIsSet = false;
5959
private int containerSchedPriorityAdjustment = 0;
60-
61-
60+
private boolean containerLimitUsers;
61+
6262
@Override
6363
public void setConf(Configuration conf) {
6464
super.setConf(conf);
@@ -81,6 +81,13 @@ public void setConf(Configuration conf) {
8181
nonsecureLocalUserPattern = Pattern.compile(
8282
conf.get(YarnConfiguration.NM_NONSECURE_MODE_USER_PATTERN_KEY,
8383
YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_USER_PATTERN));
84+
containerLimitUsers = conf.getBoolean(
85+
YarnConfiguration.NM_NONSECURE_MODE_LIMIT_USERS,
86+
YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LIMIT_USERS);
87+
if (!containerLimitUsers) {
88+
LOG.warn(YarnConfiguration.NM_NONSECURE_MODE_LIMIT_USERS +
89+
": impersonation without authentication enabled");
90+
}
8491
}
8592

8693
void verifyUsernamePattern(String user) {
@@ -92,7 +99,12 @@ void verifyUsernamePattern(String user) {
9299
}
93100

94101
String getRunAsUser(String user) {
95-
return UserGroupInformation.isSecurityEnabled() ? user : nonsecureLocalUser;
102+
if (UserGroupInformation.isSecurityEnabled() ||
103+
!containerLimitUsers) {
104+
return user;
105+
} else {
106+
return nonsecureLocalUser;
107+
}
96108
}
97109

98110
/**

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ public void testLocalUser() throws Exception {
279279
lce.setConf(conf);
280280
Assert.assertEquals("bar", lce.getRunAsUser("foo"));
281281

282+
//nonsecure without limits
283+
conf.set(YarnConfiguration.NM_NONSECURE_MODE_LOCAL_USER_KEY, "bar");
284+
conf.setBoolean(YarnConfiguration.NM_NONSECURE_MODE_LIMIT_USERS, false);
285+
lce = new LinuxContainerExecutor();
286+
lce.setConf(conf);
287+
Assert.assertEquals("foo", lce.getRunAsUser("foo"));
288+
282289
//secure
283290
conf = new YarnConfiguration();
284291
conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,

0 commit comments

Comments
 (0)