Skip to content

Commit fd5debf

Browse files
committed
libct/cg: rm GetInitCgroup[Path]
These functions were added in ancient times, facilitating the docker-in-docker case when cgroup namespace was not available. As pointed out in commit 2b28b3c, using init 1 cgroup is not correct because it won't work in case of host PID namespace. The last user of GetInitCgroup was removed by commit 54e2021. GetInitCgroupPath was never used as far as I can see, nor was I able to find any external users. Remove both functions. Modify the comment in libct/cg/fs.subsysPath to not refer to GetInitCgroupPath. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent cc60a39 commit fd5debf

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

libcontainer/cgroups/fs/paths.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ func subsysPath(root, inner, subsystem string) (string, error) {
164164
return filepath.Join(root, filepath.Base(mnt), inner), nil
165165
}
166166

167-
// Use GetOwnCgroupPath instead of GetInitCgroupPath, because the creating
168-
// process could in container and shared pid namespace with host, and
169-
// /proc/1/cgroup could point to whole other world of cgroups.
167+
// Use GetOwnCgroupPath for dind-like cases, when cgroupns is not
168+
// available. This is ugly.
170169
parentPath, err := cgroups.GetOwnCgroupPath(subsystem)
171170
if err != nil {
172171
return "", err

libcontainer/cgroups/v1_utils.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,6 @@ func GetOwnCgroupPath(subsystem string) (string, error) {
236236
return getCgroupPathHelper(subsystem, cgroup)
237237
}
238238

239-
func GetInitCgroup(subsystem string) (string, error) {
240-
if IsCgroup2UnifiedMode() {
241-
return "", errUnified
242-
}
243-
cgroups, err := ParseCgroupFile("/proc/1/cgroup")
244-
if err != nil {
245-
return "", err
246-
}
247-
248-
return getControllerPath(subsystem, cgroups)
249-
}
250-
251-
func GetInitCgroupPath(subsystem string) (string, error) {
252-
cgroup, err := GetInitCgroup(subsystem)
253-
if err != nil {
254-
return "", err
255-
}
256-
257-
return getCgroupPathHelper(subsystem, cgroup)
258-
}
259-
260239
func getCgroupPathHelper(subsystem, cgroup string) (string, error) {
261240
mnt, root, err := FindCgroupMountpointAndRoot("", subsystem)
262241
if err != nil {

0 commit comments

Comments
 (0)