mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Improve the getCgroupSubsystemsV1() which uses random record per subsystem
returned by libcontainercgroups.GetCgroupMounts(). Example array from GetCgroupMounts(): ``` [ { Mountpoint: "/sys/fs/cgroup/systemd", Root: "/", Subsystems: []string len: 1, cap: 1, ["systemd"],}, { Mountpoint: "/sys/fs/cgroup/cpu,cpuacct", Root: "/", Subsystems: []string len: 2, cap: 2, ["cpu","cpuacct"],}, { Mountpoint: "/sys/fs/cgroup/systemd/some/path", Root: "/some/path", Subsystems: []string len: 1, cap: 1, ["systemd"],}, ] ``` becames a map: ``` [ "memory": "/sys/fs/cgroup/memory/kubepods", "systemd": "/sys/fs/cgroup/systemd/some/path", ] ``` which seems to be wrong. Using shortest path of mountpoint per subsystem would be more reliable. reference issue: https://github.com/kubernetes/kubernetes/issues/95488
This commit is contained in:
parent
d20e3246ba
commit
de60340e51
@ -202,8 +202,16 @@ func getCgroupSubsystemsV1() (*CgroupSubsystems, error) {
|
|||||||
}
|
}
|
||||||
mountPoints := make(map[string]string, len(allCgroups))
|
mountPoints := make(map[string]string, len(allCgroups))
|
||||||
for _, mount := range allCgroups {
|
for _, mount := range allCgroups {
|
||||||
|
// BEFORE kubelet used a random mount point per cgroups subsystem;
|
||||||
|
// NOW more deterministic: kubelet use mount point with shortest path;
|
||||||
|
// FUTURE is bright with clear expectation determined in doc.
|
||||||
|
// ref. issue: https://github.com/kubernetes/kubernetes/issues/95488
|
||||||
|
|
||||||
for _, subsystem := range mount.Subsystems {
|
for _, subsystem := range mount.Subsystems {
|
||||||
mountPoints[subsystem] = mount.Mountpoint
|
previous := mountPoints[subsystem]
|
||||||
|
if previous == "" || len(mount.Mountpoint) < len(previous) {
|
||||||
|
mountPoints[subsystem] = mount.Mountpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &CgroupSubsystems{
|
return &CgroupSubsystems{
|
||||||
|
Loading…
Reference in New Issue
Block a user