Skip to content

Commit 7148ef6

Browse files
committed
common/pkg/cgroups: Remove linuxCpusetHandler.Create
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent ddb75f5 commit 7148ef6

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

common/pkg/cgroups/cgroups_linux.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -445,46 +445,6 @@ func cleanString(s string) string {
445445
return strings.Trim(s, "\n")
446446
}
447447

448-
func cpusetCopyFromParent(path string, cgroupv2 bool) error {
449-
for _, file := range []string{"cpuset.cpus", "cpuset.mems"} {
450-
if _, err := cpusetCopyFileFromParent(path, file, cgroupv2); err != nil {
451-
return err
452-
}
453-
}
454-
return nil
455-
}
456-
457-
func cpusetCopyFileFromParent(dir, file string, cgroupv2 bool) ([]byte, error) {
458-
if dir == cgroupRoot {
459-
return nil, fmt.Errorf("could not find parent to initialize cpuset %s", file)
460-
}
461-
path := filepath.Join(dir, file)
462-
parentPath := path
463-
if cgroupv2 {
464-
parentPath += ".effective"
465-
}
466-
data, err := os.ReadFile(parentPath)
467-
if err != nil {
468-
// if the file doesn't exist, it is likely that the cpuset controller
469-
// is not enabled in the kernel.
470-
if os.IsNotExist(err) {
471-
return nil, nil
472-
}
473-
return nil, err
474-
}
475-
if strings.Trim(string(data), "\n") != "" {
476-
return data, nil
477-
}
478-
data, err = cpusetCopyFileFromParent(filepath.Dir(dir), file, cgroupv2)
479-
if err != nil {
480-
return nil, err
481-
}
482-
if err := os.WriteFile(path, data, 0o644); err != nil {
483-
return nil, fmt.Errorf("write %s: %w", path, err)
484-
}
485-
return data, nil
486-
}
487-
488448
// SystemCPUUsage returns the system usage for all the cgroups.
489449
func SystemCPUUsage() (uint64, error) {
490450
_, err := IsCgroup2UnifiedMode()

common/pkg/cgroups/cpuset_linux.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ func (c *linuxCpusetHandler) Apply(ctr *CgroupControl, res *cgroups.Resources) e
2727
return man.Set(res)
2828
}
2929

30-
// Create the cgroup.
31-
func (c *linuxCpusetHandler) Create(ctr *CgroupControl) (bool, error) {
32-
path := filepath.Join(cgroupRoot, ctr.config.Path)
33-
return true, cpusetCopyFromParent(path, true)
34-
}
35-
3630
// Stat fills a metrics structure with usage stats for the controller.
3731
func (c *linuxCpusetHandler) Stat(_ *CgroupControl, _ *cgroups.Stats) error {
3832
return nil

0 commit comments

Comments
 (0)