Skip to content

Commit 5f98dfb

Browse files
committed
Remove Destroy method from controllerHandler
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent ceaec36 commit 5f98dfb

File tree

6 files changed

+0
-42
lines changed

6 files changed

+0
-42
lines changed

common/pkg/cgroups/blkio_linux.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ func (c *linuxBlkioHandler) Apply(ctr *CgroupControl, res *cgroups.Resources) er
2929
return man.Set(res)
3030
}
3131

32-
// Destroy the cgroup.
33-
func (c *linuxBlkioHandler) Destroy(ctr *CgroupControl) error {
34-
return rmDirRecursively(ctr.getCgroupv1Path(Blkio))
35-
}
36-
3732
// Stat fills a metrics structure with usage stats for the controller.
3833
func (c *linuxBlkioHandler) Stat(ctr *CgroupControl, m *cgroups.Stats) error {
3934
var ioServiceBytesRecursive []cgroups.BlkioStatEntry

common/pkg/cgroups/cgroups_linux.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/godbus/dbus/v5"
2222
"github.com/opencontainers/cgroups"
2323
"github.com/opencontainers/cgroups/fs2"
24-
"github.com/sirupsen/logrus"
2524
"go.podman.io/storage/pkg/fileutils"
2625
"go.podman.io/storage/pkg/unshare"
2726
"golang.org/x/sys/unix"
@@ -52,7 +51,6 @@ type controller struct {
5251

5352
type controllerHandler interface {
5453
Apply(*CgroupControl, *cgroups.Resources) error
55-
Destroy(*CgroupControl) error
5654
Stat(*CgroupControl, *cgroups.Stats) error
5755
}
5856

@@ -150,23 +148,8 @@ func getCgroupPathForCurrentProcess() (string, error) {
150148
return cgroupPath, nil
151149
}
152150

153-
// getCgroupv1Path is a helper function to get the cgroup v1 path.
154-
func (c *CgroupControl) getCgroupv1Path(name string) string {
155-
return filepath.Join(cgroupRoot, name, c.config.Path)
156-
}
157-
158151
// initialize initializes the specified hierarchy.
159152
func (c *CgroupControl) initialize() (err error) {
160-
createdSoFar := map[string]controllerHandler{}
161-
defer func() {
162-
if err != nil {
163-
for name, ctr := range createdSoFar {
164-
if err := ctr.Destroy(c); err != nil {
165-
logrus.Warningf("error cleaning up controller %s for %s", name, c.config.Path)
166-
}
167-
}
168-
}
169-
}()
170153
if err := createCgroupv2Path(filepath.Join(cgroupRoot, c.config.Path)); err != nil {
171154
return fmt.Errorf("creating cgroup path %s: %w", c.config.Path, err)
172155
}

common/pkg/cgroups/cpu_linux.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ func (c *linuxCPUHandler) Apply(ctr *CgroupControl, res *cgroups.Resources) erro
2828
return man.Set(res)
2929
}
3030

31-
// Destroy the cgroup.
32-
func (c *linuxCPUHandler) Destroy(ctr *CgroupControl) error {
33-
return rmDirRecursively(ctr.getCgroupv1Path(CPU))
34-
}
35-
3631
// Stat fills a metrics structure with usage stats for the controller.
3732
func (c *linuxCPUHandler) Stat(ctr *CgroupControl, m *cgroups.Stats) error {
3833
cpu := cgroups.CpuStats{}

common/pkg/cgroups/cpuset_linux.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func (c *linuxCpusetHandler) Create(ctr *CgroupControl) (bool, error) {
3333
return true, cpusetCopyFromParent(path, true)
3434
}
3535

36-
// Destroy the cgroup.
37-
func (c *linuxCpusetHandler) Destroy(ctr *CgroupControl) error {
38-
return rmDirRecursively(ctr.getCgroupv1Path(CPUset))
39-
}
40-
4136
// Stat fills a metrics structure with usage stats for the controller.
4237
func (c *linuxCpusetHandler) Stat(_ *CgroupControl, _ *cgroups.Stats) error {
4338
return nil

common/pkg/cgroups/memory_linux.go

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

30-
// Destroy the cgroup.
31-
func (c *linuxMemHandler) Destroy(ctr *CgroupControl) error {
32-
return rmDirRecursively(ctr.getCgroupv1Path(Memory))
33-
}
34-
3530
// Stat fills a metrics structure with usage stats for the controller.
3631
func (c *linuxMemHandler) Stat(ctr *CgroupControl, m *cgroups.Stats) error {
3732
var err error

common/pkg/cgroups/pids_linux.go

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

30-
// Destroy the cgroup.
31-
func (c *linuxPidHandler) Destroy(ctr *CgroupControl) error {
32-
return rmDirRecursively(ctr.getCgroupv1Path(Pids))
33-
}
34-
3530
// Stat fills a metrics structure with usage stats for the controller.
3631
func (c *linuxPidHandler) Stat(ctr *CgroupControl, m *cgroups.Stats) error {
3732
if ctr.config.Path == "" {

0 commit comments

Comments
 (0)