diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go index f3ecd4b12..748bc0438 100644 --- a/libcontainer/cgroups/fs/apply_raw.go +++ b/libcontainer/cgroups/fs/apply_raw.go @@ -52,10 +52,10 @@ type subsystem interface { Name() string // Returns the stats, as 'stats', corresponding to the cgroup under 'path'. GetStats(path string, stats *cgroups.Stats) error - // Removes the cgroup represented by 'data'. - Remove(*data) error - // Creates and joins the cgroup represented by data. - Apply(*data) error + // Removes the cgroup represented by 'cgroupData'. + Remove(*cgroupData) error + // Creates and joins the cgroup represented by 'cgroupData'. + Apply(*cgroupData) error // Set the cgroup represented by cgroup. Set(path string, cgroup *configs.Cgroup) error } @@ -92,7 +92,7 @@ func getCgroupRoot() (string, error) { return cgroupRoot, nil } -type data struct { +type cgroupData struct { root string cgroup string c *configs.Cgroup @@ -229,7 +229,7 @@ func (m *Manager) GetPids() ([]int, error) { return cgroups.GetPids(dir) } -func getCgroupData(c *configs.Cgroup, pid int) (*data, error) { +func getCgroupData(c *configs.Cgroup, pid int) (*cgroupData, error) { root, err := getCgroupRoot() if err != nil { return nil, err @@ -240,7 +240,7 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) { cgroup = filepath.Join(c.Parent, cgroup) } - return &data{ + return &cgroupData{ root: root, cgroup: cgroup, c: c, @@ -248,7 +248,7 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) { }, nil } -func (raw *data) parent(subsystem, mountpoint, root string) (string, error) { +func (raw *cgroupData) parentPath(subsystem, mountpoint, root string) (string, error) { initPath, err := cgroups.GetThisCgroupDir(subsystem) if err != nil { return "", err @@ -260,7 +260,7 @@ func (raw *data) parent(subsystem, mountpoint, root string) (string, error) { return filepath.Join(mountpoint, relDir), nil } -func (raw *data) path(subsystem string) (string, error) { +func (raw *cgroupData) path(subsystem string) (string, error) { mnt, root, err := cgroups.FindCgroupMountpointAndRoot(subsystem) // If we didn't mount the subsystem, there is no point we make the path. if err != nil { @@ -272,15 +272,15 @@ func (raw *data) path(subsystem string) (string, error) { return filepath.Join(raw.root, filepath.Base(mnt), raw.cgroup), nil } - parent, err := raw.parent(subsystem, mnt, root) + parentPath, err := raw.parentPath(subsystem, mnt, root) if err != nil { return "", err } - return filepath.Join(parent, raw.cgroup), nil + return filepath.Join(parentPath, raw.cgroup), nil } -func (raw *data) join(subsystem string) (string, error) { +func (raw *cgroupData) join(subsystem string) (string, error) { path, err := raw.path(subsystem) if err != nil { return "", err diff --git a/libcontainer/cgroups/fs/blkio.go b/libcontainer/cgroups/fs/blkio.go index 0cb65cb98..8e51e887d 100644 --- a/libcontainer/cgroups/fs/blkio.go +++ b/libcontainer/cgroups/fs/blkio.go @@ -21,7 +21,7 @@ func (s *BlkioGroup) Name() string { return "blkio" } -func (s *BlkioGroup) Apply(d *data) error { +func (s *BlkioGroup) Apply(d *cgroupData) error { dir, err := d.join("blkio") if err != nil && !cgroups.IsNotFound(err) { return err @@ -78,7 +78,7 @@ func (s *BlkioGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *BlkioGroup) Remove(d *data) error { +func (s *BlkioGroup) Remove(d *cgroupData) error { return removePath(d.path("blkio")) } diff --git a/libcontainer/cgroups/fs/cpu.go b/libcontainer/cgroups/fs/cpu.go index 5161a7a61..2eff183f3 100644 --- a/libcontainer/cgroups/fs/cpu.go +++ b/libcontainer/cgroups/fs/cpu.go @@ -19,7 +19,7 @@ func (s *CpuGroup) Name() string { return "cpu" } -func (s *CpuGroup) Apply(d *data) error { +func (s *CpuGroup) Apply(d *cgroupData) error { // We always want to join the cpu group, to allow fair cpu scheduling // on a container basis dir, err := d.join("cpu") @@ -64,7 +64,7 @@ func (s *CpuGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *CpuGroup) Remove(d *data) error { +func (s *CpuGroup) Remove(d *cgroupData) error { return removePath(d.path("cpu")) } diff --git a/libcontainer/cgroups/fs/cpuacct.go b/libcontainer/cgroups/fs/cpuacct.go index c855fb323..53afbaddf 100644 --- a/libcontainer/cgroups/fs/cpuacct.go +++ b/libcontainer/cgroups/fs/cpuacct.go @@ -28,7 +28,7 @@ func (s *CpuacctGroup) Name() string { return "cpuacct" } -func (s *CpuacctGroup) Apply(d *data) error { +func (s *CpuacctGroup) Apply(d *cgroupData) error { // we just want to join this group even though we don't set anything if _, err := d.join("cpuacct"); err != nil && !cgroups.IsNotFound(err) { return err @@ -41,7 +41,7 @@ func (s *CpuacctGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *CpuacctGroup) Remove(d *data) error { +func (s *CpuacctGroup) Remove(d *cgroupData) error { return removePath(d.path("cpuacct")) } diff --git a/libcontainer/cgroups/fs/cpuset.go b/libcontainer/cgroups/fs/cpuset.go index 19c27bde8..b0bc08b91 100644 --- a/libcontainer/cgroups/fs/cpuset.go +++ b/libcontainer/cgroups/fs/cpuset.go @@ -20,7 +20,7 @@ func (s *CpusetGroup) Name() string { return "cpuset" } -func (s *CpusetGroup) Apply(d *data) error { +func (s *CpusetGroup) Apply(d *cgroupData) error { dir, err := d.path("cpuset") if err != nil && !cgroups.IsNotFound(err) { return err @@ -42,7 +42,7 @@ func (s *CpusetGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *CpusetGroup) Remove(d *data) error { +func (s *CpusetGroup) Remove(d *cgroupData) error { return removePath(d.path("cpuset")) } diff --git a/libcontainer/cgroups/fs/devices.go b/libcontainer/cgroups/fs/devices.go index dfd20601c..39fa82b39 100644 --- a/libcontainer/cgroups/fs/devices.go +++ b/libcontainer/cgroups/fs/devices.go @@ -14,7 +14,7 @@ func (s *DevicesGroup) Name() string { return "devices" } -func (s *DevicesGroup) Apply(d *data) error { +func (s *DevicesGroup) Apply(d *cgroupData) error { dir, err := d.join("devices") if err != nil { // We will return error even it's `not found` error, devices @@ -56,7 +56,7 @@ func (s *DevicesGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *DevicesGroup) Remove(d *data) error { +func (s *DevicesGroup) Remove(d *cgroupData) error { return removePath(d.path("devices")) } diff --git a/libcontainer/cgroups/fs/freezer.go b/libcontainer/cgroups/fs/freezer.go index b6df93ea8..79170cda4 100644 --- a/libcontainer/cgroups/fs/freezer.go +++ b/libcontainer/cgroups/fs/freezer.go @@ -18,7 +18,7 @@ func (s *FreezerGroup) Name() string { return "freezer" } -func (s *FreezerGroup) Apply(d *data) error { +func (s *FreezerGroup) Apply(d *cgroupData) error { dir, err := d.join("freezer") if err != nil && !cgroups.IsNotFound(err) { return err @@ -57,7 +57,7 @@ func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *FreezerGroup) Remove(d *data) error { +func (s *FreezerGroup) Remove(d *cgroupData) error { return removePath(d.path("freezer")) } diff --git a/libcontainer/cgroups/fs/hugetlb.go b/libcontainer/cgroups/fs/hugetlb.go index 1c2f7f78f..e9ced13b9 100644 --- a/libcontainer/cgroups/fs/hugetlb.go +++ b/libcontainer/cgroups/fs/hugetlb.go @@ -18,7 +18,7 @@ func (s *HugetlbGroup) Name() string { return "hugetlb" } -func (s *HugetlbGroup) Apply(d *data) error { +func (s *HugetlbGroup) Apply(d *cgroupData) error { dir, err := d.join("hugetlb") if err != nil && !cgroups.IsNotFound(err) { return err @@ -41,7 +41,7 @@ func (s *HugetlbGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *HugetlbGroup) Remove(d *data) error { +func (s *HugetlbGroup) Remove(d *cgroupData) error { return removePath(d.path("hugetlb")) } diff --git a/libcontainer/cgroups/fs/memory.go b/libcontainer/cgroups/fs/memory.go index dd3184959..3e83bbac2 100644 --- a/libcontainer/cgroups/fs/memory.go +++ b/libcontainer/cgroups/fs/memory.go @@ -21,7 +21,7 @@ func (s *MemoryGroup) Name() string { return "memory" } -func (s *MemoryGroup) Apply(d *data) (err error) { +func (s *MemoryGroup) Apply(d *cgroupData) (err error) { path, err := d.path("memory") if err != nil && !cgroups.IsNotFound(err) { return err @@ -94,7 +94,7 @@ func (s *MemoryGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *MemoryGroup) Remove(d *data) error { +func (s *MemoryGroup) Remove(d *cgroupData) error { return removePath(d.path("memory")) } diff --git a/libcontainer/cgroups/fs/name.go b/libcontainer/cgroups/fs/name.go index 264d0eead..0e423f667 100644 --- a/libcontainer/cgroups/fs/name.go +++ b/libcontainer/cgroups/fs/name.go @@ -15,7 +15,7 @@ func (s *NameGroup) Name() string { return s.GroupName } -func (s *NameGroup) Apply(d *data) error { +func (s *NameGroup) Apply(d *cgroupData) error { return nil } @@ -23,7 +23,7 @@ func (s *NameGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *NameGroup) Remove(d *data) error { +func (s *NameGroup) Remove(d *cgroupData) error { return nil } diff --git a/libcontainer/cgroups/fs/net_cls.go b/libcontainer/cgroups/fs/net_cls.go index 35df2f594..985f80b45 100644 --- a/libcontainer/cgroups/fs/net_cls.go +++ b/libcontainer/cgroups/fs/net_cls.go @@ -14,7 +14,7 @@ func (s *NetClsGroup) Name() string { return "net_cls" } -func (s *NetClsGroup) Apply(d *data) error { +func (s *NetClsGroup) Apply(d *cgroupData) error { dir, err := d.join("net_cls") if err != nil && !cgroups.IsNotFound(err) { return err @@ -37,7 +37,7 @@ func (s *NetClsGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *NetClsGroup) Remove(d *data) error { +func (s *NetClsGroup) Remove(d *cgroupData) error { return removePath(d.path("net_cls")) } diff --git a/libcontainer/cgroups/fs/net_prio.go b/libcontainer/cgroups/fs/net_prio.go index 294ff098f..90fc23f1b 100644 --- a/libcontainer/cgroups/fs/net_prio.go +++ b/libcontainer/cgroups/fs/net_prio.go @@ -14,7 +14,7 @@ func (s *NetPrioGroup) Name() string { return "net_prio" } -func (s *NetPrioGroup) Apply(d *data) error { +func (s *NetPrioGroup) Apply(d *cgroupData) error { dir, err := d.join("net_prio") if err != nil && !cgroups.IsNotFound(err) { return err @@ -37,7 +37,7 @@ func (s *NetPrioGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *NetPrioGroup) Remove(d *data) error { +func (s *NetPrioGroup) Remove(d *cgroupData) error { return removePath(d.path("net_prio")) } diff --git a/libcontainer/cgroups/fs/perf_event.go b/libcontainer/cgroups/fs/perf_event.go index 7bcb8df81..5693676d3 100644 --- a/libcontainer/cgroups/fs/perf_event.go +++ b/libcontainer/cgroups/fs/perf_event.go @@ -14,7 +14,7 @@ func (s *PerfEventGroup) Name() string { return "perf_event" } -func (s *PerfEventGroup) Apply(d *data) error { +func (s *PerfEventGroup) Apply(d *cgroupData) error { // we just want to join this group even though we don't set anything if _, err := d.join("perf_event"); err != nil && !cgroups.IsNotFound(err) { return err @@ -26,7 +26,7 @@ func (s *PerfEventGroup) Set(path string, cgroup *configs.Cgroup) error { return nil } -func (s *PerfEventGroup) Remove(d *data) error { +func (s *PerfEventGroup) Remove(d *cgroupData) error { return removePath(d.path("perf_event")) } diff --git a/libcontainer/cgroups/fs/util_test.go b/libcontainer/cgroups/fs/util_test.go index 0f3625607..01bf5f347 100644 --- a/libcontainer/cgroups/fs/util_test.go +++ b/libcontainer/cgroups/fs/util_test.go @@ -17,8 +17,8 @@ import ( ) type cgroupTestUtil struct { - // data to use in tests. - CgroupData *data + // cgroup data to use in tests. + CgroupData *cgroupData // Path to the mock cgroup directory. CgroupPath string @@ -30,7 +30,7 @@ type cgroupTestUtil struct { // Creates a new test util for the specified subsystem func NewCgroupTestUtil(subsystem string, t *testing.T) *cgroupTestUtil { - d := &data{ + d := &cgroupData{ c: &configs.Cgroup{}, } tempDir, err := ioutil.TempDir("", "cgroup_test")