Skip to content

Commit 280cac0

Browse files
committed
YARN-11692. Added a new config for cgroups v2 mount path
Change-Id: I1de48e26ce0f827be16a7c435f240c14487d2baa
1 parent 543bd9f commit 280cac0

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,10 @@ public static boolean isAclEnabled(Configuration conf) {
27332733
public static final String NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH =
27342734
NM_PREFIX + "linux-container-executor.cgroups.mount-path";
27352735

2736+
/** Where the linux container executor should mount cgroups v2 if not found */
2737+
public static final String NM_LINUX_CONTAINER_CGROUPS_V2_MOUNT_PATH =
2738+
NM_PREFIX + "linux-container-executor.cgroups.v2.mount-path";
2739+
27362740
/**
27372741
* Whether the apps should run in strict resource usage mode(not allowed to
27382742
* use spare CPU)

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,20 @@
20872087
<name>yarn.nodemanager.linux-container-executor.cgroups.mount-path</name>
20882088
</property>
20892089

2090+
<property>
2091+
<description>This property sets the mount path for CGroups v2.
2092+
This parameter is optional, and needed to be set only in mixed mode,
2093+
when CGroups v2 is mounted in a different path than Cgroups v1.
2094+
For example, in hybrid mode, CGroups v1 controllers can be mounted in
2095+
/sys/fs/cgroup, while v2 can be mounted in /sys/fs/cgroup/unified folder.
2096+
2097+
If this value is not set, the value of
2098+
yarn.nodemanager.linux-container-executor.cgroups.mount-path
2099+
will be used for CGroups v2 as well.
2100+
</description>
2101+
<name>yarn.nodemanager.linux-container-executor.cgroups.v2.mount-path</name>
2102+
</property>
2103+
20902104
<property>
20912105
<description>Delay in ms between attempts to remove linux cgroup</description>
20922106
<name>yarn.nodemanager.linux-container-executor.cgroups.delete-delay-ms</name>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/CGroupsMountConfig.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525
public class CGroupsMountConfig {
2626
private final boolean enableMount;
2727
private final String mountPath;
28+
29+
// CGroups v2 mount path is only relevant in mixed CGroups v1/v2 mode,
30+
// where v2 can be mounted in a different folder than v1.
31+
private final String v2MountPath;
2832

2933
public CGroupsMountConfig(Configuration conf) {
3034
this.enableMount = conf.getBoolean(YarnConfiguration.
3135
NM_LINUX_CONTAINER_CGROUPS_MOUNT, false);
3236
this.mountPath = conf.get(YarnConfiguration.
3337
NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH, null);
38+
this.v2MountPath = conf.get(YarnConfiguration.
39+
NM_LINUX_CONTAINER_CGROUPS_V2_MOUNT_PATH, mountPath);
3440
}
3541

3642
public boolean ensureMountPathIsDefined() throws ResourceHandlerException {
@@ -62,11 +68,16 @@ public String getMountPath() {
6268
return mountPath;
6369
}
6470

71+
public String getV2MountPath() {
72+
return v2MountPath;
73+
}
74+
6575
@Override
6676
public String toString() {
6777
return "CGroupsMountConfig{" +
6878
"enableMount=" + enableMount +
69-
", mountPath='" + mountPath + '\'' +
79+
", mountPath='" + mountPath +
80+
", v2MountPath='" + v2MountPath + '\'' +
7081
'}';
7182
}
7283
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/CGroupsV2HandlerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ protected List<CGroupController> getCGroupControllers() {
9797
@Override
9898
protected Map<String, Set<String>> parsePreConfiguredMountPath() throws IOException {
9999
Map<String, Set<String>> controllerMappings = new HashMap<>();
100-
controllerMappings.put(this.cGroupsMountConfig.getMountPath(),
101-
readControllersFile(this.cGroupsMountConfig.getMountPath()));
100+
controllerMappings.put(this.cGroupsMountConfig.getV2MountPath(),
101+
readControllersFile(this.cGroupsMountConfig.getV2MountPath()));
102102
return controllerMappings;
103103
}
104104

0 commit comments

Comments
 (0)